From 2d58ec4c86fcc7b02bc3c220c4d37baf03fc23ab Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Thu, 9 Jul 2020 22:20:29 +0100 Subject: [PATCH] rosalina: prevent sleep mode entry if debugger/input redir is enabled to prevent lockup --- sysmodules/rosalina/source/main.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/sysmodules/rosalina/source/main.c b/sysmodules/rosalina/source/main.c index e2ebe61..91a0cfe 100644 --- a/sysmodules/rosalina/source/main.c +++ b/sysmodules/rosalina/source/main.c @@ -133,6 +133,29 @@ static void handleTermNotification(u32 notificationId) (void)notificationId; } +static void handleSleepNotification(u32 notificationId) +{ + ptmSysmInit(); + s32 ackValue = ptmSysmGetNotificationAckValue(notificationId); + switch (notificationId) + { + case PTMNOTIFID_SLEEP_REQUESTED: + PTMSYSM_ReplyToSleepQuery(miniSocEnabled); // deny sleep request if we have network stuff running + break; + case PTMNOTIFID_GOING_TO_SLEEP: + case PTMNOTIFID_SLEEP_ALLOWED: + case PTMNOTIFID_FULLY_WAKING_UP: + case PTMNOTIFID_HALF_AWAKE: + PTMSYSM_NotifySleepPreparationComplete(ackValue); + break; + case PTMNOTIFID_SLEEP_DENIED: + case PTMNOTIFID_FULLY_AWAKE: + default: + break; + } + ptmSysmExit(); +} + static void handlePreTermNotification(u32 notificationId) { (void)notificationId; @@ -182,11 +205,17 @@ static const ServiceManagerServiceEntry services[] = { }; static const ServiceManagerNotificationEntry notifications[] = { - { 0x100 , handleTermNotification }, - //{ 0x103 , handlePreTermNotification }, // Sleep mode entry <=== causes issues - { 0x1000, handleNextApplicationDebuggedByForce }, - { 0x2000, handlePreTermNotification }, - { 0x3000, handleRestartHbAppNotification }, + { 0x100 , handleTermNotification }, + { PTMNOTIFID_SLEEP_REQUESTED, handleSleepNotification }, + { PTMNOTIFID_SLEEP_DENIED, handleSleepNotification }, + { PTMNOTIFID_SLEEP_ALLOWED, handleSleepNotification }, + { PTMNOTIFID_GOING_TO_SLEEP, handleSleepNotification }, + { PTMNOTIFID_FULLY_WAKING_UP, handleSleepNotification }, + { PTMNOTIFID_FULLY_AWAKE, handleSleepNotification }, + { PTMNOTIFID_HALF_AWAKE, handleSleepNotification }, + { 0x1000, handleNextApplicationDebuggedByForce }, + { 0x2000, handlePreTermNotification }, + { 0x3000, handleRestartHbAppNotification }, { 0x000, NULL }, };