diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-10 21:27:28 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-10 22:48:26 +0100 |
commit | 69420e796c4008b8923b8241ab3e154442735678 (patch) | |
tree | a43ee2f15a1fa38faa8a1e0967d07b0d3e41b832 | |
parent | a8063054f90b6f134a8bac089667356b8e974a38 (diff) |
touchscreen: Use pointing mode in the yes/no screen
Seems to fix the unintuitive / inaccurate behavior of this screen.
Rejigger the generic touchscreen keymap because the 3x3 buttons are
no longer used. Also map physical keys for yes/no on the Q1.
Change-Id: I2ed633896b87030fa654d47d9d02929b849495da
-rw-r--r-- | apps/gui/yesno.c | 21 | ||||
-rw-r--r-- | apps/keymaps/keymap-shanlingq1.c | 9 | ||||
-rw-r--r-- | apps/keymaps/keymap-touchscreen.c | 2 |
3 files changed, 28 insertions, 4 deletions
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 669f8ca09a..4098d630d0 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -164,6 +164,12 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, gui_yesno_draw(&(yn[i])); } +#ifdef HAVE_TOUCHSCREEN + /* switch to point mode because that's more intuitive */ + enum touchscreen_mode tsm = touchscreen_get_mode(); + touchscreen_set_mode(TOUCHSCREEN_POINT); +#endif + /* make sure to eat any extranous keypresses */ action_wait_for_release(); button_clear_queue(); @@ -211,12 +217,23 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, /* ignore some SYS events that can happen */ continue; default: - if(default_event_handler(button) == SYS_USB_CONNECTED) - return(YESNO_USB); + if(default_event_handler(button) == SYS_USB_CONNECTED) { +#ifdef HAVE_TOUCHSCREEN + /* restore old touchscreen mode */ + touchscreen_set_mode(tsm); +#endif + return YESNO_USB; + } + result = YESNO_NO; } } +#ifdef HAVE_TOUCHSCREEN + /* restore old touchscreen mode */ + touchscreen_set_mode(tsm); +#endif + FOR_NB_SCREENS(i) result_displayed=gui_yesno_draw_result(&(yn[i]), result); diff --git a/apps/keymaps/keymap-shanlingq1.c b/apps/keymaps/keymap-shanlingq1.c index 4745139e7a..2c09a40f4b 100644 --- a/apps/keymaps/keymap-shanlingq1.c +++ b/apps/keymaps/keymap-shanlingq1.c @@ -57,6 +57,13 @@ static const struct button_mapping button_context_list[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_list */ +static const struct button_mapping button_context_yesno[] = { + /* note: touchscreen buttons are usable in addition to physical keys */ + {ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE}, + {ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE}, + LAST_ITEM_IN_LIST +}; /* button_context_yesno */ + const struct button_mapping* target_get_context_mapping(int context) { switch (context) @@ -73,5 +80,7 @@ const struct button_mapping* target_get_context_mapping(int context) //return button_context_tree; case CONTEXT_LIST: return button_context_list; + case CONTEXT_YESNOSCREEN: + return button_context_yesno; } } diff --git a/apps/keymaps/keymap-touchscreen.c b/apps/keymaps/keymap-touchscreen.c index 6163cb054c..c70aea2651 100644 --- a/apps/keymaps/keymap-touchscreen.c +++ b/apps/keymaps/keymap-touchscreen.c @@ -179,8 +179,6 @@ static const struct button_mapping button_context_mainmenu[] = static const struct button_mapping button_context_yesno[] = { - { ACTION_YESNO_ACCEPT, BUTTON_TOPRIGHT, BUTTON_NONE }, - { ACTION_YESNO_ACCEPT, BUTTON_BOTTOMLEFT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_YESNOSCREEN) }; /* button_context_settings_yesno */ |