This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 75c0e2977417da77c1d6d42745637285d23346ed Author: Jorge Guzman <[email protected]> AuthorDate: Thu Jul 30 15:08:11 2026 -0300 include/nuttx/input: add modifier keycodes to the keyboard codec A keyboard driver that tracks modifier state has no way to report it. Folding the modifier into the character that it produces loses the fact that the key is down, so an application cannot bind an action to Ctrl or Shift, and cannot tell that one is being held. Add the eight modifiers to enum kbd_keycode_e and move LAST_KEYCODE to the new end of the enumeration. Leaving LAST_KEYCODE behind would make kbd_specpress() assert and kbd_decode() reject the new keycodes, since both range check against it. The keycodes are appended, so the values of the existing ones do not change. Signed-off-by: Jorge Guzman <[email protected]> --- include/nuttx/input/kbd_codec.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/include/nuttx/input/kbd_codec.h b/include/nuttx/input/kbd_codec.h index 951e1ee472a..26c3e21c3e4 100644 --- a/include/nuttx/input/kbd_codec.h +++ b/include/nuttx/input/kbd_codec.h @@ -166,11 +166,28 @@ enum kbd_keycode_e KEYCODE_F21, /* Function key 21 */ KEYCODE_F22, /* Function key 22 */ KEYCODE_F23, /* Function key 23 */ - KEYCODE_F24 /* Function key 24 */ + KEYCODE_F24, /* Function key 24 */ + + /* Modifier keys. Drivers that are able to track modifier state (a USB + * HID keyboard, for example) may report these as key press and key + * release events in their own right. That allows an application to bind + * an action to a modifier, or to know that a modifier is being held down, + * which cannot be expressed by folding the modifier into the character + * that it produces. + */ + + KEYCODE_LCTRL, /* Left Ctrl */ + KEYCODE_RCTRL, /* Right Ctrl */ + KEYCODE_LSHIFT, /* Left Shift */ + KEYCODE_RSHIFT, /* Right Shift */ + KEYCODE_LALT, /* Left Alt */ + KEYCODE_RALT, /* Right Alt */ + KEYCODE_LGUI, /* Left GUI (Windows/Command) */ + KEYCODE_RGUI /* Right GUI (Windows/Command) */ }; #define FIRST_KEYCODE KEYCODE_FWDDEL -#define LAST_KEYCODE KEYCODE_F24 +#define LAST_KEYCODE KEYCODE_RGUI /* kbd_decode() return values */
