Difference between revisions of "GLFW to CEGUI Key and Mouse Mapping"
From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
Map key and mouse button codes from [http://glfw.sourceforge.net GLFW] to CEGUI. | Map key and mouse button codes from [http://glfw.sourceforge.net GLFW] to CEGUI. | ||
− | < | + | <source lang="cpp"> |
unsigned int GlfwToCeguiKey(int glfwKey) | unsigned int GlfwToCeguiKey(int glfwKey) | ||
{ | { | ||
Line 57: | Line 57: | ||
} | } | ||
} | } | ||
− | </ | + | </source> |
+ | |||
+ | |||
+ | For GLFW3 you may find this useful: http://cegui.org.uk/forum/viewtopic.php?p=35297 | ||
[[Category:HowTo]] | [[Category:HowTo]] |
Latest revision as of 18:10, 19 September 2016
Map key and mouse button codes from GLFW to CEGUI.
unsigned int GlfwToCeguiKey(int glfwKey) { switch(glfwKey) { case GLFW_KEY_UNKNOWN : return 0; case GLFW_KEY_ESC : return CEGUI::Key::Escape; case GLFW_KEY_F1 : return CEGUI::Key::F1; case GLFW_KEY_F2 : return CEGUI::Key::F2; case GLFW_KEY_F3 : return CEGUI::Key::F3; case GLFW_KEY_F4 : return CEGUI::Key::F4; case GLFW_KEY_F5 : return CEGUI::Key::F5; case GLFW_KEY_F6 : return CEGUI::Key::F6; case GLFW_KEY_F7 : return CEGUI::Key::F7; case GLFW_KEY_F8 : return CEGUI::Key::F8; case GLFW_KEY_F9 : return CEGUI::Key::F9; case GLFW_KEY_F10 : return CEGUI::Key::F10; case GLFW_KEY_F11 : return CEGUI::Key::F11; case GLFW_KEY_F12 : return CEGUI::Key::F12; case GLFW_KEY_F13 : return CEGUI::Key::F13; case GLFW_KEY_F14 : return CEGUI::Key::F14; case GLFW_KEY_F15 : return CEGUI::Key::F15; case GLFW_KEY_UP : return CEGUI::Key::ArrowUp; case GLFW_KEY_DOWN : return CEGUI::Key::ArrowDown; case GLFW_KEY_LEFT : return CEGUI::Key::ArrowLeft; case GLFW_KEY_RIGHT : return CEGUI::Key::ArrowRight; case GLFW_KEY_LSHIFT : return CEGUI::Key::LeftShift; case GLFW_KEY_RSHIFT : return CEGUI::Key::RightShift; case GLFW_KEY_LCTRL : return CEGUI::Key::LeftControl; case GLFW_KEY_RCTRL : return CEGUI::Key::RightControl; case GLFW_KEY_LALT : return CEGUI::Key::LeftAlt; case GLFW_KEY_RALT : return CEGUI::Key::RightAlt; case GLFW_KEY_TAB : return CEGUI::Key::Tab; case GLFW_KEY_ENTER : return CEGUI::Key::Return; case GLFW_KEY_BACKSPACE : return CEGUI::Key::Backspace; case GLFW_KEY_INSERT : return CEGUI::Key::Insert; case GLFW_KEY_DEL : return CEGUI::Key::Delete; case GLFW_KEY_PAGEUP : return CEGUI::Key::PageUp; case GLFW_KEY_PAGEDOWN : return CEGUI::Key::PageDown; case GLFW_KEY_HOME : return CEGUI::Key::Home; case GLFW_KEY_END : return CEGUI::Key::End; case GLFW_KEY_KP_ENTER : return CEGUI::Key::NumpadEnter; default : return 0; } } CEGUI::MouseButton GlfwToCeguiButton(int glfwButton) { switch(glfwButton) { case GLFW_MOUSE_BUTTON_LEFT : return CEGUI::LeftButton; case GLFW_MOUSE_BUTTON_RIGHT : return CEGUI::RightButton; case GLFW_MOUSE_BUTTON_MIDDLE : return CEGUI::MiddleButton; default : return CEGUI::NoButton; } }
For GLFW3 you may find this useful: http://cegui.org.uk/forum/viewtopic.php?p=35297