summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows/input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/windows/input.cpp')
-rw-r--r--src/osd/windows/input.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/osd/windows/input.cpp b/src/osd/windows/input.cpp
index 6a9d534a2f6..0165e4820f0 100644
--- a/src/osd/windows/input.cpp
+++ b/src/osd/windows/input.cpp
@@ -39,7 +39,6 @@
#include "config.h"
#include "winutil.h"
-#include <mutex>
//============================================================
// PARAMETERS
@@ -167,7 +166,7 @@ typedef /*WINUSERAPI*/ BOOL (WINAPI *register_rawinput_devices_ptr)(IN PCRAWINPU
// global states
static bool input_enabled;
-static std::mutex input_lock;
+static osd_lock * input_lock;
static bool input_paused;
static DWORD last_poll;
@@ -470,6 +469,10 @@ static inline INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawma
bool windows_osd_interface::input_init()
{
+ // allocate a lock for input synchronizations, since messages sometimes come from another thread
+ input_lock = osd_lock_alloc();
+ assert_always(input_lock != NULL, "Failed to allocate input_lock");
+
// decode the options
lightgun_shared_axis_mode = downcast<windows_options &>(machine().options()).dual_lightgun();
@@ -509,8 +512,15 @@ void windows_osd_interface::input_resume()
void windows_osd_interface::input_exit()
{
// acquire the lock and turn off input (this ensures everyone is done)
- std::lock_guard<std::mutex> lock(input_lock);
- input_enabled = false;
+ if (input_lock != NULL)
+ {
+ osd_lock_acquire(input_lock);
+ input_enabled = false;
+ osd_lock_release(input_lock);
+
+ // free the lock
+ osd_lock_free(input_lock);
+ }
}
@@ -603,7 +613,7 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y)
}
// take the lock
- std::lock_guard<std::mutex> lock(input_lock);
+ osd_lock_acquire(input_lock);
// set the button state
devinfo->mouse.state.rgbButtons[button] = down ? 0x80 : 0x00;
@@ -622,6 +632,9 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y)
devinfo->mouse.state.lX = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right);
devinfo->mouse.state.lY = normalize_absolute_axis(mousepos.y, client_rect.top, client_rect.bottom);
}
+
+ // release the lock
+ osd_lock_release(input_lock);
return TRUE;
}
@@ -648,7 +661,7 @@ BOOL wininput_handle_raw(HANDLE device)
// if necessary, allocate a temporary buffer and fetch the data
if (size > sizeof(small_buffer))
{
- data = global_alloc_array_nothrow(BYTE, size);
+ data = global_alloc_array(BYTE, size);
if (data == NULL)
return result;
}
@@ -662,16 +675,18 @@ BOOL wininput_handle_raw(HANDLE device)
// handle keyboard input
if (input->header.dwType == RIM_TYPEKEYBOARD)
{
- std::lock_guard<std::mutex> lock(input_lock);
+ osd_lock_acquire(input_lock);
rawinput_keyboard_update(input->header.hDevice, &input->data.keyboard);
+ osd_lock_release(input_lock);
result = TRUE;
}
// handle mouse input
else if (input->header.dwType == RIM_TYPEMOUSE)
{
- std::lock_guard<std::mutex> lock(input_lock);
+ osd_lock_acquire(input_lock);
rawinput_mouse_update(input->header.hDevice, &input->data.mouse);
+ osd_lock_release(input_lock);
result = TRUE;
}
}
@@ -789,11 +804,6 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent
entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT);
break;
- // add a NOT-lalt to write timecode file
- case IPT_UI_TIMECODE: // emu/input.c: input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT)
- entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT);
- break;
-
// lctrl-lalt-F5 to toggle post-processing
case IPT_OSD_4:
entry->configure_osd("POST_PROCESS", "Toggle Post-Processing");
@@ -2191,13 +2201,14 @@ static void rawinput_mouse_poll(device_info *devinfo)
poll_if_necessary(devinfo->machine());
// copy the accumulated raw state to the actual state
- std::lock_guard<std::mutex> lock(input_lock);
+ osd_lock_acquire(input_lock);
devinfo->mouse.state.lX = devinfo->mouse.raw_x;
devinfo->mouse.state.lY = devinfo->mouse.raw_y;
devinfo->mouse.state.lZ = devinfo->mouse.raw_z;
devinfo->mouse.raw_x = 0;
devinfo->mouse.raw_y = 0;
devinfo->mouse.raw_z = 0;
+ osd_lock_release(input_lock);
}