reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit e1bb26563903b510d3513575c45a8581d6ec6790
parent bda0766375f13deba63507e4896c0ee8a672ae1e
Author: Lukas F. Hartmann <lukas@mntre.com>
Date:   Tue,  2 Mar 2021 16:22:43 +0100

keyboard: don't reenter menu mode until all keys have been lifted again

Diffstat:
Mreform2-keyboard-fw/Keyboard.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/reform2-keyboard-fw/Keyboard.c b/reform2-keyboard-fw/Keyboard.c @@ -554,10 +554,6 @@ int execute_meta_function(int keycode) { render_menu(current_scroll_y); return 1; } - else if (keycode == KEY_M) { - render_menu(current_scroll_y); - return 1; - } else if (keycode == KEY_ENTER) { return execute_menu_function(current_menu_y); } @@ -634,16 +630,18 @@ void process_keyboard(char usb_report_mode, USB_KeyboardReport_Data_t* KeyboardR if (debounced_pressed) { total_pressed++; + // circle key? if (keycode == HID_KEYBOARD_SC_EXSEL) { - if (!active_meta_mode) { + if (!active_meta_mode && !last_meta_key) { current_scroll_y = 0; current_menu_y = 0; active_meta_mode = 1; // render menu - execute_meta_function(KEY_M); + render_menu(current_scroll_y); } } else { if (active_meta_mode) { + // not holding the same key? if (last_meta_key!=keycode) { // hyper/circle/menu functions int stay_meta = execute_meta_function(keycode); @@ -656,7 +654,7 @@ void process_keyboard(char usb_report_mode, USB_KeyboardReport_Data_t* KeyboardR } } } else if (!last_meta_key) { - // report keypress via USB + // not meta mode, regular key: report keypress via USB // 6 keys is a hard limit in the HID descriptor :/ if (usb_report_mode && KeyboardReport && used_key_codes<6) { KeyboardReport->KeyCode[used_key_codes++] = keycode; @@ -676,6 +674,7 @@ void process_keyboard(char usb_report_mode, USB_KeyboardReport_Data_t* KeyboardR } } + // if no more keys are held down, allow a new meta command if (total_pressed<1) last_meta_key = 0; }