Files
MoHadiShibli--Control4Free/include/c4f_sce.h
T
MoHadiShibli 4331ec79fd Cleanup: drop the diagnostic spike, one version source, public tests
The staged spike that worked out the VDA call order is no longer part of the
build. It is kept at tag spike-final.

- src/main.c is the service only: instance lock, credentials, MBus and pad
  init, then the web service. src/server.c and include/c4f_server.h are gone
  with stage 8, and so are the stage-only helpers in src/vda.c: the MBus bind
  and holds, the assignment and button-map probes, and the GoldHEN klog stream
  path. The service reads /dev/klog, which is what works.
- VERSION holds the only version number. Both Makefiles pass it in, the
  packager reads it for param.sfo and the package name, and the build and
  deploy scripts read it for the file they look for.
- The payload's log is /data/control4free/control4free.log, not spike.log.
- The page drops the protocol 1 branches: the payload has always answered 2.
  A console slot is a "controller" and a pad plugged into the phone or PC is a
  "gamepad", so the two no longer read as the same word.
- The host tests move to tests/, with tests/run.py to run all four suites. They
  build the real sources with the PS4 calls stubbed, so they need no console.
  klog_test now covers the device path only, and asserts that nothing ever
  connects to GoldHEN's klog server.
2026-10-05 01:53:11 +03:00

96 lines
3.1 KiB
C

/* Control4Free -- declarations for the system libraries we drive.
*
* The virtual-device API (VDA) is not in any public SDK header, so the pieces we
* need are declared here. Everything was taken from ps4libdoc, the OpenOrbis
* stubs and seregonwar/SplashDown's psbutton.c, which is the only known working
* caller on a PS4.
*/
#ifndef C4F_SCE_H
#define C4F_SCE_H
#include <stddef.h>
#include <stdint.h>
/* ---- libSceUserService ---- */
int32_t sceUserServiceInitialize(void *params);
#define C4F_USER_ID_INVALID (-1)
/* ---- libScePad ---- */
int32_t scePadInit(void);
/* Lets an unsigned process talk to the pad service at all. SplashDown calls this
* with 1 before scePadInit; without it the VDA calls are refused. */
int32_t scePadSetProcessPrivilege(int32_t privilege);
/* The virtual-device API. AddDevice returns a status, NOT a usable handle: the
* handle is the MBus DeviceId the kernel logs right after the call. */
int32_t scePadVirtualDeviceAddDevice(void *param, int32_t deviceType);
int32_t scePadVirtualDeviceDeleteDevice(int32_t handle);
int32_t scePadVirtualDeviceInsertData(int32_t handle, const void *padData);
int32_t scePadVirtualDeviceGetRemoteSetting(int32_t handle, void *setting) __attribute__((weak));
/* Device type 3 is what SplashDown uses on both PS4 and PS5. */
#define C4F_VIRTUAL_DEVICE_TYPE 3
/* AddDevice's parameter block. size must be sizeof the struct (32). The six
* trailing words are unknown; we fill them with a marker so the log shows
* whether the call writes anything back into them. */
typedef struct {
int32_t size;
int32_t userId;
int32_t pad[6];
} C4fVdaParam;
/* Created for user 1, a device arrives unassigned and the PS4 opens its native
* "Who's using this controller?" screen (confirmed on firmware 10.01). */
#define C4F_VDA_USER_SELECT 1
/* ---- libSceMbus (no SDK stub exists: loaded with dlopen) ---- */
#define C4F_LIBSCEMBUS_PATH "/system/common/lib/libSceMbus.sprx"
/* ---- libkernel ---- */
int sceKernelSendNotificationRequest(int unk0, void *req, size_t size, int unk1);
/* ---- Pad sample ---- */
typedef struct {
uint16_t x;
uint16_t y;
uint8_t finger;
uint8_t pad[3];
} ScePadTouch;
typedef struct {
uint8_t fingers;
uint8_t pad1[3];
uint32_t pad2;
ScePadTouch touch[2];
} ScePadTouchData;
/* 120 bytes, same layout the normal scePadRead path uses. */
typedef struct {
uint32_t buttons;
uint8_t lx, ly;
uint8_t rx, ry;
uint8_t l2, r2;
uint16_t padding;
float quat[4];
float vel[3];
float accel[3];
ScePadTouchData touchData;
uint8_t connected;
uint8_t align[3];
uint64_t timestamp;
uint8_t ext[16];
uint8_t count;
uint8_t unknown[15];
} ScePadData;
/* VDA button bits use the standard read-side layout; these were confirmed on
* firmware 10.01. The page sends the full mask (C4F_INPUT_MASK in web.c). */
#define C4F_VDI_BUTTON_PS 0x00010000u /* moved the home screen */
#define C4F_VDI_BUTTON_CROSS 0x00004000u /* native second-user sign-in */
#endif /* C4F_SCE_H */