From 690a806a8330757333018e2b15cb005e3226fd04 Mon Sep 17 00:00:00 2001 From: Gabriel Cirlig Date: Tue, 1 Nov 2022 14:15:08 -0400 Subject: [PATCH] add function keys --- views/usb_hid_keyboard.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/views/usb_hid_keyboard.c b/views/usb_hid_keyboard.c index 11c3305..fe07243 100644 --- a/views/usb_hid_keyboard.c +++ b/views/usb_hid_keyboard.c @@ -42,7 +42,7 @@ typedef struct { #define KEY_WIDTH 9 #define KEY_HEIGHT 12 #define KEY_PADDING 1 -#define ROW_COUNT 6 +#define ROW_COUNT 7 #define COLUMN_COUNT 12 // 0 width items are not drawn, but there value is used @@ -135,6 +135,20 @@ const UsbHidKeyboardKey usb_hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = { {.width = 0, .icon = NULL, .value = HID_KEYBOARD_TAB}, {.width = 0, .icon = NULL, .value = HID_KEYBOARD_TAB}, }, + { + {.width = 1, .icon = NULL, .key = "1", .shift_key = "1", .value = HID_KEYBOARD_F1}, + {.width = 1, .icon = NULL, .key = "2", .shift_key = "2", .value = HID_KEYBOARD_F2}, + {.width = 1, .icon = NULL, .key = "3", .shift_key = "3", .value = HID_KEYBOARD_F3}, + {.width = 1, .icon = NULL, .key = "4", .shift_key = "4", .value = HID_KEYBOARD_F4}, + {.width = 1, .icon = NULL, .key = "5", .shift_key = "5", .value = HID_KEYBOARD_F5}, + {.width = 1, .icon = NULL, .key = "6", .shift_key = "6", .value = HID_KEYBOARD_F6}, + {.width = 1, .icon = NULL, .key = "7", .shift_key = "7", .value = HID_KEYBOARD_F7}, + {.width = 1, .icon = NULL, .key = "8", .shift_key = "8", .value = HID_KEYBOARD_F8}, + {.width = 1, .icon = NULL, .key = "9", .shift_key = "9", .value = HID_KEYBOARD_F9}, + {.width = 1, .icon = NULL, .key = "0", .shift_key = "0", .value = HID_KEYBOARD_F10}, + {.width = 1, .icon = NULL, .key = "1", .shift_key = "1", .value = HID_KEYBOARD_F11}, + {.width = 1, .icon = NULL, .key = "2", .shift_key = "2", .value = HID_KEYBOARD_F12}, + } }; static void usb_hid_keyboard_to_upper(char* str) { @@ -216,6 +230,7 @@ static void usb_hid_keyboard_draw_callback(Canvas* canvas, void* context) { // Select if back is clicked and its the backspace key // Deselect when the button clicked or not hovered bool keySelected = (x <= model->x && model->x < (x + key.width)) && y == model->y; + keySelected = y == ROW_COUNT - 1 ? !keySelected : keySelected; bool backSelected = model->back_pressed && key.value == HID_KEYBOARD_DELETE; usb_hid_keyboard_draw_key( canvas, @@ -368,4 +383,4 @@ void usb_hid_keyboard_free(UsbHidKeyboard* usb_hid_keyboard) { View* usb_hid_keyboard_get_view(UsbHidKeyboard* usb_hid_keyboard) { furi_assert(usb_hid_keyboard); return usb_hid_keyboard->view; -} \ No newline at end of file +}