rgnano: Sleep timer and idle poweroff support

Actually power off the handheld with the sleep timer and idle poweroff functions instead of closing rockbox.

This commit also moves setting system volume to max from the launch script to system-sdl.c so it works when running rockbox via instant play.

Change-Id: I174b67c6abef451faa05f4a8f52b8d9eeed98a22
This commit is contained in:
Hairo R. Carela 2025-08-12 21:34:17 -04:00 committed by Solomon Peachy
parent 5ecb5832e1
commit c9e16e4888
6 changed files with 38 additions and 28 deletions

View file

@ -80,27 +80,32 @@ void ip_reset_values(void)
}
}
void ip_power_off(void)
{
/* Stop the powerdown countdown */
system("powerdown handle");
/* Write the instant_play file */
char buf[60];
size_t nbytes;
int fd;
fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640);
strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n");
nbytes = strlen(buf);
write(fd, buf, nbytes);
close(fd);
/* Powerdown the handheld after writting the file */
system("powerdown now");
}
void ip_handle_sigusr1(int sig)
{
if (sig == SIGUSR1)
{
/* Stop the powerdown countdown */
system("powerdown handle");
/* Write the instant_play file */
char buf[60];
size_t nbytes;
int fd;
fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640);
strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n");
nbytes = strlen(buf);
write(fd, buf, nbytes);
close(fd);
/* Powerdown the handheld after writting the file */
system("powerdown now");
ip_power_off();
}
}