diff --git a/gen-key-constants.py b/gen-key-constants.py index b484ab913..a19040525 100644 --- a/gen-key-constants.py +++ b/gen-key-constants.py @@ -79,6 +79,17 @@ kp_subtract KP_Subtract - kp_add KP_Add - kp_enter KP_Enter - kp_equal KP_Equal - +kp_separator KP_Separator - +kp_left KP_Left - +kp_right KP_Right - +kp_up KP_Up - +kp_down KP_Down - +kp_page_up KP_Page_Up - +kp_page_down KP_Page_Down - +kp_home KP_Home - +kp_end KP_End - +kp_insert KP_Insert - +kp_delete KP_Delete - left_shift Shift_L - left_control Control_L - left_alt Alt_L - diff --git a/glfw/glfw3.h b/glfw/glfw3.h index a1541d020..c2085c328 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -417,28 +417,39 @@ typedef enum { GLFW_FKEY_KP_ADD = 0xe045, GLFW_FKEY_KP_ENTER = 0xe046, GLFW_FKEY_KP_EQUAL = 0xe047, - GLFW_FKEY_LEFT_SHIFT = 0xe048, - GLFW_FKEY_LEFT_CONTROL = 0xe049, - GLFW_FKEY_LEFT_ALT = 0xe04a, - GLFW_FKEY_LEFT_SUPER = 0xe04b, - GLFW_FKEY_RIGHT_SHIFT = 0xe04c, - GLFW_FKEY_RIGHT_CONTROL = 0xe04d, - GLFW_FKEY_RIGHT_ALT = 0xe04e, - GLFW_FKEY_RIGHT_SUPER = 0xe04f, - GLFW_FKEY_MEDIA_PLAY = 0xe050, - GLFW_FKEY_MEDIA_PAUSE = 0xe051, - GLFW_FKEY_MEDIA_PLAY_PAUSE = 0xe052, - GLFW_FKEY_MEDIA_REVERSE = 0xe053, - GLFW_FKEY_MEDIA_STOP = 0xe054, - GLFW_FKEY_MEDIA_FAST_FORWARD = 0xe055, - GLFW_FKEY_MEDIA_REWIND = 0xe056, - GLFW_FKEY_MEDIA_TRACK_NEXT = 0xe057, - GLFW_FKEY_MEDIA_TRACK_PREVIOUS = 0xe058, - GLFW_FKEY_MEDIA_RECORD = 0xe059, - GLFW_FKEY_LOWER_VOLUME = 0xe05a, - GLFW_FKEY_RAISE_VOLUME = 0xe05b, - GLFW_FKEY_MUTE_VOLUME = 0xe05c, - GLFW_FKEY_LAST = 0xe05c + GLFW_FKEY_KP_SEPARATOR = 0xe048, + GLFW_FKEY_KP_LEFT = 0xe049, + GLFW_FKEY_KP_RIGHT = 0xe04a, + GLFW_FKEY_KP_UP = 0xe04b, + GLFW_FKEY_KP_DOWN = 0xe04c, + GLFW_FKEY_KP_PAGE_UP = 0xe04d, + GLFW_FKEY_KP_PAGE_DOWN = 0xe04e, + GLFW_FKEY_KP_HOME = 0xe04f, + GLFW_FKEY_KP_END = 0xe050, + GLFW_FKEY_KP_INSERT = 0xe051, + GLFW_FKEY_KP_DELETE = 0xe052, + GLFW_FKEY_LEFT_SHIFT = 0xe053, + GLFW_FKEY_LEFT_CONTROL = 0xe054, + GLFW_FKEY_LEFT_ALT = 0xe055, + GLFW_FKEY_LEFT_SUPER = 0xe056, + GLFW_FKEY_RIGHT_SHIFT = 0xe057, + GLFW_FKEY_RIGHT_CONTROL = 0xe058, + GLFW_FKEY_RIGHT_ALT = 0xe059, + GLFW_FKEY_RIGHT_SUPER = 0xe05a, + GLFW_FKEY_MEDIA_PLAY = 0xe05b, + GLFW_FKEY_MEDIA_PAUSE = 0xe05c, + GLFW_FKEY_MEDIA_PLAY_PAUSE = 0xe05d, + GLFW_FKEY_MEDIA_REVERSE = 0xe05e, + GLFW_FKEY_MEDIA_STOP = 0xe05f, + GLFW_FKEY_MEDIA_FAST_FORWARD = 0xe060, + GLFW_FKEY_MEDIA_REWIND = 0xe061, + GLFW_FKEY_MEDIA_TRACK_NEXT = 0xe062, + GLFW_FKEY_MEDIA_TRACK_PREVIOUS = 0xe063, + GLFW_FKEY_MEDIA_RECORD = 0xe064, + GLFW_FKEY_LOWER_VOLUME = 0xe065, + GLFW_FKEY_RAISE_VOLUME = 0xe066, + GLFW_FKEY_MUTE_VOLUME = 0xe067, + GLFW_FKEY_LAST = 0xe067 } GLFWFunctionKey; /* end functional key names */ diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c index 5ccbafaa2..9cfd17c1a 100644 --- a/glfw/xkb_glfw.c +++ b/glfw/xkb_glfw.c @@ -109,6 +109,17 @@ glfw_key_for_sym(xkb_keysym_t key) { case XKB_KEY_KP_Add: return GLFW_FKEY_KP_ADD; case XKB_KEY_KP_Enter: return GLFW_FKEY_KP_ENTER; case XKB_KEY_KP_Equal: return GLFW_FKEY_KP_EQUAL; + case XKB_KEY_KP_Separator: return GLFW_FKEY_KP_SEPARATOR; + case XKB_KEY_KP_Left: return GLFW_FKEY_KP_LEFT; + case XKB_KEY_KP_Right: return GLFW_FKEY_KP_RIGHT; + case XKB_KEY_KP_Up: return GLFW_FKEY_KP_UP; + case XKB_KEY_KP_Down: return GLFW_FKEY_KP_DOWN; + case XKB_KEY_KP_Page_Up: return GLFW_FKEY_KP_PAGE_UP; + case XKB_KEY_KP_Page_Down: return GLFW_FKEY_KP_PAGE_DOWN; + case XKB_KEY_KP_Home: return GLFW_FKEY_KP_HOME; + case XKB_KEY_KP_End: return GLFW_FKEY_KP_END; + case XKB_KEY_KP_Insert: return GLFW_FKEY_KP_INSERT; + case XKB_KEY_KP_Delete: return GLFW_FKEY_KP_DELETE; case XKB_KEY_Shift_L: return GLFW_FKEY_LEFT_SHIFT; case XKB_KEY_Control_L: return GLFW_FKEY_LEFT_CONTROL; case XKB_KEY_Alt_L: return GLFW_FKEY_LEFT_ALT; @@ -210,6 +221,17 @@ glfw_xkb_sym_for_key(uint32_t key) { case GLFW_FKEY_KP_ADD: return XKB_KEY_KP_Add; case GLFW_FKEY_KP_ENTER: return XKB_KEY_KP_Enter; case GLFW_FKEY_KP_EQUAL: return XKB_KEY_KP_Equal; + case GLFW_FKEY_KP_SEPARATOR: return XKB_KEY_KP_Separator; + case GLFW_FKEY_KP_LEFT: return XKB_KEY_KP_Left; + case GLFW_FKEY_KP_RIGHT: return XKB_KEY_KP_Right; + case GLFW_FKEY_KP_UP: return XKB_KEY_KP_Up; + case GLFW_FKEY_KP_DOWN: return XKB_KEY_KP_Down; + case GLFW_FKEY_KP_PAGE_UP: return XKB_KEY_KP_Page_Up; + case GLFW_FKEY_KP_PAGE_DOWN: return XKB_KEY_KP_Page_Down; + case GLFW_FKEY_KP_HOME: return XKB_KEY_KP_Home; + case GLFW_FKEY_KP_END: return XKB_KEY_KP_End; + case GLFW_FKEY_KP_INSERT: return XKB_KEY_KP_Insert; + case GLFW_FKEY_KP_DELETE: return XKB_KEY_KP_Delete; case GLFW_FKEY_LEFT_SHIFT: return XKB_KEY_Shift_L; case GLFW_FKEY_LEFT_CONTROL: return XKB_KEY_Control_L; case GLFW_FKEY_LEFT_ALT: return XKB_KEY_Alt_L; diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 8a9267e2e..aaaf5e308 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -38,31 +38,6 @@ #define GLFW_VERSION_REVISION 0 /*! @} */ -/*! @name Key and button actions - * @{ */ -/*! @brief The key or mouse button was released. - * - * The key or mouse button was released. - * - * @ingroup input - */ -#define GLFW_RELEASE 0 -/*! @brief The key or mouse button was pressed. - * - * The key or mouse button was pressed. - * - * @ingroup input - */ -#define GLFW_PRESS 1 -/*! @brief The key was held down until it repeated. - * - * The key was held down until it repeated. - * - * @ingroup input - */ -#define GLFW_REPEAT 2 -/*! @} */ - /*! @defgroup hat_state Joystick hat states * @brief Joystick hat states. * @@ -105,6 +80,117 @@ * @{ */ +/* start functional key names (auto generated by gen-key-constants.py do not edit) */ +typedef enum { + GLFW_FKEY_FIRST = 0xe000, + GLFW_FKEY_ESCAPE = 0xe000, + GLFW_FKEY_ENTER = 0xe001, + GLFW_FKEY_TAB = 0xe002, + GLFW_FKEY_BACKSPACE = 0xe003, + GLFW_FKEY_INSERT = 0xe004, + GLFW_FKEY_DELETE = 0xe005, + GLFW_FKEY_LEFT = 0xe006, + GLFW_FKEY_RIGHT = 0xe007, + GLFW_FKEY_UP = 0xe008, + GLFW_FKEY_DOWN = 0xe009, + GLFW_FKEY_PAGE_UP = 0xe00a, + GLFW_FKEY_PAGE_DOWN = 0xe00b, + GLFW_FKEY_HOME = 0xe00c, + GLFW_FKEY_END = 0xe00d, + GLFW_FKEY_CAPS_LOCK = 0xe00e, + GLFW_FKEY_SCROLL_LOCK = 0xe00f, + GLFW_FKEY_NUM_LOCK = 0xe010, + GLFW_FKEY_PRINT_SCREEN = 0xe011, + GLFW_FKEY_PAUSE = 0xe012, + GLFW_FKEY_MENU = 0xe013, + GLFW_FKEY_F1 = 0xe014, + GLFW_FKEY_F2 = 0xe015, + GLFW_FKEY_F3 = 0xe016, + GLFW_FKEY_F4 = 0xe017, + GLFW_FKEY_F5 = 0xe018, + GLFW_FKEY_F6 = 0xe019, + GLFW_FKEY_F7 = 0xe01a, + GLFW_FKEY_F8 = 0xe01b, + GLFW_FKEY_F9 = 0xe01c, + GLFW_FKEY_F10 = 0xe01d, + GLFW_FKEY_F11 = 0xe01e, + GLFW_FKEY_F12 = 0xe01f, + GLFW_FKEY_F13 = 0xe020, + GLFW_FKEY_F14 = 0xe021, + GLFW_FKEY_F15 = 0xe022, + GLFW_FKEY_F16 = 0xe023, + GLFW_FKEY_F17 = 0xe024, + GLFW_FKEY_F18 = 0xe025, + GLFW_FKEY_F19 = 0xe026, + GLFW_FKEY_F20 = 0xe027, + GLFW_FKEY_F21 = 0xe028, + GLFW_FKEY_F22 = 0xe029, + GLFW_FKEY_F23 = 0xe02a, + GLFW_FKEY_F24 = 0xe02b, + GLFW_FKEY_F25 = 0xe02c, + GLFW_FKEY_F26 = 0xe02d, + GLFW_FKEY_F27 = 0xe02e, + GLFW_FKEY_F28 = 0xe02f, + GLFW_FKEY_F29 = 0xe030, + GLFW_FKEY_F30 = 0xe031, + GLFW_FKEY_F31 = 0xe032, + GLFW_FKEY_F32 = 0xe033, + GLFW_FKEY_F33 = 0xe034, + GLFW_FKEY_F34 = 0xe035, + GLFW_FKEY_F35 = 0xe036, + GLFW_FKEY_KP_0 = 0xe037, + GLFW_FKEY_KP_1 = 0xe038, + GLFW_FKEY_KP_2 = 0xe039, + GLFW_FKEY_KP_3 = 0xe03a, + GLFW_FKEY_KP_4 = 0xe03b, + GLFW_FKEY_KP_5 = 0xe03c, + GLFW_FKEY_KP_6 = 0xe03d, + GLFW_FKEY_KP_7 = 0xe03e, + GLFW_FKEY_KP_8 = 0xe03f, + GLFW_FKEY_KP_9 = 0xe040, + GLFW_FKEY_KP_DECIMAL = 0xe041, + GLFW_FKEY_KP_DIVIDE = 0xe042, + GLFW_FKEY_KP_MULTIPLY = 0xe043, + GLFW_FKEY_KP_SUBTRACT = 0xe044, + GLFW_FKEY_KP_ADD = 0xe045, + GLFW_FKEY_KP_ENTER = 0xe046, + GLFW_FKEY_KP_EQUAL = 0xe047, + GLFW_FKEY_KP_SEPARATOR = 0xe048, + GLFW_FKEY_KP_LEFT = 0xe049, + GLFW_FKEY_KP_RIGHT = 0xe04a, + GLFW_FKEY_KP_UP = 0xe04b, + GLFW_FKEY_KP_DOWN = 0xe04c, + GLFW_FKEY_KP_PAGE_UP = 0xe04d, + GLFW_FKEY_KP_PAGE_DOWN = 0xe04e, + GLFW_FKEY_KP_HOME = 0xe04f, + GLFW_FKEY_KP_END = 0xe050, + GLFW_FKEY_KP_INSERT = 0xe051, + GLFW_FKEY_KP_DELETE = 0xe052, + GLFW_FKEY_LEFT_SHIFT = 0xe053, + GLFW_FKEY_LEFT_CONTROL = 0xe054, + GLFW_FKEY_LEFT_ALT = 0xe055, + GLFW_FKEY_LEFT_SUPER = 0xe056, + GLFW_FKEY_RIGHT_SHIFT = 0xe057, + GLFW_FKEY_RIGHT_CONTROL = 0xe058, + GLFW_FKEY_RIGHT_ALT = 0xe059, + GLFW_FKEY_RIGHT_SUPER = 0xe05a, + GLFW_FKEY_MEDIA_PLAY = 0xe05b, + GLFW_FKEY_MEDIA_PAUSE = 0xe05c, + GLFW_FKEY_MEDIA_PLAY_PAUSE = 0xe05d, + GLFW_FKEY_MEDIA_REVERSE = 0xe05e, + GLFW_FKEY_MEDIA_STOP = 0xe05f, + GLFW_FKEY_MEDIA_FAST_FORWARD = 0xe060, + GLFW_FKEY_MEDIA_REWIND = 0xe061, + GLFW_FKEY_MEDIA_TRACK_NEXT = 0xe062, + GLFW_FKEY_MEDIA_TRACK_PREVIOUS = 0xe063, + GLFW_FKEY_MEDIA_RECORD = 0xe064, + GLFW_FKEY_LOWER_VOLUME = 0xe065, + GLFW_FKEY_RAISE_VOLUME = 0xe066, + GLFW_FKEY_MUTE_VOLUME = 0xe067, + GLFW_FKEY_LAST = 0xe067 +} GLFWFunctionKey; +/* end functional key names */ + /* The unknown key */ #define GLFW_KEY_UNKNOWN -1 @@ -1022,17 +1108,22 @@ typedef struct GLFWwindow GLFWwindow; * @ingroup input */ typedef struct GLFWcursor GLFWcursor; +typedef enum { + GLFW_RELEASE = 0, + GLFW_PRESS = 1, + GLFW_REPEAT = 2 +} GLFWKeyAction; typedef struct GLFWkeyevent { // The [keyboard key](@ref keys) that was pressed or released. - int key; + uint32_t key; // The platform-specific identifier of the key. int native_key; // The event action. Either `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. - int action; + GLFWKeyAction action; // Bit field describing which [modifier keys](@ref mods) were held down. int mods; @@ -1399,7 +1490,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int,int); * This is the function pointer type for key callbacks. A keyboard * key callback function has the following signature: * @code - * void function_name(GLFWwindow* window, int key, int native_key, int action, int mods) + * void function_name(GLFWwindow* window, uint32_t key, int native_key, int action, int mods) * @endcode * The semantics of this function are that the key that is interacted with on the * keyboard is reported, and the text, if any generated by the key is reported. @@ -1975,15 +2066,15 @@ typedef int (*glfwRawMouseMotionSupported_func)(void); GFW_EXTERN glfwRawMouseMotionSupported_func glfwRawMouseMotionSupported_impl; #define glfwRawMouseMotionSupported glfwRawMouseMotionSupported_impl -typedef const char* (*glfwGetKeyName_func)(int, int); +typedef const char* (*glfwGetKeyName_func)(uint32_t, int); GFW_EXTERN glfwGetKeyName_func glfwGetKeyName_impl; #define glfwGetKeyName glfwGetKeyName_impl -typedef int (*glfwGetNativeKeyForKey_func)(int); +typedef int (*glfwGetNativeKeyForKey_func)(uint32_t); GFW_EXTERN glfwGetNativeKeyForKey_func glfwGetNativeKeyForKey_impl; #define glfwGetNativeKeyForKey glfwGetNativeKeyForKey_impl -typedef int (*glfwGetKey_func)(GLFWwindow*, int); +typedef GLFWKeyAction (*glfwGetKey_func)(GLFWwindow*, uint32_t); GFW_EXTERN glfwGetKey_func glfwGetKey_impl; #define glfwGetKey glfwGetKey_impl