15#ifdef BUILDING_XPADMAN
26extern struct irx_id _irx_id;
29extern u32 openSlots[2];
31extern int padman_init;
32extern void *pad_ee_addr;
36 DeleteThread(s->tid_1);
37 DeleteThread(s->tid_2);
38 DeleteEventFlag(s->eventflag);
47 for(port = 0; port < 2; port++)
48 for(slot=0; slot < 4; slot++)
50 if((openSlots[port] >> slot) & 0x1)
54 SetEventFlag(vblankData.eventflag, EF_EXIT_THREAD);
56 vblankData.padEnd = 1;
58 WaitEventFlag(vblankData.eventflag, EF_VB_WAIT_THREAD_EXIT, 0x11, 0);
60 DeleteThreadsEventFlag( &vblankData );
62 while(ReleaseVblankHandler(0, (
void*)VblankStart) != 0)
63 M_PRINTF(
"Release VB_START failed.\n");
65 while(ReleaseVblankHandler(1, VblankEnd) != 0)
66 M_PRINTF(
"Release VB_END failed.\n");
77 if(((openSlots[port] >> slot) & 1) == 0)
79 M_PRINTF(
"padPortClose: Port %i Slot %i is not open.\n", (
int)port, (
int)slot);
83 if(padState[port][slot].reqState == PAD_RSTAT_BUSY)
85 M_PRINTF(
"padPortClose: Port %i Slot %i request failed.\n", (
int)port, (
int)slot);
89 padState[port][slot].runTask = TASK_PORT_CLOSE;
90 padState[port][slot].taskTid = 0;
91 padState[port][slot].reqState = PAD_RSTAT_BUSY;
97 WaitEventFlag(padState[port][slot].eventflag, EF_PORT_CLOSE, 0x10, &resbits);
98 DeleteEventFlag(padState[port][slot].eventflag);
99 padState[port][slot].eventflag = 0;
107 if( (padState[port][slot].currentTask != TASK_UPDATE_PAD) || ( padState[port][slot].modeConfig < MODE_CONFIG_READY) )
110 if( mode >= padState[port][slot].numModes )
113 if( padState[port][slot].reqState != PAD_RSTAT_BUSY)
115 padState[port][slot].mode = mode;
116 padState[port][slot].lock = lock;
117 padState[port][slot].runTask = TASK_SET_MAIN_MODE;
118 padState[port][slot].reqState = PAD_RSTAT_BUSY;
119 padState[port][slot].taskTid = padState[port][slot].setmainmodeTid;
127s32
padInfoAct(u32 port, u32 slot, s32 act, u32 val)
129 if(padState[port][slot].currentTask != TASK_UPDATE_PAD)
132 if(padState[port][slot].modeConfig < MODE_CONFIG_READY)
135 if(act == -1)
return padState[port][slot].numActuators;
137 if( act < padState[port][slot].numActuators )
139 u8 *actData = padState[port][slot].actData.data[act];
157s32 padInfoComb(u32 port, u32 slot, s32 listno, u32 offs)
159 if(padState[port][slot].currentTask != TASK_UPDATE_PAD)
162 if(padState[port][slot].modeConfig < MODE_CONFIG_READY)
165 if(listno == -1)
return padState[port][slot].numActComb;
167 if( listno < padState[port][slot].numActComb)
169 u8 *combData = padState[port][slot].combData.data[listno];
187s32
padInfoMode(u32 port, u32 slot, s32 term, u32 offs)
189 if((padState[port][slot].currentTask != TASK_UPDATE_PAD) || (padState[port][slot].reqState == PAD_RSTAT_BUSY))
195 if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD)
198 return padState[port][slot].modeTable.data[padState[port][slot].modeCurOffs];
200 if( padState[port][slot].modeCurId != PAD_ID_CONFIG)
201 return (PAD_ID_HI(PAD_ID_CONFIG));
205 if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD)
208 return padState[port][slot].modeCurOffs;
210 if(padState[port][slot].modeConfig == MODE_CONFIG_QUERY_PAD)
214 if(offs == (u32)(-1))
216 return padState[port][slot].numModes;
220 u16* mode = padState[port][slot].modeTable.data;
222 if(offs < padState[port][slot].numModes)
233u32 ActDirectTotal(u32 port, u32 slot)
242 if( (p == port) && (s == slot) && (((openSlots[port] >> slot) & 1) != 0))
244 if(padState[port][slot].modeCurId != 0)
248 for(i=0; i < padState[port][slot].ee_actDirectSize; i++)
250 if((padState[port][slot].ee_actAlignData.data[i] != 0xFF)
251 && (padState[port][slot].ee_actDirectData.data[i] != 0))
253 u8 *act = padState[port][slot].actData.data[padState[port][slot].ee_actAlignData.data[i]];
265u32 CheckAirDirectTotal(u32 port, u32 slot, u8 *actData)
268 u32 total = ActDirectTotal(port, slot);
272 u32 a = padState[port][slot].ee_actAlignData.data[i];
276 if( actData[a] != 0 )
278 u8 *act = padState[port][slot].actData.data[a];
284 M_KPRINTF(
"Over Consumpt Max 600mA[%d][%d]\n", (
int)port, (
int)slot);
296 if(padState[port][slot].currentTask == TASK_UPDATE_PAD)
298 if( CheckAirDirectTotal(port, slot, actData) == 0)
300 M_KPRINTF(
"Over consumpt Max [%d][%d]\n", (
int)port, (
int)slot);
307 padState[port][slot].ee_actDirectData.data[i] = actData[i];
309 padState[port][slot].ee_actDirectSize = 6;
320 if( (padState[port][slot].currentTask != TASK_UPDATE_PAD) || ( padState[port][slot].modeConfig < MODE_CONFIG_READY) )
323 if( padState[port][slot].reqState != PAD_RSTAT_BUSY)
328 padState[port][slot].ee_actAlignData.data[i] = actData[i];
330 padState[port][slot].reqState = PAD_RSTAT_BUSY;
331 padState[port][slot].runTask = TASK_SET_ACT_ALIGN;
332 padState[port][slot].taskTid = padState[port][slot].setactalignTid;
340u32 padGetButtonMask(u32 port, u32 slot)
344 if( (padState[port][slot].currentTask != TASK_UPDATE_PAD) || ( padState[port][slot].modeConfig < MODE_CONFIG_READY) )
347 if( padState[port][slot].model < 2)
350 ret = (u32)padState[port][slot].buttonMask[0];
351 ret |= (u32)padState[port][slot].buttonMask[1] << 8;
352 ret |= (u32)padState[port][slot].buttonMask[2] << 16;
353 ret |= (u32)padState[port][slot].buttonMask[3] << 24;
358u32 padSetButtonInfo(u32 port, u32 slot, u32
info)
360 if( (padState[port][slot].currentTask != TASK_UPDATE_PAD) || ( padState[port][slot].modeConfig < MODE_CONFIG_READY) )
363 if( padState[port][slot].model < 2)
366 if( padState[port][slot].reqState != PAD_RSTAT_BUSY)
372 padState[port][slot].buttonInfo[0] = (u8)(
info);
373 padState[port][slot].buttonInfo[1] = (u8)(
info >> 8);
374 padState[port][slot].buttonInfo[2] = (u8)(
info >> 16);
375 padState[port][slot].buttonInfo[3] = (u8)(
info >> 24);
377 for(i=0; i < 11; i++)
378 padState[port][slot].modeParam[i] = 0x2;
380 padState[port][slot].reqState = PAD_RSTAT_BUSY;
381 padState[port][slot].runTask = TASK_SET_BUTTON_INFO;
382 padState[port][slot].taskTid = padState[port][slot].setbuttoninfoTid;
391u32 padSetVrefParam(u32 port, u32 slot,
const u8 *vparam)
393 if( (padState[port][slot].currentTask != TASK_UPDATE_PAD) || ( padState[port][slot].modeConfig < MODE_CONFIG_READY) )
396 if( padState[port][slot].model < 2)
399 if( padState[port][slot].reqState != PAD_RSTAT_BUSY)
403 for(i=0; i < 12; i++)
404 padState[port][slot].modeParam[i] = vparam[i];
406 padState[port][slot].runTask = TASK_SET_VREF_PARAM;
407 padState[port][slot].reqState = PAD_RSTAT_BUSY;
408 padState[port][slot].taskTid = padState[port][slot].setvrefparamTid;
423#ifdef BUILDING_XPADMAN
424 return sio2_mtap_get_slot_max(port);
435u32 padGetInBuffer(u32 port, u32 slot, u8 *buf)
439 for(i=0; i < 32 ; i++)
440 buf[i] = padState[port][slot].inbuffer[i];
445u32 padGetModeConfig(u32 port, u32 slot)
447 return padState[port][slot].modeConfig;
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)
u32 padGetModVersion(void)