#include "common.h" #include "nu/nusys.h" /* 1A660 8008A260 */ u8 nuContMgrInit(void) { s32 i; u8 pattern; u8 bitmask; nuContDataUnLock(); osCreateMesgQueue(&nuContWaitMesgQ, &nuContWaitMesgBuf, 1); osCreateMesgQueue(&nuContDataMutexQ, &nuContDataMutexBuf, 1); nuSiCallBackAdd(&nuContCallBack); nuContQueryRead(); nuContNum = 0; bitmask = 1; pattern = 0; for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { if (nuContStatus[i].errno != 0) { continue; } if ((nuContStatus[i].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL) { nuContNum++; pattern |= bitmask; } bitmask <<= 1; } return pattern; } void nuContMgrRemove(void) { nuSiCallBackRemove(&nuContCallBack); } void nuContDataClose(void) { osSendMesg(&nuContDataMutexQ, NULL, OS_MESG_BLOCK); } void nuContDataOpen(void) { osRecvMesg(&nuContDataMutexQ, NULL, OS_MESG_BLOCK); } s32 nuContReadDataImpl(OSContPad* data, u32 flags) { s32 res; res = osContStartReadData(&nuSiMesgQ); if(res != 0) return res; osRecvMesg(&nuSiMesgQ, NULL, OS_MESG_BLOCK); if (!(flags & nuContDataLockKey)) { func_8008A354(); osContGetReadData(data); func_8008A37C(); return 0; } return 0; } s32 nuContQueryImpl(NUSiCommonMesg* mesg) { s32 ret = osContStartQuery(&nuSiMesgQ); if (ret != 0) { return ret; } osRecvMesg(&nuSiMesgQ, NULL, OS_MESG_BLOCK); osContGetQuery(nuContStatus); return ret; } s32 nuContRetraceImpl(NUSiCommonMesg* mesg) { if(nuContDataLockKey) { return NU_SI_CALLBACK_CONTINUE; } osRecvMesg(&nuContWaitMesgQ, NULL, OS_MESG_NOBLOCK); nuContReadDataImpl(nuContData, 1); if(nuContReadFunc != NULL) { nuContReadFunc(mesg->mesg); } osSendMesg(&nuContWaitMesgQ, NULL, OS_MESG_NOBLOCK); return NU_SI_CALLBACK_CONTINUE; } void nuContReadImpl(NUSiCommonMesg* mesg) { nuContReadDataImpl((OSContPad*)mesg->dataPtr, 0); } s32 nuContReadNWImpl(NUSiCommonMesg* mesg) { s32 rtn; osRecvMesg(&nuContWaitMesgQ, NULL, OS_MESG_NOBLOCK); rtn = nuContReadDataImpl(nuContData, 0); if (rtn) { return rtn; } if(nuContReadFunc != NULL) { (*nuContReadFunc)(mesg->mesg); } return rtn; }