From 65d7278f53560da118695e451f063e71199e271b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 8 Jul 2011 03:55:37 +0200 Subject: [PATCH] Added a bunch of butchered SDL headers, catching SDL events on linux. --- library/CMakeLists.txt | 4 +- library/Core.cpp | 11 + library/{Core-linux.cpp => FakeSDL-linux.cpp} | 43 ++- .../{Core-windows.cpp => FakeSDL-windows.cpp} | 0 library/include/dfhack/Core.h | 2 + library/include/dfhack/FakeSDL.h | 11 +- library/include/dfhack/SDL_fakes/events.h | 207 +++++++++++ library/include/dfhack/SDL_fakes/keyboard.h | 61 ++++ library/include/dfhack/SDL_fakes/keysym.h | 326 ++++++++++++++++++ 9 files changed, 635 insertions(+), 30 deletions(-) rename library/{Core-linux.cpp => FakeSDL-linux.cpp} (86%) rename library/{Core-windows.cpp => FakeSDL-windows.cpp} (100%) create mode 100644 library/include/dfhack/SDL_fakes/events.h create mode 100644 library/include/dfhack/SDL_fakes/keyboard.h create mode 100644 library/include/dfhack/SDL_fakes/keysym.h diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 268855f79..3a5b4a4b7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -82,13 +82,13 @@ SET(PROJECT_HDRS_WINDOWS ) SET(PROJECT_SRCS_LINUX -Core-linux.cpp +FakeSDL-linux.cpp Console-linux.cpp Process-linux.cpp ) SET(PROJECT_SRCS_WINDOWS -Core-windows.cpp +FakeSDL-windows.cpp Console-windows.cpp Process-windows.cpp ) diff --git a/library/Core.cpp b/library/Core.cpp index a52c91dec..b67c207c2 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -233,6 +233,17 @@ int Core::Shutdown ( void ) return -1; } +void Core::SDL_Event(FakeSDL::Event* event) +{ + if(!event) + return; + if(event->type == FakeSDL::ET_KEYDOWN) + { + FakeSDL::KeyboardEvent * kev = (FakeSDL::KeyboardEvent *) event; + cerr << "Key " << kev->ksym.sym << std::endl; + } +} + /******************************************************************************* M O D U L E S *******************************************************************************/ diff --git a/library/Core-linux.cpp b/library/FakeSDL-linux.cpp similarity index 86% rename from library/Core-linux.cpp rename to library/FakeSDL-linux.cpp index f09940f4e..cef9557c3 100644 --- a/library/Core-linux.cpp +++ b/library/FakeSDL-linux.cpp @@ -76,6 +76,7 @@ bool inited = false; DFhackCExport int SDL_NumJoysticks(void) { + inited = true; DFHack::Core & c = DFHack::Core::getInstance(); return c.Update(); } @@ -142,24 +143,6 @@ DFhackCExport void SDL_DestroyMutex(DFMutex * mutex) _SDL_DestroyMutex(mutex); } -static void * (*_SDL_LoadFunction)(DFLibrary *handle, const char *name) = 0; -DFhackCExport void * SDL_LoadFunction(DFLibrary *handle, const char *name) -{ - return _SDL_LoadFunction(handle, name); -} - -static DFLibrary * (*_SDL_LoadObject)(const char *sofile) = 0; -DFhackCExport DFLibrary * SDL_LoadObject(const char *sofile) -{ - return _SDL_LoadObject(sofile); -} - -static void (*_SDL_UnloadObject)(DFLibrary * handle) = 0; -DFhackCExport void SDL_UnloadObject(DFLibrary * handle) -{ - _SDL_UnloadObject(handle); -} - // hook - called at program exit DFhackCExport void SDL_Quit(void) { @@ -171,6 +154,23 @@ DFhackCExport void SDL_Quit(void) } } +// called by DF to check input events +static int (*_SDL_PollEvent)(FakeSDL::Event* event) = 0; +DFhackCExport int SDL_PollEvent(FakeSDL::Event* event) +{ + int ret = _SDL_PollEvent(event); + // only send events to Core after we get first SDL_NumJoysticks call + // DF event loop is possibly polling for SDL events before things get inited properly + // SDL handles it. We don't, because we use some other parts of SDL too. + if(inited && event != 0) + { + DFHack::Core & c = DFHack::Core::getInstance(); + c.SDL_Event(event); + } + return ret; +} + + // hook - called at program start, initialize some stuffs we'll use later DFhackCExport int SDL_Init(uint32_t flags) { @@ -186,9 +186,7 @@ DFhackCExport int SDL_Init(uint32_t flags) _SDL_DestroyMutex = (void (*)(DFMutex*))dlsym(RTLD_NEXT,"SDL_DestroyMutex"); _SDL_mutexP = (int (*)(DFMutex*))dlsym(RTLD_NEXT,"SDL_mutexP"); _SDL_mutexV = (int (*)(DFMutex*))dlsym(RTLD_NEXT,"SDL_mutexV"); - _SDL_LoadFunction = (void*(*)(DFLibrary*, const char*))dlsym(RTLD_NEXT,"SDL_LoadFunction"); - _SDL_LoadObject = (DFLibrary*(*)(const char*))dlsym(RTLD_NEXT,"SDL_LoadObject"); - _SDL_UnloadObject = (void (*)(DFLibrary*))dlsym(RTLD_NEXT,"SDL_UnloadObject"); + _SDL_PollEvent = (int (*)(FakeSDL::Event*))dlsym(RTLD_NEXT,"SDL_PollEvent"); // check if we got them if(_SDL_Init && _SDL_Quit && _SDL_CreateThread && _SDL_CreateMutex && _SDL_DestroyMutex && _SDL_mutexP && _SDL_mutexV) @@ -201,5 +199,6 @@ DFhackCExport int SDL_Init(uint32_t flags) fprintf(stderr,"dfhack: something went horribly wrong\n"); exit(1); } - return _SDL_Init(flags); + int ret = _SDL_Init(flags); + return ret; } diff --git a/library/Core-windows.cpp b/library/FakeSDL-windows.cpp similarity index 100% rename from library/Core-windows.cpp rename to library/FakeSDL-windows.cpp diff --git a/library/include/dfhack/Core.h b/library/include/dfhack/Core.h index 9327cec3d..cdc192193 100644 --- a/library/include/dfhack/Core.h +++ b/library/include/dfhack/Core.h @@ -65,6 +65,7 @@ namespace DFHack { friend int ::SDL_NumJoysticks(void); friend void ::SDL_Quit(void); + friend int ::SDL_PollEvent(FakeSDL::Event *); public: /// Get the single Core instance or make one. static Core& getInstance() @@ -110,6 +111,7 @@ namespace DFHack Core(); int Update (void); int Shutdown (void); + void SDL_Event(FakeSDL::Event* event); Core(Core const&); // Don't Implement void operator=(Core const&); // Don't implement bool errorstate; diff --git a/library/include/dfhack/FakeSDL.h b/library/include/dfhack/FakeSDL.h index f4969991e..5ca3662d4 100644 --- a/library/include/dfhack/FakeSDL.h +++ b/library/include/dfhack/FakeSDL.h @@ -31,6 +31,10 @@ distribution. #include "dfhack/Pragma.h" #include "dfhack/Export.h" #include +#include +#include "dfhack/SDL_fakes/events.h" +#include "dfhack/SDL_fakes/keyboard.h" +#include "dfhack/SDL_fakes/keysym.h" // function and variable pointer... we don't try to understand what SDL does here typedef void * fPtr; @@ -46,19 +50,14 @@ DFhackCExport int SDL_mutexV(DFMutex *); DFhackCExport void SDL_DestroyMutex(DFMutex *); DFhackCExport DFThread *SDL_CreateThread(int (*fn)(void *), void *data); -//FIXME: remove, these fail -DFhackCExport void * SDL_LoadFunction(DFLibrary *handle, const char *name); -DFhackCExport DFLibrary * SDL_LoadObject(const char *sofile); -DFhackCExport void SDL_UnloadObject(DFLibrary * handle); - // these functions are here because they call into DFHack::Core and therefore need to // be declared as friend functions/known DFhackCExport int SDL_NumJoysticks(void); DFhackCExport void SDL_Quit(void); +DFhackCExport int SDL_PollEvent(FakeSDL::Event* event); /* // not yet. DFhackCExport int SDL_Init(uint32_t flags); -DFhackCExport int SDL_PollEvent(vPtr event); */ // Other crud is in the OS-specific core files. diff --git a/library/include/dfhack/SDL_fakes/events.h b/library/include/dfhack/SDL_fakes/events.h new file mode 100644 index 000000000..33a337ed2 --- /dev/null +++ b/library/include/dfhack/SDL_fakes/events.h @@ -0,0 +1,207 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#pragma once +#include "keyboard.h" + +namespace FakeSDL +{ + enum ButtonState + { + BTN_RELEASED = 0, + BTN_PRESSED = 1 + }; + + /** Event enumerations */ + enum EventType + { + ET_NOEVENT = 0, /**< Unused (do not remove) */ + ET_ACTIVEEVENT, /**< Application loses/gains visibility */ + ET_KEYDOWN, /**< Keys pressed */ + ET_KEYUP, /**< Keys released */ + ET_MOUSEMOTION, /**< Mouse moved */ + ET_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + ET_MOUSEBUTTONUP, /**< Mouse button released */ + ET_JOYAXISMOTION, /**< Joystick axis motion */ + ET_JOYBALLMOTION, /**< Joystick trackball motion */ + ET_JOYHATMOTION, /**< Joystick hat position change */ + ET_JOYBUTTONDOWN, /**< Joystick button pressed */ + ET_JOYBUTTONUP, /**< Joystick button released */ + ET_QUIT, /**< User-requested quit */ + ET_SYSWMEVENT, /**< System specific event */ + ET_EVENT_RESERVEDA, /**< Reserved for future use.. */ + ET_EVENT_RESERVEDB, /**< Reserved for future use.. */ + ET_VIDEORESIZE, /**< User resized video mode */ + ET_VIDEOEXPOSE, /**< Screen needs to be redrawn */ + ET_EVENT_RESERVED2, /**< Reserved for future use.. */ + ET_EVENT_RESERVED3, /**< Reserved for future use.. */ + ET_EVENT_RESERVED4, /**< Reserved for future use.. */ + ET_EVENT_RESERVED5, /**< Reserved for future use.. */ + ET_EVENT_RESERVED6, /**< Reserved for future use.. */ + ET_EVENT_RESERVED7, /**< Reserved for future use.. */ + /** Events ET_USEREVENT through ET_MAXEVENTS-1 are for your use */ + ET_USEREVENT = 24, + /** This last event is only for bounding internal arrays + * It is the number of bits in the event mask datatype -- Uint32 + */ + ET_NUMEVENTS = 32 + }; + + /** Application visibility event structure */ + struct ActiveEvent + { + uint8_t type; /**< ET_ACTIVEEVENT */ + uint8_t gain; /**< Whether given states were gained or lost (1/0) */ + uint8_t state; /**< A mask of the focus states */ + }; + + /** Keyboard event structure */ + struct KeyboardEvent + { + uint8_t type; /**< ET_KEYDOWN or ET_KEYUP */ + uint8_t which; /**< The keyboard device index */ + uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ + keysym ksym; + }; + + /** Mouse motion event structure */ + struct MouseMotionEvent + { + uint8_t type; /**< ET_MOUSEMOTION */ + uint8_t which; /**< The mouse device index */ + uint8_t state; /**< The current button state */ + uint16_t x, y; /**< The X/Y coordinates of the mouse */ + int16_t xrel; /**< The relative motion in the X direction */ + int16_t yrel; /**< The relative motion in the Y direction */ + }; + + /** Mouse button event structure */ + struct MouseButtonEvent + { + uint8_t type; /**< ET_MOUSEBUTTONDOWN or ET_MOUSEBUTTONUP */ + uint8_t which; /**< The mouse device index */ + uint8_t button; /**< The mouse button index */ + uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ + uint16_t x, y; /**< The X/Y coordinates of the mouse at press time */ + }; + + /** Joystick axis motion event structure */ + struct JoyAxisEvent + { + uint8_t type; /**< ET_JOYAXISMOTION */ + uint8_t which; /**< The joystick device index */ + uint8_t axis; /**< The joystick axis index */ + int16_t value; /**< The axis value (range: -32768 to 32767) */ + }; + + /** Joystick trackball motion event structure */ + struct JoyBallEvent + { + uint8_t type; /**< ET_JOYBALLMOTION */ + uint8_t which; /**< The joystick device index */ + uint8_t ball; /**< The joystick trackball index */ + int16_t xrel; /**< The relative motion in the X direction */ + int16_t yrel; /**< The relative motion in the Y direction */ + }; + + /** Joystick hat position change event structure */ + struct JoyHatEvent + { + uint8_t type; /**< ET_JOYHATMOTION */ + uint8_t which; /**< The joystick device index */ + uint8_t hat; /**< The joystick hat index */ + uint8_t value; /**< The hat position value: + * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + * Note that zero means the POV is centered. + */ + }; + + /** Joystick button event structure */ + struct JoyButtonEvent + { + uint8_t type; /**< ET_JOYBUTTONDOWN or ET_JOYBUTTONUP */ + uint8_t which; /**< The joystick device index */ + uint8_t button; /**< The joystick button index */ + uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ + }; + + /** The "window resized" event + * When you get this event, you are responsible for setting a new video + * mode with the new width and height. + */ + struct ResizeEvent + { + uint8_t type; /**< ET_VIDEORESIZE */ + int w; /**< New width */ + int h; /**< New height */ + }; + + /** The "screen redraw" event */ + struct ExposeEvent + { + uint8_t type; /**< ET_VIDEOEXPOSE */ + }; + + /** The "quit requested" event */ + struct QuitEvent + { + uint8_t type; /**< ET_QUIT */ + }; + + /** A user-defined event type */ + struct UserEvent + { + uint8_t type; /**< ETL_USEREVENT through ET_NUMEVENTS-1 */ + int code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ + }; + + /** If you want to use this event, you should include SDL_syswm.h */ + struct SysWMmsg; + struct SysWMEvent + { + uint8_t type; + SysWMmsg *msg; + }; + + /** General event structure */ + union Event + { + uint8_t type; + ActiveEvent active; + KeyboardEvent key; + MouseMotionEvent motion; + MouseButtonEvent button; + JoyAxisEvent jaxis; + JoyBallEvent jball; + JoyHatEvent jhat; + JoyButtonEvent jbutton; + ResizeEvent resize; + ExposeEvent expose; + QuitEvent quit; + UserEvent user; + SysWMEvent syswm; + }; +} \ No newline at end of file diff --git a/library/include/dfhack/SDL_fakes/keyboard.h b/library/include/dfhack/SDL_fakes/keyboard.h new file mode 100644 index 000000000..42cb93763 --- /dev/null +++ b/library/include/dfhack/SDL_fakes/keyboard.h @@ -0,0 +1,61 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +// Fake - only structs. Shamelessly pilfered from the SDL library. +// Needed for processing its event types without polluting our namespaces with C garbage + +#pragma once +#include "keysym.h" +#include + +namespace FakeSDL +{ + /** Keysym structure + * + * - The scancode is hardware dependent, and should not be used by general + * applications. If no hardware scancode is available, it will be 0. + * + * - The 'unicode' translated character is only available when character + * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, + * this is a UNICODE character corresponding to the keypress. If the + * high 9 bits of the character are 0, then this maps to the equivalent + * ASCII character: + * @code + * char ch; + * if ( (keysym.unicode & 0xFF80) == 0 ) { + * ch = keysym.unicode & 0x7F; + * } else { + * An international character.. + * } + * @endcode + */ + typedef struct keysym + { + uint8_t scancode; /**< hardware specific scancode */ + Key sym; /**< SDL virtual keysym */ + Mod mod; /**< current key modifiers */ + uint16_t unicode; /**< translated character */ + } keysym; + + /** This is the mask which refers to all hotkey bindings */ + #define ALL_HOTKEYS 0xFFFFFFFF +} \ No newline at end of file diff --git a/library/include/dfhack/SDL_fakes/keysym.h b/library/include/dfhack/SDL_fakes/keysym.h new file mode 100644 index 000000000..013a462c6 --- /dev/null +++ b/library/include/dfhack/SDL_fakes/keysym.h @@ -0,0 +1,326 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#pragma once + +namespace FakeSDL +{ + /** What we really want is a mapping of every raw key on the keyboard. + * To support international keyboards, we use the range 0xA1 - 0xFF + * as international virtual keycodes. We'll follow in the footsteps of X11... + * @brief The names of the keys + */ + enum Key + { + /** @name ASCII mapped keysyms + * The keyboard syms have been cleverly chosen to map to ASCII + */ + /*@{*/ + K_UNKNOWN = 0, + K_FIRST = 0, + K_BACKSPACE = 8, + K_TAB = 9, + K_CLEAR = 12, + K_RETURN = 13, + K_PAUSE = 19, + K_ESCAPE = 27, + K_SPACE = 32, + K_EXCLAIM = 33, + K_QUOTEDBL = 34, + K_HASH = 35, + K_DOLLAR = 36, + K_AMPERSAND = 38, + K_QUOTE = 39, + K_LEFTPAREN = 40, + K_RIGHTPAREN = 41, + K_ASTERISK = 42, + K_PLUS = 43, + K_COMMA = 44, + K_MINUS = 45, + K_PERIOD = 46, + K_SLASH = 47, + K_0 = 48, + K_1 = 49, + K_2 = 50, + K_3 = 51, + K_4 = 52, + K_5 = 53, + K_6 = 54, + K_7 = 55, + K_8 = 56, + K_9 = 57, + K_COLON = 58, + K_SEMICOLON = 59, + K_LESS = 60, + K_EQUALS = 61, + K_GREATER = 62, + K_QUESTION = 63, + K_AT = 64, + /* + Skip uppercase letters + */ + K_LEFTBRACKET = 91, + K_BACKSLASH = 92, + K_RIGHTBRACKET = 93, + K_CARET = 94, + K_UNDERSCORE = 95, + K_BACKQUOTE = 96, + K_a = 97, + K_b = 98, + K_c = 99, + K_d = 100, + K_e = 101, + K_f = 102, + K_g = 103, + K_h = 104, + K_i = 105, + K_j = 106, + K_k = 107, + K_l = 108, + K_m = 109, + K_n = 110, + K_o = 111, + K_p = 112, + K_q = 113, + K_r = 114, + K_s = 115, + K_t = 116, + K_u = 117, + K_v = 118, + K_w = 119, + K_x = 120, + K_y = 121, + K_z = 122, + K_DELETE = 127, + /* End of ASCII mapped keysyms */ + /*@}*/ + + /** @name International keyboard syms */ + /*@{*/ + K_WORLD_0 = 160, /* 0xA0 */ + K_WORLD_1 = 161, + K_WORLD_2 = 162, + K_WORLD_3 = 163, + K_WORLD_4 = 164, + K_WORLD_5 = 165, + K_WORLD_6 = 166, + K_WORLD_7 = 167, + K_WORLD_8 = 168, + K_WORLD_9 = 169, + K_WORLD_10 = 170, + K_WORLD_11 = 171, + K_WORLD_12 = 172, + K_WORLD_13 = 173, + K_WORLD_14 = 174, + K_WORLD_15 = 175, + K_WORLD_16 = 176, + K_WORLD_17 = 177, + K_WORLD_18 = 178, + K_WORLD_19 = 179, + K_WORLD_20 = 180, + K_WORLD_21 = 181, + K_WORLD_22 = 182, + K_WORLD_23 = 183, + K_WORLD_24 = 184, + K_WORLD_25 = 185, + K_WORLD_26 = 186, + K_WORLD_27 = 187, + K_WORLD_28 = 188, + K_WORLD_29 = 189, + K_WORLD_30 = 190, + K_WORLD_31 = 191, + K_WORLD_32 = 192, + K_WORLD_33 = 193, + K_WORLD_34 = 194, + K_WORLD_35 = 195, + K_WORLD_36 = 196, + K_WORLD_37 = 197, + K_WORLD_38 = 198, + K_WORLD_39 = 199, + K_WORLD_40 = 200, + K_WORLD_41 = 201, + K_WORLD_42 = 202, + K_WORLD_43 = 203, + K_WORLD_44 = 204, + K_WORLD_45 = 205, + K_WORLD_46 = 206, + K_WORLD_47 = 207, + K_WORLD_48 = 208, + K_WORLD_49 = 209, + K_WORLD_50 = 210, + K_WORLD_51 = 211, + K_WORLD_52 = 212, + K_WORLD_53 = 213, + K_WORLD_54 = 214, + K_WORLD_55 = 215, + K_WORLD_56 = 216, + K_WORLD_57 = 217, + K_WORLD_58 = 218, + K_WORLD_59 = 219, + K_WORLD_60 = 220, + K_WORLD_61 = 221, + K_WORLD_62 = 222, + K_WORLD_63 = 223, + K_WORLD_64 = 224, + K_WORLD_65 = 225, + K_WORLD_66 = 226, + K_WORLD_67 = 227, + K_WORLD_68 = 228, + K_WORLD_69 = 229, + K_WORLD_70 = 230, + K_WORLD_71 = 231, + K_WORLD_72 = 232, + K_WORLD_73 = 233, + K_WORLD_74 = 234, + K_WORLD_75 = 235, + K_WORLD_76 = 236, + K_WORLD_77 = 237, + K_WORLD_78 = 238, + K_WORLD_79 = 239, + K_WORLD_80 = 240, + K_WORLD_81 = 241, + K_WORLD_82 = 242, + K_WORLD_83 = 243, + K_WORLD_84 = 244, + K_WORLD_85 = 245, + K_WORLD_86 = 246, + K_WORLD_87 = 247, + K_WORLD_88 = 248, + K_WORLD_89 = 249, + K_WORLD_90 = 250, + K_WORLD_91 = 251, + K_WORLD_92 = 252, + K_WORLD_93 = 253, + K_WORLD_94 = 254, + K_WORLD_95 = 255, /* 0xFF */ + /*@}*/ + + /** @name Numeric keypad */ + /*@{*/ + K_KP0 = 256, + K_KP1 = 257, + K_KP2 = 258, + K_KP3 = 259, + K_KP4 = 260, + K_KP5 = 261, + K_KP6 = 262, + K_KP7 = 263, + K_KP8 = 264, + K_KP9 = 265, + K_KP_PERIOD = 266, + K_KP_DIVIDE = 267, + K_KP_MULTIPLY = 268, + K_KP_MINUS = 269, + K_KP_PLUS = 270, + K_KP_ENTER = 271, + K_KP_EQUALS = 272, + /*@}*/ + + /** @name Arrows + Home/End pad */ + /*@{*/ + K_UP = 273, + K_DOWN = 274, + K_RIGHT = 275, + K_LEFT = 276, + K_INSERT = 277, + K_HOME = 278, + K_END = 279, + K_PAGEUP = 280, + K_PAGEDOWN = 281, + /*@}*/ + + /** @name Function keys */ + /*@{*/ + K_F1 = 282, + K_F2 = 283, + K_F3 = 284, + K_F4 = 285, + K_F5 = 286, + K_F6 = 287, + K_F7 = 288, + K_F8 = 289, + K_F9 = 290, + K_F10 = 291, + K_F11 = 292, + K_F12 = 293, + K_F13 = 294, + K_F14 = 295, + K_F15 = 296, + /*@}*/ + + /** @name Key state modifier keys */ + /*@{*/ + K_NUMLOCK = 300, + K_CAPSLOCK = 301, + K_SCROLLOCK = 302, + K_RSHIFT = 303, + K_LSHIFT = 304, + K_RCTRL = 305, + K_LCTRL = 306, + K_RALT = 307, + K_LALT = 308, + K_RMETA = 309, + K_LMETA = 310, + K_LSUPER = 311, /**< Left "Windows" key */ + K_RSUPER = 312, /**< Right "Windows" key */ + K_MODE = 313, /**< "Alt Gr" key */ + K_COMPOSE = 314, /**< Multi-key compose key */ + /*@}*/ + + /** @name Miscellaneous function keys */ + /*@{*/ + K_HELP = 315, + K_PRINT = 316, + K_SYSREQ = 317, + K_BREAK = 318, + K_MENU = 319, + K_POWER = 320, /**< Power Macintosh power key */ + K_EURO = 321, /**< Some european keyboards */ + K_UNDO = 322, /**< Atari keyboard has Undo */ + /*@}*/ + + /* Add any other keys here */ + + K_LAST + }; + + /** Enumeration of valid key mods (possibly OR'd together) */ + enum Mod { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000, + KMOD_CTRL = (KMOD_LCTRL|KMOD_RCTRL), + KMOD_SHIFT = (KMOD_LSHIFT|KMOD_RSHIFT), + KMOD_ALT = (KMOD_LALT|KMOD_RALT), + KMOD_META = (KMOD_LMETA|KMOD_RMETA) + }; +} \ No newline at end of file