/* * This file is subject to the terms of the GFX License. If a copy of * the license was not distributed with this file, you can obtain one at: * * http://ugfx.io/license.html */ /** * @file src/ginput/ginput_keyboard.h * * @defgroup Keyboard Keyboard * @ingroup GINPUT * * @brief Sub-Module to handle physical keyboards. * * @{ */ #ifndef _GINPUT_KEYBOARD_H #define _GINPUT_KEYBOARD_H #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD || defined(__DOXYGEN__) /*===========================================================================*/ /* Type definitions */ /*===========================================================================*/ // Event types for various ginput sources #define GEVENT_KEYBOARD (GEVENT_GINPUT_FIRST+2) typedef struct GEventKeyboard_t { GEventType type; // The type of this event (GEVENT_KEYBOARD) gU16 bytecount; // The number of bytes in c[]. Note this will only ever represent 0 or 1 characters. This is set to 0 for state transitions. char c[8]; // The utf8 code for the key or a special key code // Normal characters with special meaning. They are a maximum of 1 byte in length. #define GKEY_NULL 0 #define GKEY_BACKSPACE 8 #define GKEY_TAB 9 #define GKEY_LF 10 #define GKEY_CR 13 #define GKEY_ENTER 13 #define GKEY_ESC 27 #define GKEY_SPACE 32 #define GKEY_DEL 127 // These are special keys - GKEYSTATE_SPECIAL will be set. They are a maximum of 1 byte in length. #define GKEY_UP 0x81 #define GKEY_DOWN 0x82 #define GKEY_LEFT 0x83 #define GKEY_RIGHT 0x84 #define GKEY_HOME 0x85 #define GKEY_END 0x86 #define GKEY_PAGEUP 0x87 #define GKEY_PAGEDOWN 0x88 #define GKEY_INSERT 0x89 #define GKEY_WINKEY 0x8A #define GKEY_RIGHTCLICKKEY 0x8B #define GKEY_FN1 0x91 #define GKEY_FN2 0x92 #define GKEY_FN3 0x93 #define GKEY_FN4 0x94 #define GKEY_FN5 0x95 #define GKEY_FN6 0x96 #define GKEY_FN7 0x97 #define GKEY_FN8 0x98 #define GKEY_FN9 0x99 #define GKEY_FN10 0x9A #define GKEY_FN11 0x9B #define GKEY_FN12 0x9C #define GKEY_FN13 0x9D #define GKEY_FN14 0x9E #define GKEY_FN15 0x9F #define GKEY_CTRLBREAK 0xA0 #define GKEY_CTRLPAUSE 0xA1 #define GKEY_SYSREQ 0xA2 #define GKEY_PRINTSCREEN 0xA3 #define GKEY_POWER 0xA4 #define GKEY_SLEEP 0xA5 #define GKEY_SCREENSWITCH 0xA6 #define GKEY_SCREENLOCK 0xA7 #define GKEY_WIFIONOFF 0xA8 #define GKEY_TRACKPADONOFF 0xA9 #define GKEY_STARTMEDIA 0xAA #define GKEY_STARTHOME 0xAB #define GKEY_STARTEMAIL 0xAC #define GKEY_STARTCOMPUTER 0xAD #define GKEY_STARTAPP1 0xAE #define GKEY_STARTAPP2 0xAF #define GKEY_VOLUP 0xB0 #define GKEY_VOLDOWN 0xB1 #define GKEY_VOLMUTE 0xB2 #define GKEY_EJECT 0xB3 #define GKEY_MEDIAPLAY 0xB4 #define GKEY_MEDIASTOP 0xB5 #define GKEY_MEDIAPAUSE 0xB6 #define GKEY_MEDIAFORWARD 0xB7 #define GKEY_MEDIANEXT 0xB8 #define GKEY_MEDIAREWIND 0xB9 #define GKEY_MEDIAPREV 0xBA #define GKEY_MEDIASLOW 0xBB #define GKEY_LIGHTUP 0xBC #define GKEY_LIGHTDOWN 0xBD #define GKEY_LIGHTONOFF 0xBE #define GKEY_LAYOUT_FIRST 0xC0 // Special characters the layout can return start here. #define GKEY_DRIVER_FIRST 0xE0 // Special characters the driver can return start here. gU32 keystate; // The keyboard state. #define GKEYSTATE_KEYUP_BIT 0 #define GKEYSTATE_REPEAT_BIT 1 #define GKEYSTATE_SPECIAL_BIT 2 #define GKEYSTATE_RAW_BIT 3 #define GKEYSTATE_SHIFT_L_BIT 4 #define GKEYSTATE_SHIFT_R_BIT 5 #define GKEYSTATE_CTRL_L_BIT 6 #define GKEYSTATE_CTRL_R_BIT 7 #define GKEYSTATE_ALT_L_BIT 8 #define GKEYSTATE_ALT_R_BIT 9 #define GKEYSTATE_FN_BIT 10 #define GKEYSTATE_COMPOSE_BIT 11 #define GKEYSTATE_WINKEY_BIT 12 #define GKEYSTATE_CAPSLOCK_BIT 13 #define GKEYSTATE_NUMLOCK_BIT 14 #define GKEYSTATE_SCROLLLOCK_BIT 15 #define GKEYSTATE_LAYOUT_FIRST_BIT 16 #define GKEYSTATE_SYSTEM_FIRST_BIT 20 #define GKEYSTATE_DRIVER_FIRST_BIT 24 #define GKEYSTATE_MISSED_EVENT_BIT 31 #define GKEYSTATE_KEYUP (1<