From 3547203233192288753ab365b40f118b8975c248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 21 Oct 2024 15:14:26 +0200 Subject: [PATCH] Platform: these aren't TODOs, mere notes. Partially reverts 589b3e594db7000e62be6472208746c7aed8d115 -- I got it backwards. It actually makes more sense from a user perspective to have layout-dependent key identifiers, because for for e.g. using Ctrl-Z as the "Undo" shortcut it's the most important what key the user perceives as Z, not where that key is placed on some (again, from the user PoV basically arbitrary) layout. For game-y usage, e.g. the WASD movement, scancodes matter (and appropriate getters will get added), but for 90% of actual user interfaces the local layout is how the keys should be defined. This is consistent with e.g. how Qt does it (and it has scancodes as an additional, completely untyped getter), another data point that's in favor of keycodes is that SDL's SDLK_* defines are far shorter than the corresponding SDL_SCANCODE_* scancodes. --- src/Magnum/Platform/EmscriptenApplication.h | 20 ++++++-------------- src/Magnum/Platform/GlfwApplication.h | 20 ++++++-------------- src/Magnum/Platform/Sdl2Application.h | 20 ++++++-------------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/src/Magnum/Platform/EmscriptenApplication.h b/src/Magnum/Platform/EmscriptenApplication.h index 40d24a4f3..626a0cf23 100644 --- a/src/Magnum/Platform/EmscriptenApplication.h +++ b/src/Magnum/Platform/EmscriptenApplication.h @@ -2369,26 +2369,18 @@ class EmscriptenApplication::KeyEvent: public EmscriptenApplication::InputEvent Minus, /**< Minus */ /** - * Plus - * @todo Impossible to represent via a scancode on US layout - * (Shift + =). The reason this was included is that it was in - * Sdl2App which historically uses layout-dependent keycodes - * instead of scancodes because otherwise Z and Y would be - * swapped on QWERTZ layouts (unlike GLFW and HTML5), which is - * a far worse problem. + * Plus. On the US keyboard layout this may only be representable + * as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **=**. */ Plus, Slash, /**< Slash */ /** - * Percent - * @todo Impossible to represent via a scancode on US layout - * (Shift + 5). The reason this was included is that it was in - * Sdl2App which historically uses layout-dependent keycodes - * instead of scancodes because otherwise Z and Y would be - * swapped on QWERTZ layouts (unlike GLFW and HTML5), which is - * a far worse problem. + * Percent. On the US keyboard layout this may only be + * representable as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **5**. */ Percent, diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index 9e240c25a..bf7089336 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -1933,26 +1933,18 @@ class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { Minus = GLFW_KEY_MINUS, /**< Minus */ /** - * Plus - * @todo Impossible to represent via a scancode on US layout - * (Shift + =). The reason this was included is that it was in - * Sdl2App which historically uses layout-dependent keycodes - * instead of scancodes because otherwise Z and Y would be - * swapped on QWERTZ layouts (unlike GLFW and HTML5), which is - * a far worse problem. + * Plus. On the US keyboard layout this may only be representable + * as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **=**. */ Plus = '+', Slash = GLFW_KEY_SLASH, /**< Slash */ /** - * Percent - * @todo Impossible to represent via a scancode on US layout - * (Shift + 5). The reason this was included is that it was in - * Sdl2App which historically uses layout-dependent keycodes - * instead of scancodes because otherwise Z and Y would be - * swapped on QWERTZ layouts (unlike GLFW and HTML5), which is - * a far worse problem. + * Percent. On the US keyboard layout this may only be + * representable as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **5**. */ Percent = '%', diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index c8636fe3b..645d3928b 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -2602,26 +2602,18 @@ class Sdl2Application::KeyEvent: public Sdl2Application::InputEvent { Minus = SDLK_MINUS, /**< Minus */ /** - * Plus - * @todo Impossible to represent via a scancode on US layout - * (Shift + =). The reason this was included is that Sdl2App - * historically uses layout-dependent keycodes instead of - * scancodes because otherwise Z and Y would be swapped on - * QWERTZ layouts (unlike GLFW and HTML5), which is a far - * worse problem. + * Plus. On the US keyboard layout this may only be representable + * as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **=**. */ Plus = SDLK_PLUS, Slash = SDLK_SLASH, /**< Slash */ /** - * Percent - * @todo Impossible to represent via a scancode on US layout - * (Shift + 5). The reason this was included is that Sdl2App - * historically uses layout-dependent keycodes instead of - * scancodes because otherwise Z and Y would be swapped on - * QWERTZ layouts (unlike GLFW and HTML5), which is a far - * worse problem. + * Percent. On the US keyboard layout this may only be + * representable as @m_class{m-label m-warning} **Shift** + * @m_class{m-label m-default} **5**. */ Percent = SDLK_PERCENT,