20#define PAD_BIND_RPC_ID1 0x80000100
21#define PAD_BIND_RPC_ID2 0x80000101
23#define PAD_BIND_OLD_RPC_ID1 0x8000010f
24#define PAD_BIND_OLD_RPC_ID2 0x8000011f
27#ifdef BUILDING_XPADMAN
28 PAD_RPCCMD_OPEN = 0x01,
30 PAD_RPCCMD_INFO_ACT = 0x03,
34 PAD_RPCCMD_SET_ACTDIR,
35 PAD_RPCCMD_SET_ACTALIGN,
36 PAD_RPCCMD_GET_BTNMASK,
37 PAD_RPCCMD_SET_BTNINFO,
39 PAD_RPCCMD_GET_PORTMAX,
40 PAD_RPCCMD_GET_SLOTMAX,
45 PAD_RPCCMD_GET_MODVER = 0x12,
48 PAD_RPCCMD_OPEN = 0x80000100,
50 PAD_RPCCMD_INFO_ACT = 0x80000102,
54 PAD_RPCCMD_SET_ACTDIR,
55 PAD_RPCCMD_SET_ACTALIGN,
56 PAD_RPCCMD_GET_BTNMASK,
57 PAD_RPCCMD_SET_BTNINFO,
59 PAD_RPCCMD_GET_PORTMAX,
60 PAD_RPCCMD_GET_SLOTMAX,
67static s32 ThreadIdRpcServer;
73static s32 ThreadIdRpcServerExt;
78static void* RpcPadOpen(u32 *data)
81 data[3] =
padPortOpen(data[1], data[2], data[4], &data[5]);
86static void* RpcPadSetMainMode(u32 *data)
93static void* RpcPadInfoAct(u32 *data)
96 data[5] =
padInfoAct(data[1], data[2], data[3], data[4]);
101static void* RpcPadInfoComb(u32 *data)
103 data[5] = padInfoComb(data[1], data[2], data[3], data[4]);
108static void* RpcPadInfoMode(u32 *data)
110 data[5] =
padInfoMode(data[1], data[2], data[3], data[4]);
115static void* RpcPadSetActDirect(u32 *data)
122static void* RpcPadSetActAlign(u32 *data)
130static void* RpcPadGetButtonMask(u32 *data)
133 data[3] = padGetButtonMask(data[1], data[2]);
138static void* RpcPadSetButtonInfo(u32 *data)
140 data[4] = padSetButtonInfo(data[1], data[2], data[3]);
145static void* RpcPadSetVrefParam(u32 *data)
147 data[7] = padSetVrefParam(data[1], data[2], (u8*)&data[3]);
152static void* RpcPadGetPortMax(u32 *data)
159static void* RpcPadGetSlotMax(u32 *data)
166static void* RpcPadClose(u32 *data)
173static void* RpcPadEnd(u32 *data)
180#ifdef BUILDING_XPADMAN
181static void* RpcPadInit(u32 *data)
183 data[3] =
padInit((
void*)data[4]);
189#ifdef BUILDING_XPADMAN
190static void* RpcGetModVersion(u32 *data)
198static void* RpcServer(
int fno,
void *buffer,
int length)
200 u32 *data = (u32*)buffer;
201 u32 command = data[0];
206#ifdef BUILDING_XPADMAN
207 if ((0x00000100 & command) != 0)
209 if ((0x80000000 & command) != 0)
214 else if (command == 0x00000100)
224#ifdef BUILDING_XPADMAN
225 case PAD_RPCCMD_INIT:
return RpcPadInit(data);
227 case PAD_RPCCMD_END:
return RpcPadEnd(data);
228#ifdef BUILDING_XPADMAN
229 case PAD_RPCCMD_GET_MODVER:
return RpcGetModVersion(data);
231 case PAD_RPCCMD_OPEN:
return RpcPadOpen(data);
232 case PAD_RPCCMD_CLOSE:
return RpcPadClose(data);
233 case PAD_RPCCMD_INFO_ACT:
return RpcPadInfoAct(data);
234 case PAD_RPCCMD_INFO_COMB:
return RpcPadInfoComb(data);
235 case PAD_RPCCMD_INFO_MODE:
return RpcPadInfoMode(data);
236 case PAD_RPCCMD_SET_MMODE:
return RpcPadSetMainMode(data);
237 case PAD_RPCCMD_SET_ACTDIR:
return RpcPadSetActDirect(data);
238 case PAD_RPCCMD_SET_ACTALIGN:
return RpcPadSetActAlign(data);
239 case PAD_RPCCMD_GET_BTNMASK:
return RpcPadGetButtonMask(data);
240 case PAD_RPCCMD_SET_BTNINFO:
return RpcPadSetButtonInfo(data);
241 case PAD_RPCCMD_SET_VREF:
return RpcPadSetVrefParam(data);
242 case PAD_RPCCMD_GET_PORTMAX:
return RpcPadGetPortMax(data);
243 case PAD_RPCCMD_GET_SLOTMAX:
return RpcPadGetSlotMax(data);
246 M_PRINTF(
"invalid function code (%03x)\n", (
int)data[0]);
253static void* RpcServerExt(
int fno,
void *buffer,
int length)
258 M_PRINTF(
"Extend Service: This service is not supported.\n");
264static void RpcThread(
void *arg)
268 if( sceSifCheckInit() == 0)
270 M_PRINTF(
"Sif not initialized.\n");
275 sceSifSetRpcQueue(&qd, GetThreadId());
276#ifdef BUILDING_XPADMAN
277 sceSifRegisterRpc(&sd[0], PAD_BIND_RPC_ID1, &RpcServer, sb[0], NULL, NULL, &qd);
279 sceSifRegisterRpc(&sd[1], PAD_BIND_OLD_RPC_ID1, &RpcServer, sb[1], NULL, NULL, &qd);
283static void RpcThreadExt(
void *arg)
287 if( sceSifCheckInit() == 0)
289 M_PRINTF(
"Sif not initialized.\n");
294 sceSifSetRpcQueue(&qdext, GetThreadId());
295#ifdef BUILDING_XPADMAN
296 sceSifRegisterRpc(&sdext[0], PAD_BIND_RPC_ID2, &RpcServerExt, sbext[0], NULL, NULL, &qdext);
298 sceSifRegisterRpc(&sdext[1], PAD_BIND_OLD_RPC_ID2, &RpcServerExt, sbext[1], NULL, NULL, &qdext);
299 sceSifRpcLoop(&qdext);
302int InitRpcServers(
int prio)
307 prio = PADMAN_THPRI_LO;
310 rpc_thread.attr = TH_C;
311 rpc_thread.thread = &RpcThread;
312 rpc_thread.stacksize = 0x800;
313 rpc_thread.priority = prio;
315 ThreadIdRpcServer = CreateThread(&rpc_thread);
317 if(ThreadIdRpcServer == 0)
return 0;
319 StartThread(ThreadIdRpcServer, NULL);
322 rpc_thread.attr = TH_C;
323 rpc_thread.thread = &RpcThreadExt;
324 rpc_thread.stacksize = 0x800;
325 rpc_thread.priority = prio;
327 ThreadIdRpcServerExt = CreateThread(&rpc_thread);
329 if(ThreadIdRpcServerExt == 0)
return 0;
331 StartThread(ThreadIdRpcServerExt, NULL);
int padPortOpen(int port, int slot, void *padArea)
int padSetActAlign(int port, int slot, const char act_align[6])
int padInfoMode(int port, int slot, int infoMode, int index)
int padSetActDirect(int port, int slot, char act_align[6])
int padPortClose(int port, int slot)
unsigned char padInfoAct(int port, int slot, int word, int byte)
int padSetMainMode(int port, int slot, int mode, int lock)
int padGetSlotMax(int port)