Updated APT_CheckNew3DS to only use the APT cmds once(which also now calls aptOpenSession/aptCloseSession), then store the output value in a flag which is then used for all future APT_CheckNew3DS calls. Updated HID init/shutdown code to automatically call irrst init/shutdown code when running on new3ds. Updated irrst init code to only do init when it wasn't already initialized, likewise for the irrst shutdown code.
This commit is contained in:
parent
4e90fbb905
commit
3135d1c344
@ -69,7 +69,7 @@ Result APT_PrepareToCloseApplication(Handle* handle, u8 a);
|
||||
Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c);
|
||||
Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent);
|
||||
Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent);
|
||||
Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);//*Application and *System use APT commands 0x01010000 and 0x01020000. Using APT_CheckNew3DS() is recommended, this determines which of those two funcs to use automatically.
|
||||
Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);//*Application and *System use APT commands 0x01010000 and 0x01020000. Using APT_CheckNew3DS() is recommended, this determines which of those two funcs to use automatically. When this is first called(this calls aptOpenSession/aptCloseSession internally), this initializes an internal flag, which is then used for the out val for all future calls.
|
||||
Result APT_CheckNew3DS_System(Handle* handle, u8 *out);
|
||||
Result APT_CheckNew3DS(Handle* handle, u8 *out);
|
||||
|
||||
|
@ -17,6 +17,9 @@ NS_APPID currentAppId;
|
||||
static char *__apt_servicestr = NULL;
|
||||
static char *__apt_servicenames[3] = {"APT:U", "APT:S", "APT:A"};
|
||||
|
||||
static u32 __apt_new3dsflag_initialized = 0;
|
||||
static u8 __apt_new3dsflag = 0;
|
||||
|
||||
Handle aptLockHandle;
|
||||
Handle aptuHandle;
|
||||
Handle aptEvents[3];
|
||||
@ -838,7 +841,22 @@ Result APT_CheckNew3DS_System(Handle* handle, u8 *out)
|
||||
|
||||
Result APT_CheckNew3DS(Handle* handle, u8 *out)
|
||||
{
|
||||
if(currentAppId==APPID_APPLICATION)return APT_CheckNew3DS_Application(NULL, out);
|
||||
return APT_CheckNew3DS_System(NULL, out);
|
||||
Result ret=0;
|
||||
|
||||
if(__apt_new3dsflag_initialized)
|
||||
{
|
||||
*out = __apt_new3dsflag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
aptOpenSession();
|
||||
if(currentAppId==APPID_APPLICATION)ret = APT_CheckNew3DS_Application(NULL, out);
|
||||
ret = APT_CheckNew3DS_System(NULL, out);
|
||||
aptCloseSession();
|
||||
|
||||
__apt_new3dsflag_initialized = 1;
|
||||
__apt_new3dsflag = *out;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ static angularRate gRate;
|
||||
|
||||
Result hidInit(u32* sharedMem)
|
||||
{
|
||||
u8 val=0;
|
||||
|
||||
if(!sharedMem)sharedMem=(u32*)HID_SHAREDMEM_DEFAULT;
|
||||
Result ret=0;
|
||||
|
||||
@ -34,9 +36,16 @@ Result hidInit(u32* sharedMem)
|
||||
hidSharedMem=sharedMem;
|
||||
if((ret=svcMapMemoryBlock(hidMemHandle, (u32)hidSharedMem, MEMPERM_READ, 0x10000000)))goto cleanup2;
|
||||
|
||||
APT_CheckNew3DS(NULL, &val);
|
||||
|
||||
if(val)
|
||||
{
|
||||
ret = irrstInit(NULL);
|
||||
}
|
||||
|
||||
// Reset internal state.
|
||||
kOld = kHeld = kDown = kUp = 0;
|
||||
return 0;
|
||||
return ret;
|
||||
|
||||
cleanup2:
|
||||
svcCloseHandle(hidMemHandle);
|
||||
@ -48,10 +57,18 @@ cleanup1:
|
||||
void hidExit()
|
||||
{
|
||||
// Unmap HID sharedmem and close handles.
|
||||
u8 val=0;
|
||||
int i; for(i=0; i<5; i++)svcCloseHandle(hidEvents[i]);
|
||||
svcUnmapMemoryBlock(hidMemHandle, (u32)hidSharedMem);
|
||||
svcCloseHandle(hidMemHandle);
|
||||
svcCloseHandle(hidHandle);
|
||||
|
||||
APT_CheckNew3DS(NULL, &val);
|
||||
|
||||
if(val)
|
||||
{
|
||||
irrstExit();
|
||||
}
|
||||
}
|
||||
|
||||
void hidWaitForEvent(HID_Event id, bool nextEvent)
|
||||
|
@ -17,6 +17,8 @@ static bool irrstUsed = false;
|
||||
|
||||
Result irrstInit(u32* sharedMem)
|
||||
{
|
||||
if(irrstUsed)return 0;
|
||||
|
||||
if(!sharedMem)sharedMem=(u32*)IRRST_SHAREDMEM_DEFAULT;
|
||||
Result ret=0;
|
||||
|
||||
@ -44,6 +46,8 @@ cleanup1:
|
||||
|
||||
void irrstExit()
|
||||
{
|
||||
if(!irrstUsed)return;
|
||||
|
||||
irrstUsed = false;
|
||||
svcCloseHandle(irrstEvent);
|
||||
// Unmap ir:rst sharedmem and close handles.
|
||||
|
Loading…
Reference in New Issue
Block a user