Do not store events as global variables

This commit is contained in:
exelix 2019-02-25 21:43:28 +01:00
parent 9d536520b3
commit a812549802
2 changed files with 4 additions and 37 deletions

View File

@ -2351,7 +2351,6 @@ bool appletMainLoop(void) {
appletCallHook(AppletHookType_OnPerformanceMode); appletCallHook(AppletHookType_OnPerformanceMode);
break; break;
} }
return true; return true;

View File

@ -13,10 +13,6 @@
static Service g_hidsysSrv; static Service g_hidsysSrv;
static u64 g_hidsysRefCnt; static u64 g_hidsysRefCnt;
static Event g_hidsysHomeEvent = {0};
static Event g_hidsysCaptureEvent = {0};
static Event g_hidSysSleepEvent = {0};
static u64 g_hidsysAppletResourceUserId = 0; static u64 g_hidsysAppletResourceUserId = 0;
Result hidsysInitialize(void) { Result hidsysInitialize(void) {
@ -37,11 +33,7 @@ Result hidsysInitialize(void) {
} }
void hidsysExit(void) { void hidsysExit(void) {
if (atomicDecrement64(&g_hidsysRefCnt) == 0) { if (atomicDecrement64(&g_hidsysRefCnt) == 0) {
eventClose(&g_hidsysHomeEvent);
eventClose(&g_hidsysCaptureEvent);
eventClose(&g_hidSysSleepEvent);
serviceClose(&g_hidsysSrv); serviceClose(&g_hidsysSrv);
} }
} }
@ -166,40 +158,16 @@ static Result _hidsysGetEvent(Event* event_out, u64 cmd_id, bool autoclear) {
} }
Result hidsysAcquireHomeButtonEventHandle(Event* event_out) { Result hidsysAcquireHomeButtonEventHandle(Event* event_out) {
if (eventActive(&g_hidsysHomeEvent)) return _hidsysGetEvent(event_out, 101, false);
{
*event_out = g_hidsysHomeEvent;
return 0;
}
Result rc = _hidsysGetEvent(&g_hidsysHomeEvent, 101, false);
if (R_SUCCEEDED(rc))
*event_out = g_hidsysHomeEvent;
return rc;
} }
//These functions don't seem to work in the overlaydisp applet context //These functions don't seem to work in the overlaydisp applet context
Result hidsysAcquireCaptureButtonEventHandle(Event* event_out) { Result hidsysAcquireCaptureButtonEventHandle(Event* event_out) {
if (eventActive(&g_hidsysCaptureEvent)) return _hidsysGetEvent(event_out, 141, false);
{
*event_out = g_hidsysCaptureEvent;
return 0;
}
Result rc = _hidsysGetEvent(&g_hidsysCaptureEvent, 141, false);
if (R_SUCCEEDED(rc))
*event_out = g_hidsysCaptureEvent;
return rc;
} }
Result hidsysAcquireSleepButtonEventHandle(Event* event_out) { Result hidsysAcquireSleepButtonEventHandle(Event* event_out) {
if (eventActive(&g_hidSysSleepEvent)) return _hidsysGetEvent(event_out, 121, false);
{
*event_out = g_hidSysSleepEvent;
return 0;
}
Result rc = _hidsysGetEvent(&g_hidSysSleepEvent, 121, false);
if (R_SUCCEEDED(rc))
*event_out = g_hidSysSleepEvent;
return rc;
} }
Result hidsysActivateHomeButton(void) { Result hidsysActivateHomeButton(void) {