From dec23085f759e917f1acb2137c9ea3e71e85fd48 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Thu, 29 Aug 2024 13:10:11 -0600 Subject: [PATCH] fix: HID menus items navigation --- .../main/apps/ble/hid_device/hid_module.c | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/firmware/main/apps/ble/hid_device/hid_module.c b/firmware/main/apps/ble/hid_device/hid_module.c index e062a58..3b05324 100644 --- a/firmware/main/apps/ble/hid_device/hid_module.c +++ b/firmware/main/apps/ble/hid_device/hid_module.c @@ -19,14 +19,6 @@ static void hid_module_reset_menu() { menus_module_set_app_state(true, hid_module_cb_event); } -static void hid_module_increment_item() { - current_item++; -} - -static void hid_module_decrement_item() { - current_item--; -} - static void hid_module_cb_connection_handler(bool connection) { hid_module_display_device_connection(connection); if (!connection) { @@ -41,17 +33,11 @@ static void hid_module_cb_event_volumen(uint8_t button_name, } switch (button_name) { case BUTTON_UP: - hid_module_decrement_item(); - if (current_item < 0) { - current_item = HID_DEVICE_COUNT - 1; - } + current_item = current_item-- == 0 ? HID_DEVICE_COUNT - 1 : current_item; hid_module_display_menu(current_item); break; case BUTTON_DOWN: - hid_module_increment_item(); - if (current_item > HID_DEVICE_COUNT - 1) { - current_item = 0; - } + current_item = ++current_item > HID_DEVICE_COUNT - 1 ? 0 : current_item; hid_module_display_menu(current_item); break; case BUTTON_LEFT: @@ -86,17 +72,11 @@ static void hid_module_cb_event(uint8_t button_name, uint8_t button_event) { } switch (button_name) { case BUTTON_UP: - hid_module_decrement_item(); - if (current_item < 0) { - current_item = HID_MENU_COUNT - 1; - } + current_item = current_item-- == 0 ? HID_MENU_COUNT - 1 : current_item; hid_module_display_menu(current_item); break; case BUTTON_DOWN: - hid_module_increment_item(); - if (current_item > HID_MENU_COUNT - 1) { - current_item = 0; - } + current_item = ++current_item > HID_MENU_COUNT - 1 ? 0 : current_item; hid_module_display_menu(current_item); break; case BUTTON_RIGHT: