jscene: poweroff upon SHIFT+AC/ON

This commit is contained in:
Lephenixnoir 2024-01-16 11:43:23 +01:00
parent 4c44b3e413
commit ef71bc11c0
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 16 additions and 0 deletions

View file

@ -33,6 +33,8 @@ typedef struct {
uint16_t lost_events;
/* Whether jscene_run() returns to the main menu */
bool mainmenu;
/* Whether jscene_run() powers off */
bool poweroff;
} jscene;
@ -110,6 +112,12 @@ bool jscene_process_event(jscene *scene, jevent event);
resources before invoking the main menu. */
void jscene_set_mainmenu(jscene *scene, bool mainmenu);
/* jscene_set_poweroff(): Set whether jscene_run() will poweroff
This type of poweroff (SHIFT+AC/ON) doesn't allow return to menu, so the
add-in "must" resume after powering on again, however sensitive programs
will probably want to save important data before leaving anyway. */
void jscene_set_poweroff(jscene *scene, bool poweroff);
/* jscene_run(): Run a scene's main loop
This function implements a main control loop that sleeps when there is

View file

@ -53,6 +53,7 @@ jscene *jscene_create(int x, int y, int w, int h, void *parent)
s->queue_next = 0;
s->lost_events = 0;
s->mainmenu = true;
s->poweroff = true;
/* Prepare first layout/paint operation */
s->widget.dirty = 1;
@ -225,6 +226,13 @@ jevent jscene_run(jscene *s)
continue;
}
}
if(k.type == KEYEV_DOWN && k.key == KEY_ACON && k.shift && !k.alpha) {
if(s->poweroff) {
gint_poweroff(true);
jscene_queue_event(s, (jevent){ .type = JSCENE_PAINT });
continue;
}
}
#ifdef FX9860G
if(k.type == KEYEV_DOWN && k.key == KEY_OPTN && k.shift && !k.alpha) {
t6k11_backlight(-1);