Просмотр исходного кода

AleX83Xpert/add f keys to keyboard layout (#2362)

* Assets: png images for F1..F12 keys: Will be used for HID keyboard layout
* HID KEYBOARD F1..F12 keys were added
  - a new row with functional keys was added
  - logic for displaying the keyboard layout was improved
* HidApp: hid functional keys by default

Co-authored-by: あく <alleteam@gmail.com>
nas 2 лет назад
Родитель
Сommit
79d45c97f9

BIN
applications/plugins/hid_app/assets/ButtonF10_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF11_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF12_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF1_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF2_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF3_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF4_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF5_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF6_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF7_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF8_5x8.png


BIN
applications/plugins/hid_app/assets/ButtonF9_5x8.png


+ 25 - 3
applications/plugins/hid_app/views/hid_keyboard.c

@@ -46,11 +46,25 @@ 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
 const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = {
+    {
+        {.width = 1, .icon = &I_ButtonF1_5x8, .value = HID_KEYBOARD_F1},
+        {.width = 1, .icon = &I_ButtonF2_5x8, .value = HID_KEYBOARD_F2},
+        {.width = 1, .icon = &I_ButtonF3_5x8, .value = HID_KEYBOARD_F3},
+        {.width = 1, .icon = &I_ButtonF4_5x8, .value = HID_KEYBOARD_F4},
+        {.width = 1, .icon = &I_ButtonF5_5x8, .value = HID_KEYBOARD_F5},
+        {.width = 1, .icon = &I_ButtonF6_5x8, .value = HID_KEYBOARD_F6},
+        {.width = 1, .icon = &I_ButtonF7_5x8, .value = HID_KEYBOARD_F7},
+        {.width = 1, .icon = &I_ButtonF8_5x8, .value = HID_KEYBOARD_F8},
+        {.width = 1, .icon = &I_ButtonF9_5x8, .value = HID_KEYBOARD_F9},
+        {.width = 1, .icon = &I_ButtonF10_5x8, .value = HID_KEYBOARD_F10},
+        {.width = 1, .icon = &I_ButtonF11_5x8, .value = HID_KEYBOARD_F11},
+        {.width = 1, .icon = &I_ButtonF12_5x8, .value = HID_KEYBOARD_F12},
+    },
     {
         {.width = 1, .icon = NULL, .key = "1", .shift_key = "!", .value = HID_KEYBOARD_1},
         {.width = 1, .icon = NULL, .key = "2", .shift_key = "@", .value = HID_KEYBOARD_2},
@@ -224,7 +238,12 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
 
     canvas_set_font(canvas, FontKeyboard);
     // Start shifting the all keys up if on the next row (Scrolling)
-    uint8_t initY = model->y - 4 > 0 ? model->y - 4 : 0;
+    uint8_t initY = model->y == 0 ? 0 : 1;
+
+    if(model->y > 5) {
+        initY = model->y - 4;
+    }
+
     for(uint8_t y = initY; y < ROW_COUNT; y++) {
         const HidKeyboardKey* keyboardKeyRow = hid_keyboard_keyset[y];
         uint8_t x = 0;
@@ -365,7 +384,10 @@ HidKeyboard* hid_keyboard_alloc(Hid* bt_hid) {
     with_view_model(
         hid_keyboard->view,
         HidKeyboardModel * model,
-        { model->transport = bt_hid->transport; },
+        {
+            model->transport = bt_hid->transport;
+            model->y = 1;
+        },
         true);
 
     return hid_keyboard;