From 3c73123a81a7aeb1032680a2f33496c1396bb2b9 Mon Sep 17 00:00:00 2001 From: Nikolay Minaylov Date: Fri, 9 Feb 2024 12:33:47 +0300 Subject: [PATCH] HID app: keyboard modifiers fix (#3378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * HID App: Modifier keys fix * Toggled keys indication * New enter and backspace button icons Co-authored-by: あく --- .../hid_app/assets/Alt_pressed_17x10.png | Bin 0 -> 4227 bytes .../system/hid_app/assets/Backspace_9x7.png | Bin 0 -> 6628 bytes .../hid_app/assets/Cmd_pressed_17x10.png | Bin 0 -> 4234 bytes .../hid_app/assets/Ctrl_pressed_17x10.png | Bin 0 -> 4227 bytes .../system/hid_app/assets/Return_10x7.png | Bin 0 -> 6630 bytes .../hid_app/assets/Shift_pressed_7x10.png | Bin 0 -> 6626 bytes .../system/hid_app/views/hid_keyboard.c | 212 ++++++++++-------- 7 files changed, 115 insertions(+), 97 deletions(-) create mode 100644 applications/system/hid_app/assets/Alt_pressed_17x10.png create mode 100644 applications/system/hid_app/assets/Backspace_9x7.png create mode 100644 applications/system/hid_app/assets/Cmd_pressed_17x10.png create mode 100644 applications/system/hid_app/assets/Ctrl_pressed_17x10.png create mode 100644 applications/system/hid_app/assets/Return_10x7.png create mode 100644 applications/system/hid_app/assets/Shift_pressed_7x10.png diff --git a/applications/system/hid_app/assets/Alt_pressed_17x10.png b/applications/system/hid_app/assets/Alt_pressed_17x10.png new file mode 100644 index 0000000000000000000000000000000000000000..e7421c8c0bf7d189200b2b953219f24b287f093d GIT binary patch literal 4227 zcmeHKYitx%6rSawWdYGr&_JS_sX(R7&dl!4?9QZHEZsg<9VoCswK4JT%-wcmU(QUs z+m@h$ii!~mY7_ybJbVI*f%pOy9~GlPFvK6cOf%D;wK(7YC*nbWCrscG>BKq{k_D??BJotWF9o|^bwv3t^{`l<5ldrUW`Od1=(%)N83kO@BZx^Z+ z+!w94e)ViidQ#`ARnPxEyY$GKr^jD7^~A(S_!4eZ`?~Fik8U}(_3)-y7Y=-I;?Bp% z+TVWlp+yCf_u-C*%ZoQe&ODP`yXf;6#QY1L&x{)P zTkDQ96L#IUiF~W_##MOPI_6Y9H(}qg{E_V)c-^l3moD$0Q@H2w$4#$AhECl*|Ge<-!p~oww{P5!KTcV+a&z6q0ecoUjQ+;vc0r1z)ljWb zE8QW=iI@{9i7(Oijz#0TnD&zvt_ZTJrb&loV$AiEwU9F92@N|uPLGqJ zD$;6`i!8M}N;D-R&InXyAz1!k!R{obyjMYEf%DicI4uj)AETtFpb8G%r`q z!=#{IjU_EFAiI~Pp+>sN>J^(gV{NBrAmEx)W4 zRu$0_ImI18OxQZjt>jsL;*n|RbrwTYcQuv4$ z@f4$k70Tm94CP}LFNNH^hvRr3gWcgC5YsdjvJypmMrA@N02TJ|ir`Z?N=B^DgkmYg zARmQUA>#HSA*^^<3rdm2%7hj}aGYuk)nhstueT;l!o{+hpr3R(nQl!@6d4h4@RN6_ z@y2xbL`aR{nFcc1WW5aMcC(zD=Y3wE&(&=-8*4gbqKRphNo&SD77;cB#3D0K0l?D3 zUc_<@BO{@O5{amv%oW(&v;@~lK?VvS0|RKT6%oaXt^vUV*MBB1Q^nxU3#{1g;=Gtsf&t zk#$hF^o}LffX!0?!YGENSnf)~=N|CU7&_8yHe$uf8$fxr5tJ&f?zD{pQotnI&C+@Y>R0&g5F|NZwt4bO0C;te6_uH07QJe*x!(u95%% literal 0 HcmV?d00001 diff --git a/applications/system/hid_app/assets/Backspace_9x7.png b/applications/system/hid_app/assets/Backspace_9x7.png new file mode 100644 index 0000000000000000000000000000000000000000..e098cf676167cdd78687b61cc1b61caf6e6b5666 GIT binary patch literal 6628 zcmeHMc|4TuyB~xo$(E!trcGs5W426|8Cy)&Y$0Rj8Rlh{W=4i=A!IwGP05m?<>ysV zwrG)5vP&tI)EkjhRHEfPGqk+t^qzD2e9rH`p84E!U(bDC*Y~;Z?|ohO=ea)5F2{}5 zD$0wLArOd)tqs)~?3KW#C?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6cS$uKD{36v$nNElSAA_^kI zJiu363Qqt)u?Q>z1-BHlw_#xGm7yjACX3`uwVHtd@5rz~k%&)1B11z%5urv1o*)2; zCK8EA6b6aGz(EbTFpMjri{V`1G6}>q1{Dx81Z=*D&ErBPm~?+$h=>e>f%DL>{&Dy; z+BbNvaE1kt52TpRN1_oZB!`3i(LyM)+y;WoIP_Bsp=%f)Ksp0LUWkAJSZ)KjqGf-F za0b4w>Hh!$s{aju$@t~~KSU5L<%7vU0>JuNB084=d^Kl-=0!&xk20FK4c8E_&C zhlU$5jOh$4hJf;?Gk<_^5U{~erU(Db6Hp(ECISRF3q{1iv1k+krxUP7aFjoWiDek! zh(t6)3dLlQtat(r9gG1shaLbR`P=~MgoI?0xuY!^hC!gdk2nU?MJ&*O46|o*L&V=F zT-hAJMMRe{h{mIgu_!bekH%vN7=qDvB{x7I1jAQ?DXj&iGm@(o7=J8PiJ;(zgNAn+0M`PcZ`N z+yDSPa%MvG>p1%-p+Lmpv2-R23r7(#bT}4IWWfEgL_8dWGp4ir0TzKspQiO2x{${b zh0+Cpc>u^G$Q76p(ux~uAl<0dQqI0uG#gYkyO{a3<}GYdva4w|nkHbMS( zPG)GL0s=O;U@HNSBc($q0+XD?{Kp(YTmFwZ0x~AC{~0sWIfkbGqrKF16RG1roS5Kx zrpLgO7(CdK-%j?Ky#$&0cV06w^6z{E6#Dxizr^ovx_;C3OAP#y^6%*SP1i3m@Jq_S zqwD{TF6HmFA;1OS&O*V;4|}Ix0jwGo9PM2#zeGt2NJVq|60no;x3i`~lH`|2zHBJ* zZ9Ih#$Q%txlYtz}StwBy+0rZ(2W93fLyaQB(j?zY7TQwHU1#56WbphP1N~n8;TI^A dWp+M74uVaT*A7y@Xaed$Y%MoZ|FrOn{ZATUCJF!m literal 0 HcmV?d00001 diff --git a/applications/system/hid_app/assets/Cmd_pressed_17x10.png b/applications/system/hid_app/assets/Cmd_pressed_17x10.png new file mode 100644 index 0000000000000000000000000000000000000000..274c3e070ae42bccbb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4CQMP*(W!CL4CnzEp%1;D{Yj8?)m zi3bzqN(fERM4e5>L336s!`ZEjgJ+z{m<_y%D5gRt>X=5EG~D%L5nwYwtf=QH02q4M zi{OqSQH#XNBaxtsNEg`jv=6S6ENY@h)DVECOKy2<$t|F*0-X$Bhx0{bB~bTY*81ha z3&9?ayi`$P{W?RHyipU-E6GuE7*vd_gyY7g5JV}t1y!s?vJod>C8wlnF0uV;h49Rf+B#cUJn9^%T>y8Vle{oW17_=!e;Fr`v@q$`NrHf&T zGl=(5eo|-gD3`$T&P6)JZzo-ybajY<4jFf5S0`N^VxU9Do!Rxj(Pe({I)%dUFDMQ# zOF3ld3cPAP=6}A#gWcDk4|lCw0-B!D(#a}@^~%zl30tx12~hUXyuRWdmrVWo^)9Gb z`qyz#m3loz<@wEx3-+2ZJi}di#{bR4m1}XD=la~3z(RV!Z literal 0 HcmV?d00001 diff --git a/applications/system/hid_app/assets/Ctrl_pressed_17x10.png b/applications/system/hid_app/assets/Ctrl_pressed_17x10.png new file mode 100644 index 0000000000000000000000000000000000000000..978a1090c2ee9f38e07c66adc5f4a3250885a048 GIT binary patch literal 4227 zcmeHKd2AF_7@y@V3xrq-8ZbCc15{vku06+HuylK@vampbk{aXe%-eS8UhYi0+m=)m z5k#XLLZq~)r2?YdsX;kKlp`ACihpngL5@g7Ih8>0o7wHsDv4<#|8*yC-}k=veZTj; z-}~OTJ8${M7xpy{GGZ9k*Hh%41pQ;sj2T_v`_vHPCUl!oi6`LkjKDHr&3ARtZK+827fKAbf%w28BV56zl+n&BA>&e(Z|<2f5f9c$hO5xgen<@uCJg=29~ zex8+aSgj#@f-hYp*&^)ta_u%lVdrwa@+V zK}}-RrN+kPx2KLi`|*-tcP_s(;!Ug5GN7q>$C;lupKCd@e#)JbyDm(hKiIf+?HhBm zytX;}=H!iB6}Y}Mx^mHcQ?Cy*;+JE&X9t(Q=eQeGj+~va{AN+2+sT`IPM@dVz2_hL z$!B}6#b(anSKmFkug>FjavZtIyS@8tTI}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gDfpks) z03JEBTlC8~>nB@*KqvYESd0oH9$t+D& zfX@O0w%~Kw5;_DzFv&^Gf6fu?|Cl2nV`BTCF*BQEn18gFxNa-zE=G2qZbYpSWs+}n%=zGr+-(5K|}Ou?U?r6D?F W(tV}+OFw`b5Nq>|)W6JpWB(JHjv}J~ literal 0 HcmV?d00001 diff --git a/applications/system/hid_app/views/hid_keyboard.c b/applications/system/hid_app/views/hid_keyboard.c index 9060c1d6a..1ee2c01c9 100644 --- a/applications/system/hid_app/views/hid_keyboard.c +++ b/applications/system/hid_app/views/hid_keyboard.c @@ -20,19 +20,18 @@ typedef struct { uint8_t x; uint8_t y; uint8_t last_key_code; - uint16_t modifier_code; bool ok_pressed; bool back_pressed; bool connected; - char key_string[5]; HidTransport transport; } HidKeyboardModel; typedef struct { uint8_t width; - char* key; + char key; + char shift_key; const Icon* icon; - char* shift_key; + const Icon* icon_toggled; uint8_t value; } HidKeyboardKey; @@ -66,85 +65,97 @@ const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = { {.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}, - {.width = 1, .icon = NULL, .key = "3", .shift_key = "#", .value = HID_KEYBOARD_3}, - {.width = 1, .icon = NULL, .key = "4", .shift_key = "$", .value = HID_KEYBOARD_4}, - {.width = 1, .icon = NULL, .key = "5", .shift_key = "%", .value = HID_KEYBOARD_5}, - {.width = 1, .icon = NULL, .key = "6", .shift_key = "^", .value = HID_KEYBOARD_6}, - {.width = 1, .icon = NULL, .key = "7", .shift_key = "&", .value = HID_KEYBOARD_7}, - {.width = 1, .icon = NULL, .key = "8", .shift_key = "*", .value = HID_KEYBOARD_8}, - {.width = 1, .icon = NULL, .key = "9", .shift_key = "(", .value = HID_KEYBOARD_9}, - {.width = 1, .icon = NULL, .key = "0", .shift_key = ")", .value = HID_KEYBOARD_0}, - {.width = 2, .icon = &I_Pin_arrow_left_9x7, .value = HID_KEYBOARD_DELETE}, + {.width = 1, .icon = NULL, .key = '1', .shift_key = '!', .value = HID_KEYBOARD_1}, + {.width = 1, .icon = NULL, .key = '2', .shift_key = '@', .value = HID_KEYBOARD_2}, + {.width = 1, .icon = NULL, .key = '3', .shift_key = '#', .value = HID_KEYBOARD_3}, + {.width = 1, .icon = NULL, .key = '4', .shift_key = '$', .value = HID_KEYBOARD_4}, + {.width = 1, .icon = NULL, .key = '5', .shift_key = '%', .value = HID_KEYBOARD_5}, + {.width = 1, .icon = NULL, .key = '6', .shift_key = '^', .value = HID_KEYBOARD_6}, + {.width = 1, .icon = NULL, .key = '7', .shift_key = '&', .value = HID_KEYBOARD_7}, + {.width = 1, .icon = NULL, .key = '8', .shift_key = '*', .value = HID_KEYBOARD_8}, + {.width = 1, .icon = NULL, .key = '9', .shift_key = '(', .value = HID_KEYBOARD_9}, + {.width = 1, .icon = NULL, .key = '0', .shift_key = ')', .value = HID_KEYBOARD_0}, + {.width = 2, .icon = &I_Backspace_9x7, .value = HID_KEYBOARD_DELETE}, {.width = 0, .value = HID_KEYBOARD_DELETE}, }, { - {.width = 1, .icon = NULL, .key = "q", .shift_key = "Q", .value = HID_KEYBOARD_Q}, - {.width = 1, .icon = NULL, .key = "w", .shift_key = "W", .value = HID_KEYBOARD_W}, - {.width = 1, .icon = NULL, .key = "e", .shift_key = "E", .value = HID_KEYBOARD_E}, - {.width = 1, .icon = NULL, .key = "r", .shift_key = "R", .value = HID_KEYBOARD_R}, - {.width = 1, .icon = NULL, .key = "t", .shift_key = "T", .value = HID_KEYBOARD_T}, - {.width = 1, .icon = NULL, .key = "y", .shift_key = "Y", .value = HID_KEYBOARD_Y}, - {.width = 1, .icon = NULL, .key = "u", .shift_key = "U", .value = HID_KEYBOARD_U}, - {.width = 1, .icon = NULL, .key = "i", .shift_key = "I", .value = HID_KEYBOARD_I}, - {.width = 1, .icon = NULL, .key = "o", .shift_key = "O", .value = HID_KEYBOARD_O}, - {.width = 1, .icon = NULL, .key = "p", .shift_key = "P", .value = HID_KEYBOARD_P}, - {.width = 1, .icon = NULL, .key = "[", .shift_key = "{", .value = HID_KEYBOARD_OPEN_BRACKET}, + {.width = 1, .icon = NULL, .key = 'q', .shift_key = 'Q', .value = HID_KEYBOARD_Q}, + {.width = 1, .icon = NULL, .key = 'w', .shift_key = 'W', .value = HID_KEYBOARD_W}, + {.width = 1, .icon = NULL, .key = 'e', .shift_key = 'E', .value = HID_KEYBOARD_E}, + {.width = 1, .icon = NULL, .key = 'r', .shift_key = 'R', .value = HID_KEYBOARD_R}, + {.width = 1, .icon = NULL, .key = 't', .shift_key = 'T', .value = HID_KEYBOARD_T}, + {.width = 1, .icon = NULL, .key = 'y', .shift_key = 'Y', .value = HID_KEYBOARD_Y}, + {.width = 1, .icon = NULL, .key = 'u', .shift_key = 'U', .value = HID_KEYBOARD_U}, + {.width = 1, .icon = NULL, .key = 'i', .shift_key = 'I', .value = HID_KEYBOARD_I}, + {.width = 1, .icon = NULL, .key = 'o', .shift_key = 'O', .value = HID_KEYBOARD_O}, + {.width = 1, .icon = NULL, .key = 'p', .shift_key = 'P', .value = HID_KEYBOARD_P}, + {.width = 1, .icon = NULL, .key = '[', .shift_key = '{', .value = HID_KEYBOARD_OPEN_BRACKET}, {.width = 1, .icon = NULL, - .key = "]", - .shift_key = "}", + .key = ']', + .shift_key = '}', .value = HID_KEYBOARD_CLOSE_BRACKET}, }, { - {.width = 1, .icon = NULL, .key = "a", .shift_key = "A", .value = HID_KEYBOARD_A}, - {.width = 1, .icon = NULL, .key = "s", .shift_key = "S", .value = HID_KEYBOARD_S}, - {.width = 1, .icon = NULL, .key = "d", .shift_key = "D", .value = HID_KEYBOARD_D}, - {.width = 1, .icon = NULL, .key = "f", .shift_key = "F", .value = HID_KEYBOARD_F}, - {.width = 1, .icon = NULL, .key = "g", .shift_key = "G", .value = HID_KEYBOARD_G}, - {.width = 1, .icon = NULL, .key = "h", .shift_key = "H", .value = HID_KEYBOARD_H}, - {.width = 1, .icon = NULL, .key = "j", .shift_key = "J", .value = HID_KEYBOARD_J}, - {.width = 1, .icon = NULL, .key = "k", .shift_key = "K", .value = HID_KEYBOARD_K}, - {.width = 1, .icon = NULL, .key = "l", .shift_key = "L", .value = HID_KEYBOARD_L}, - {.width = 1, .icon = NULL, .key = ";", .shift_key = ":", .value = HID_KEYBOARD_SEMICOLON}, - {.width = 2, .icon = &I_Pin_arrow_right_9x7, .value = HID_KEYBOARD_RETURN}, + {.width = 1, .icon = NULL, .key = 'a', .shift_key = 'A', .value = HID_KEYBOARD_A}, + {.width = 1, .icon = NULL, .key = 's', .shift_key = 'S', .value = HID_KEYBOARD_S}, + {.width = 1, .icon = NULL, .key = 'd', .shift_key = 'D', .value = HID_KEYBOARD_D}, + {.width = 1, .icon = NULL, .key = 'f', .shift_key = 'F', .value = HID_KEYBOARD_F}, + {.width = 1, .icon = NULL, .key = 'g', .shift_key = 'G', .value = HID_KEYBOARD_G}, + {.width = 1, .icon = NULL, .key = 'h', .shift_key = 'H', .value = HID_KEYBOARD_H}, + {.width = 1, .icon = NULL, .key = 'j', .shift_key = 'J', .value = HID_KEYBOARD_J}, + {.width = 1, .icon = NULL, .key = 'k', .shift_key = 'K', .value = HID_KEYBOARD_K}, + {.width = 1, .icon = NULL, .key = 'l', .shift_key = 'L', .value = HID_KEYBOARD_L}, + {.width = 1, .icon = NULL, .key = ';', .shift_key = ':', .value = HID_KEYBOARD_SEMICOLON}, + {.width = 2, .icon = &I_Return_10x7, .value = HID_KEYBOARD_RETURN}, {.width = 0, .value = HID_KEYBOARD_RETURN}, }, { - {.width = 1, .icon = NULL, .key = "z", .shift_key = "Z", .value = HID_KEYBOARD_Z}, - {.width = 1, .icon = NULL, .key = "x", .shift_key = "X", .value = HID_KEYBOARD_X}, - {.width = 1, .icon = NULL, .key = "c", .shift_key = "C", .value = HID_KEYBOARD_C}, - {.width = 1, .icon = NULL, .key = "v", .shift_key = "V", .value = HID_KEYBOARD_V}, - {.width = 1, .icon = NULL, .key = "b", .shift_key = "B", .value = HID_KEYBOARD_B}, - {.width = 1, .icon = NULL, .key = "n", .shift_key = "N", .value = HID_KEYBOARD_N}, - {.width = 1, .icon = NULL, .key = "m", .shift_key = "M", .value = HID_KEYBOARD_M}, - {.width = 1, .icon = NULL, .key = "/", .shift_key = "?", .value = HID_KEYBOARD_SLASH}, - {.width = 1, .icon = NULL, .key = "\\", .shift_key = "|", .value = HID_KEYBOARD_BACKSLASH}, - {.width = 1, .icon = NULL, .key = "`", .shift_key = "~", .value = HID_KEYBOARD_GRAVE_ACCENT}, + {.width = 1, .icon = NULL, .key = 'z', .shift_key = 'Z', .value = HID_KEYBOARD_Z}, + {.width = 1, .icon = NULL, .key = 'x', .shift_key = 'X', .value = HID_KEYBOARD_X}, + {.width = 1, .icon = NULL, .key = 'c', .shift_key = 'C', .value = HID_KEYBOARD_C}, + {.width = 1, .icon = NULL, .key = 'v', .shift_key = 'V', .value = HID_KEYBOARD_V}, + {.width = 1, .icon = NULL, .key = 'b', .shift_key = 'B', .value = HID_KEYBOARD_B}, + {.width = 1, .icon = NULL, .key = 'n', .shift_key = 'N', .value = HID_KEYBOARD_N}, + {.width = 1, .icon = NULL, .key = 'm', .shift_key = 'M', .value = HID_KEYBOARD_M}, + {.width = 1, .icon = NULL, .key = '/', .shift_key = '?', .value = HID_KEYBOARD_SLASH}, + {.width = 1, .icon = NULL, .key = '\\', .shift_key = '|', .value = HID_KEYBOARD_BACKSLASH}, + {.width = 1, .icon = NULL, .key = '`', .shift_key = '~', .value = HID_KEYBOARD_GRAVE_ACCENT}, {.width = 1, .icon = &I_ButtonUp_7x4, .value = HID_KEYBOARD_UP_ARROW}, - {.width = 1, .icon = NULL, .key = "-", .shift_key = "_", .value = HID_KEYBOARD_MINUS}, + {.width = 1, .icon = NULL, .key = '-', .shift_key = '_', .value = HID_KEYBOARD_MINUS}, }, { - {.width = 1, .icon = &I_Pin_arrow_up_7x9, .value = HID_KEYBOARD_L_SHIFT}, - {.width = 1, .icon = NULL, .key = ",", .shift_key = "<", .value = HID_KEYBOARD_COMMA}, - {.width = 1, .icon = NULL, .key = ".", .shift_key = ">", .value = HID_KEYBOARD_DOT}, - {.width = 4, .icon = NULL, .key = " ", .value = HID_KEYBOARD_SPACEBAR}, + {.width = 1, + .icon = &I_Pin_arrow_up_7x9, + .icon_toggled = &I_Shift_pressed_7x10, + .value = HID_KEYBOARD_L_SHIFT}, + {.width = 1, .icon = NULL, .key = ',', .shift_key = '<', .value = HID_KEYBOARD_COMMA}, + {.width = 1, .icon = NULL, .key = '.', .shift_key = '>', .value = HID_KEYBOARD_DOT}, + {.width = 4, .icon = NULL, .key = ' ', .value = HID_KEYBOARD_SPACEBAR}, {.width = 0, .value = HID_KEYBOARD_SPACEBAR}, {.width = 0, .value = HID_KEYBOARD_SPACEBAR}, {.width = 0, .value = HID_KEYBOARD_SPACEBAR}, - {.width = 1, .icon = NULL, .key = "'", .shift_key = "\"", .value = HID_KEYBOARD_APOSTROPHE}, - {.width = 1, .icon = NULL, .key = "=", .shift_key = "+", .value = HID_KEYBOARD_EQUAL_SIGN}, + {.width = 1, .icon = NULL, .key = '\'', .shift_key = '\"', .value = HID_KEYBOARD_APOSTROPHE}, + {.width = 1, .icon = NULL, .key = '=', .shift_key = '+', .value = HID_KEYBOARD_EQUAL_SIGN}, {.width = 1, .icon = &I_ButtonLeft_4x7, .value = HID_KEYBOARD_LEFT_ARROW}, {.width = 1, .icon = &I_ButtonDown_7x4, .value = HID_KEYBOARD_DOWN_ARROW}, {.width = 1, .icon = &I_ButtonRight_4x7, .value = HID_KEYBOARD_RIGHT_ARROW}, }, { - {.width = 2, .icon = &I_Ctrl_17x10, .value = HID_KEYBOARD_L_CTRL}, + {.width = 2, + .icon = &I_Ctrl_17x10, + .icon_toggled = &I_Ctrl_pressed_17x10, + .value = HID_KEYBOARD_L_CTRL}, {.width = 0, .value = HID_KEYBOARD_L_CTRL}, - {.width = 2, .icon = &I_Alt_17x10, .value = HID_KEYBOARD_L_ALT}, + {.width = 2, + .icon = &I_Alt_17x10, + .icon_toggled = &I_Alt_pressed_17x10, + .value = HID_KEYBOARD_L_ALT}, {.width = 0, .value = HID_KEYBOARD_L_ALT}, - {.width = 2, .icon = &I_Cmd_17x10, .value = HID_KEYBOARD_L_GUI}, + {.width = 2, + .icon = &I_Cmd_17x10, + .icon_toggled = &I_Cmd_pressed_17x10, + .value = HID_KEYBOARD_L_GUI}, {.width = 0, .value = HID_KEYBOARD_L_GUI}, {.width = 2, .icon = &I_Tab_17x10, .value = HID_KEYBOARD_TAB}, {.width = 0, .value = HID_KEYBOARD_TAB}, @@ -155,13 +166,6 @@ const HidKeyboardKey hid_keyboard_keyset[ROW_COUNT][COLUMN_COUNT] = { }, }; -static void hid_keyboard_to_upper(char* str) { - while(*str) { - *str = toupper((unsigned char)*str); - str++; - } -} - static void hid_keyboard_draw_key( Canvas* canvas, HidKeyboardModel* model, @@ -192,28 +196,32 @@ static void hid_keyboard_draw_key( KEY_HEIGHT); } if(key.icon != NULL) { + const Icon* key_icon = key.icon; + if((model->ctrl && key.value == HID_KEYBOARD_L_CTRL) || + (model->alt && key.value == HID_KEYBOARD_L_ALT) || + (model->shift && key.value == HID_KEYBOARD_L_SHIFT) || + (model->gui && key.value == HID_KEYBOARD_L_GUI)) { + if(key.icon_toggled) { + key_icon = key.icon_toggled; + } + } // Draw the icon centered on the button canvas_draw_icon( canvas, - MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 - key.icon->width / 2, - MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 - key.icon->height / 2, - key.icon); + MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 - key_icon->width / 2, + MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2 - key_icon->height / 2, + key_icon); } else { + char key_str[2] = "\0\0"; // If shift is toggled use the shift key when available - strcpy(model->key_string, (model->shift && key.shift_key != 0) ? key.shift_key : key.key); - // Upper case if ctrl or alt was toggled true - if((model->ctrl && key.value == HID_KEYBOARD_L_CTRL) || - (model->alt && key.value == HID_KEYBOARD_L_ALT) || - (model->gui && key.value == HID_KEYBOARD_L_GUI)) { - hid_keyboard_to_upper(model->key_string); - } + key_str[0] = (model->shift && key.shift_key != 0) ? key.shift_key : key.key; canvas_draw_str_aligned( canvas, MARGIN_LEFT + x * (KEY_WIDTH + KEY_PADDING) + keyWidth / 2 + 1, MARGIN_TOP + y * (KEY_HEIGHT + KEY_PADDING) + KEY_HEIGHT / 2, AlignCenter, AlignCenter, - model->key_string); + key_str); } } @@ -244,6 +252,8 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) { initY = model->y - 4; } + elements_scrollbar(canvas, initY, 3); + for(uint8_t y = initY; y < ROW_COUNT; y++) { const HidKeyboardKey* keyboardKeyRow = hid_keyboard_keyset[y]; uint8_t x = 0; @@ -286,6 +296,14 @@ static void hid_keyboard_get_select_key(HidKeyboardModel* model, HidKeyboardPoin 0); // Skip zero width keys, pretend they are one key } +static void hid_keyboard_modifier_set(Hid* hid, uint16_t keycode, bool is_pressed) { + if(is_pressed) { + hid_hal_keyboard_press(hid, keycode); + } else { + hid_hal_keyboard_release(hid, keycode); + } +} + static void hid_keyboard_process(HidKeyboard* hid_keyboard, InputEvent* event) { with_view_model( hid_keyboard->view, @@ -300,35 +318,25 @@ static void hid_keyboard_process(HidKeyboard* hid_keyboard, InputEvent* event) { // Toggle the modifier key when clicked, and click the key if(model->last_key_code == HID_KEYBOARD_L_SHIFT) { model->shift = !model->shift; - if(model->shift) - model->modifier_code |= KEY_MOD_LEFT_SHIFT; - else - model->modifier_code &= ~KEY_MOD_LEFT_SHIFT; + hid_keyboard_modifier_set( + hid_keyboard->hid, KEY_MOD_LEFT_SHIFT, model->shift); } else if(model->last_key_code == HID_KEYBOARD_L_ALT) { model->alt = !model->alt; - if(model->alt) - model->modifier_code |= KEY_MOD_LEFT_ALT; - else - model->modifier_code &= ~KEY_MOD_LEFT_ALT; + hid_keyboard_modifier_set(hid_keyboard->hid, KEY_MOD_LEFT_ALT, model->alt); } else if(model->last_key_code == HID_KEYBOARD_L_CTRL) { model->ctrl = !model->ctrl; - if(model->ctrl) - model->modifier_code |= KEY_MOD_LEFT_CTRL; - else - model->modifier_code &= ~KEY_MOD_LEFT_CTRL; + hid_keyboard_modifier_set( + hid_keyboard->hid, KEY_MOD_LEFT_CTRL, model->ctrl); } else if(model->last_key_code == HID_KEYBOARD_L_GUI) { model->gui = !model->gui; - if(model->gui) - model->modifier_code |= KEY_MOD_LEFT_GUI; - else - model->modifier_code &= ~KEY_MOD_LEFT_GUI; + hid_keyboard_modifier_set(hid_keyboard->hid, KEY_MOD_LEFT_GUI, model->gui); + } else { + hid_hal_keyboard_press(hid_keyboard->hid, model->last_key_code); } - hid_hal_keyboard_press( - hid_keyboard->hid, model->modifier_code | model->last_key_code); + } else if(event->type == InputTypeRelease) { // Release happens after short and long presses - hid_hal_keyboard_release( - hid_keyboard->hid, model->modifier_code | model->last_key_code); + hid_hal_keyboard_release(hid_keyboard->hid, model->last_key_code); model->ok_pressed = false; } } else if(event->key == InputKeyBack) { @@ -364,6 +372,16 @@ static bool hid_keyboard_input_callback(InputEvent* event, void* context) { if(event->type == InputTypeLong && event->key == InputKeyBack) { hid_hal_keyboard_release_all(hid_keyboard->hid); + with_view_model( + hid_keyboard->view, + HidKeyboardModel * model, + { + model->shift = false; + model->alt = false; + model->ctrl = false; + model->gui = false; + }, + true); } else { hid_keyboard_process(hid_keyboard, event); consumed = true;