summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-23 23:54:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-23 23:54:52 +0200
commitf5e4bbb151282861e3bd5ca7755c9d1a97534e3a (patch)
treec65388012b61298b78f8c5f30a422851012b548d
parent17283c55122234e7cc2dc352262b273d05aecff8 (diff)
a
-rw-r--r--editor/events.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/editor/events.cpp b/editor/events.cpp
index 109a3a39..7bffda19 100644
--- a/editor/events.cpp
+++ b/editor/events.cpp
@@ -2,6 +2,7 @@
#include "main/floormat-main.hpp"
#include "main/floormat-events.hpp"
#include "src/world.hpp"
+#include <Magnum/Platform/Sdl2Application.h>
#include <utility>
#include <Magnum/ImGuiIntegration/Context.hpp>
@@ -73,18 +74,17 @@ bool app::on_mouse_scroll(const mouse_scroll_event& event) noexcept
bool app::on_key_up_down(const floormat::key_event& event, bool is_down) noexcept
{
- enum Modifier : std::underlying_type_t<SDL_Keymod> {
- None = KMOD_NONE,
- Ctrl = KMOD_CTRL,
- Shift = KMOD_SHIFT,
- Alt = KMOD_ALT,
- Super = KMOD_GUI,
- };
- struct {
- accessor(SDL_Keymod, modifiers)
- } e = {};
+ using KeyEvent = Platform::Sdl2Application::KeyEvent;
+ struct Ev final {
+ using Key = KeyEvent::Key;
+ using Modifier = KeyEvent::Modifier;
+ using Modifiers = KeyEvent::Modifiers;
+ accessor(Key, key)
+ accessor(Modifiers, modifiers)
+ } e = {Ev::Key(event.key), Ev::Modifier(event.mods)};
if (!(is_down ? _imgui.handleKeyPressEvent(e) : _imgui.handleKeyReleaseEvent(e)))
{
+ // todo put it into a separate function
const key x = fm_begin(switch (event.key) {
default: return key::COUNT;
case SDLK_w: return key::camera_up;