diff options
author | 2016-11-17 09:59:29 -0500 | |
---|---|---|
committer | 2016-11-17 09:59:29 -0500 | |
commit | 0fb4fe79f8def330bdf6a9a08c59b211ca4e623c (patch) | |
tree | 21a2a0acb04445863913d0395313c0642a08dc82 /src/osd/modules/input/input_uwp.cpp | |
parent | 3bc03384b1549f3fcd5204725ab5933c4a60a71f (diff) |
UWP: keyboard scancodes start at 1 (nw)
Also thread synchronization which will be needed later when we have multiple windows (nw)
Diffstat (limited to 'src/osd/modules/input/input_uwp.cpp')
-rw-r--r-- | src/osd/modules/input/input_uwp.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/osd/modules/input/input_uwp.cpp b/src/osd/modules/input/input_uwp.cpp index 0c63e53fb1d..5b3cdb76417 100644 --- a/src/osd/modules/input/input_uwp.cpp +++ b/src/osd/modules/input/input_uwp.cpp @@ -215,6 +215,7 @@ private ref class UwpKeyboardDevice : public UwpInputDevice private: keyboard_state keyboard; Platform::Agile<CoreWindow> m_coreWindow; + std::mutex m_state_lock; internal: UwpKeyboardDevice(Platform::Agile<CoreWindow> coreWindow, running_machine& machine, char *name, const char *id, input_module &module) @@ -229,6 +230,7 @@ internal: void Reset() override { + std::lock_guard<std::mutex> scope_lock(m_state_lock); memset(&keyboard, 0, sizeof(keyboard)); } @@ -236,8 +238,8 @@ internal: { keyboard_trans_table &table = keyboard_trans_table::instance(); - // populate it - for (int keynum = 0; keynum < MAX_KEYS; keynum++) + // populate it indexed by the scancode + for (int keynum = KEY_UNKNOWN + 1; keynum < MAX_KEYS; keynum++) { input_item_id itemid = table.map_di_scancode_to_itemid(keynum); const char *keyname = table.ui_label_for_mame_key(itemid); @@ -256,6 +258,7 @@ internal: void OnKeyDown(CoreWindow^ win, KeyEventArgs^ args) { + std::lock_guard<std::mutex> scope_lock(m_state_lock); CorePhysicalKeyStatus status = args->KeyStatus; int discancode = (status.ScanCode & 0x7f) | (status.IsExtendedKey ? 0x80 : 0x00); keyboard.state[discancode] = 0x80; @@ -263,6 +266,7 @@ internal: void OnKeyUp(CoreWindow^ win, KeyEventArgs^ args) { + std::lock_guard<std::mutex> scope_lock(m_state_lock); CorePhysicalKeyStatus status = args->KeyStatus; int discancode = (status.ScanCode & 0x7f) | (status.IsExtendedKey ? 0x80 : 0x00); keyboard.state[discancode] = 0; |