From 1e5e4843a98f0bf4b18d2980d8629b2e47338a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 18 Jul 2016 23:50:54 +0200 Subject: [PATCH] Platform: expose also modifier keys in KeyEvent::Key enum. Was done for GLFW but not for SDL2. Also updated the docs to reflect the connection between them. --- src/Magnum/Platform/GlfwApplication.h | 95 +++++++++++++++++++++--- src/Magnum/Platform/Sdl2Application.h | 102 ++++++++++++++++++++++++-- 2 files changed, 180 insertions(+), 17 deletions(-) diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index 543331151..008281d24 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -500,10 +500,33 @@ class GlfwApplication::InputEvent { * @ref MouseEvent::modifiers() */ enum class Modifier: Int { - Shift = GLFW_MOD_SHIFT, /**< Shift */ - Ctrl = GLFW_MOD_CONTROL, /**< Ctrl */ - Alt = GLFW_MOD_ALT, /**< Alt */ - Super = GLFW_MOD_SUPER /**< Super key (Windows/⌘) */ + /** + * Shift + * + * @see @ref KeyEvent::Key::LeftShift, @ref KeyEvent::Key::RightShift + */ + Shift = GLFW_MOD_SHIFT, + + /** + * Ctrl + * + * @see @ref KeyEvent::Key::LeftCtrl, @ref KeyEvent::Key::RightCtrl + */ + Ctrl = GLFW_MOD_CONTROL, + + /** + * Alt + * + * @see @ref KeyEvent::Key::LeftAlt, @ref KeyEvent::Key::RightAlt + */ + Alt = GLFW_MOD_ALT, + + /** + * Super key (Windows/⌘) + * + * @see @ref KeyEvent::Key::LeftSuper, @ref KeyEvent::Key::RightSuper + */ + Super = GLFW_MOD_SUPER }; /** @@ -560,6 +583,62 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { enum class Key: Int { Unknown = GLFW_KEY_UNKNOWN, /**< Unknown key */ + /** + * Left Shift + * + * @see @ref InputEvent::Modifier::Shift + */ + LeftShift = GLFW_KEY_LEFT_SHIFT, + + /** + * Right Shift + * + * @see @ref InputEvent::Modifier::Shift + */ + RightShift = GLFW_KEY_RIGHT_SHIFT, + + /** + * Left Ctrl + * + * @see @ref InputEvent::Modifier::Ctrl + */ + LeftCtrl = GLFW_KEY_LEFT_CONTROL, + + /** + * Right Ctrl + * + * @see @ref InputEvent::Modifier::Ctrl + */ + RightCtrl = GLFW_KEY_RIGHT_CONTROL, + + /** + * Left Alt + * + * @see @ref InputEvent::Modifier::Alt + */ + LeftAlt = GLFW_KEY_LEFT_ALT, + + /** + * Right Alt + * + * @see @ref InputEvent::Modifier::Alt + */ + RightAlt = GLFW_KEY_RIGHT_ALT, + + /** + * Left Super key (Windows/⌘) + * + * @see @ref InputEvent::Modifier::Super + */ + LeftSuper = GLFW_KEY_LEFT_SUPER, + + /** + * Right Super key (Windows/⌘) + * + * @see @ref InputEvent::Modifier::Super + */ + RightSuper = GLFW_KEY_RIGHT_SUPER, + Enter = GLFW_KEY_ENTER, /**< Enter */ Esc = GLFW_KEY_ESCAPE, /**< Escape */ @@ -662,14 +741,6 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { NumAdd = GLFW_KEY_KP_ADD, /**< Numpad add */ NumEnter = GLFW_KEY_KP_ENTER, /**< Numpad enter */ NumEqual = GLFW_KEY_KP_EQUAL, /**< Numpad equal */ - LeftShift = GLFW_KEY_LEFT_SHIFT, /**< Left shift */ - LeftCtrl = GLFW_KEY_LEFT_CONTROL, /**< Left control */ - LeftAlt = GLFW_KEY_LEFT_ALT, /**< Left alt */ - LeftSuper = GLFW_KEY_LEFT_SUPER, /**< Left super */ - RightShift = GLFW_KEY_RIGHT_SHIFT, /**< Right shift */ - RightCtrl = GLFW_KEY_RIGHT_CONTROL, /**< Right control */ - RightAlt = GLFW_KEY_RIGHT_ALT, /**< Right alt */ - RightSuper = GLFW_KEY_RIGHT_SUPER, /**< Right super */ Menu = GLFW_KEY_MENU /**< Menu */ }; diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 9d0f91401..24c1b1d24 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -971,11 +971,40 @@ class Sdl2Application::InputEvent { * @ref MouseEvent::modifiers(), @ref MouseMoveEvent::modifiers() */ enum class Modifier: Uint16 { - Shift = KMOD_SHIFT, /**< Shift */ - Ctrl = KMOD_CTRL, /**< Ctrl */ - Alt = KMOD_ALT, /**< Alt */ - Super = KMOD_GUI, /**< Super key (Windows/⌘) */ - AltGr = KMOD_MODE, /**< AltGr */ + /** + * Shift + * + * @see @ref KeyEvent::Key::LeftShift, @ref KeyEvent::Key::RightShift + */ + Shift = KMOD_SHIFT, + + /** + * Ctrl + * + * @see @ref KeyEvent::Key::LeftCtrl, @ref KeyEvent::Key::RightCtrl + */ + Ctrl = KMOD_CTRL, + + /** + * Alt + * + * @see @ref KeyEvent::Key::LeftAlt, @ref KeyEvent::Key::RightAlt + */ + Alt = KMOD_ALT, + + /** + * Super key (Windows/⌘) + * + * @see @ref KeyEvent::Key::LeftSuper, @ref KeyEvent::Key::RightSuper + */ + Super = KMOD_GUI, + + /** + * AltGr + * + * @see @ref KeyEvent::Key::AltGr + */ + AltGr = KMOD_MODE, CapsLock = KMOD_CAPS, /**< Caps lock */ NumLock = KMOD_NUM /**< Num lock */ @@ -1042,6 +1071,69 @@ class Sdl2Application::KeyEvent: public Sdl2Application::InputEvent { enum class Key: SDL_Keycode { Unknown = SDLK_UNKNOWN, /**< Unknown key */ + /** + * Left Shift + * + * @see @ref InputEvent::Modifier::Shift + */ + LeftShift = SDLK_LSHIFT, + + /** + * Right Shift + * + * @see @ref InputEvent::Modifier::Shift + */ + RightShift = SDLK_RSHIFT, + + /** + * Left Ctrl + * + * @see @ref InputEvent::Modifier::Ctrl + */ + LeftCtrl = SDLK_LCTRL, + + /** + * Right Ctrl + * + * @see @ref InputEvent::Modifier::Ctrl + */ + RightCtrl = SDLK_RCTRL, + + /** + * Left Alt + * + * @see @ref InputEvent::Modifier::Alt + */ + LeftAlt = SDLK_LALT, + + /** + * Right Alt + * + * @see @ref InputEvent::Modifier::Alt + */ + RightAlt = SDLK_RALT, + + /** + * Left Super key (Windows/⌘) + * + * @see @ref InputEvent::Modifier::Super + */ + LeftSuper = SDLK_LGUI, + + /** + * Right Super key (Windows/⌘) + * + * @see @ref InputEvent::Modifier::Super + */ + RightSuper = SDLK_RGUI, + + /** + * AltGr + * + * @see @ref InputEvent::Modifier::AltGr + */ + AltGr = SDLK_MODE, + Enter = SDLK_RETURN, /**< Enter */ Esc = SDLK_ESCAPE, /**< Escape */