summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input
diff options
context:
space:
mode:
author ksherlock <ksherlock@gmail.com>2021-04-28 12:39:39 -0400
committer GitHub <noreply@github.com>2021-04-28 12:39:39 -0400
commit082803db49a6aba819aac4f3f38eb5f0507e9d06 (patch)
tree875d4e3a84af7b7cedebed980f92b08f3e5b5935 /src/osd/modules/input
parentc8b751da56123af70507c5eea91dca51bea5fbc9 (diff)
osx/sdl - handle caps lock key up events via a frame callback instead of the sdl key up event (which is too fast) (#7972)
Diffstat (limited to 'src/osd/modules/input')
-rw-r--r--src/osd/modules/input/input_sdl.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index 102987b3094..5ecab0a479b 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -377,13 +377,33 @@ public:
: sdl_device(machine, name, id, DEVICE_CLASS_KEYBOARD, module),
keyboard({{0}})
{
+ #ifdef __APPLE__
+ m_capslock_hack = false;
+ machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(&sdl_keyboard_device::frame_callback, this));
+ #endif
}
+ #ifdef __APPLE__
+ unsigned m_capslock_hack;
+ void frame_callback()
+ {
+ if (m_capslock_hack)
+ if (--m_capslock_hack == 0)
+ keyboard.state[SDL_SCANCODE_CAPSLOCK] = 0x00;
+ }
+ #endif
+
void process_event(SDL_Event &sdlevent) override
{
switch (sdlevent.type)
{
case SDL_KEYDOWN:
+
+ #ifdef __APPLE__
+ if (sdlevent.key.keysym.scancode == SDL_SCANCODE_CAPSLOCK)
+ m_capslock_hack = 2;
+ #endif
+
keyboard.state[sdlevent.key.keysym.scancode] = 0x80;
if (sdlevent.key.keysym.sym < 0x20)
machine().ui_input().push_char_event(osd_common_t::s_window_list.front()->target(), sdlevent.key.keysym.sym);
@@ -403,6 +423,11 @@ public:
break;
case SDL_KEYUP:
+ #ifdef __APPLE__
+ if (sdlevent.key.keysym.scancode == SDL_SCANCODE_CAPSLOCK)
+ break;
+ #endif
+
keyboard.state[sdlevent.key.keysym.scancode] = 0x00;
break;
@@ -437,6 +462,9 @@ public:
void reset() override
{
memset(&keyboard.state, 0, sizeof(keyboard.state));
+ #ifdef __APPLE__
+ m_capslock_hack = 0;
+ #endif
}
};