mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
osd/input_common: increase event queue size,
input_rawinput/win32: empty event queue on resets, input_raw: set RIDEV_INPUTSINK flag because of missed keyup events, causing stuck inputs (MT8789)
This commit is contained in:
parent
692d1f7069
commit
3a817b47da
@ -91,7 +91,7 @@ template <class TEvent>
|
||||
class event_based_device : public device_info
|
||||
{
|
||||
private:
|
||||
static inline constexpr unsigned DEFAULT_EVENT_QUEUE_SIZE = 20;
|
||||
static inline constexpr unsigned DEFAULT_EVENT_QUEUE_SIZE = 64;
|
||||
|
||||
std::queue<TEvent> m_event_queue;
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
m_event_queue.pop();
|
||||
}
|
||||
|
||||
void virtual poll(bool relative_reset) override
|
||||
virtual void poll(bool relative_reset) override
|
||||
{
|
||||
std::lock_guard<std::mutex> scope_lock(m_device_lock);
|
||||
|
||||
@ -128,6 +128,12 @@ public:
|
||||
m_event_queue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
std::lock_guard<std::mutex> scope_lock(m_device_lock);
|
||||
std::queue<TEvent>().swap(m_event_queue);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -317,6 +317,7 @@ public:
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
rawinput_device::reset();
|
||||
m_pause_pressed = std::chrono::steady_clock::time_point::min();
|
||||
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
||||
m_e1 = 0xffff;
|
||||
@ -325,7 +326,6 @@ public:
|
||||
virtual void poll(bool relative_reset) override
|
||||
{
|
||||
rawinput_device::poll(relative_reset);
|
||||
|
||||
if (m_keyboard.state[0x80 | 0x45] && (std::chrono::steady_clock::now() > (m_pause_pressed + std::chrono::milliseconds(30))))
|
||||
m_keyboard.state[0x80 | 0x45] = 0x00;
|
||||
}
|
||||
@ -452,6 +452,7 @@ public:
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
rawinput_device::reset();
|
||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||
m_x = m_y = m_v = m_h = 0;
|
||||
}
|
||||
@ -498,11 +499,9 @@ public:
|
||||
|
||||
virtual void process_event(RAWINPUT const &rawinput) override
|
||||
{
|
||||
|
||||
// If this data was intended for a rawinput mouse
|
||||
if (rawinput.data.mouse.usFlags == MOUSE_MOVE_RELATIVE)
|
||||
{
|
||||
|
||||
m_x += rawinput.data.mouse.lLastX * input_device::RELATIVE_PER_PIXEL;
|
||||
m_y += rawinput.data.mouse.lLastY * input_device::RELATIVE_PER_PIXEL;
|
||||
|
||||
@ -559,6 +558,7 @@ public:
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
rawinput_device::reset();
|
||||
memset(&m_lightgun, 0, sizeof(m_lightgun));
|
||||
m_v = 0;
|
||||
m_h = 0;
|
||||
@ -608,7 +608,6 @@ public:
|
||||
// If this data was intended for a rawinput lightgun
|
||||
if (rawinput.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
|
||||
{
|
||||
|
||||
// update the X/Y positions
|
||||
m_lightgun.lX = normalize_absolute_axis(rawinput.data.mouse.lLastX, 0, input_device::ABSOLUTE_MAX);
|
||||
m_lightgun.lY = normalize_absolute_axis(rawinput.data.mouse.lLastY, 0, input_device::ABSOLUTE_MAX);
|
||||
@ -703,9 +702,7 @@ public:
|
||||
RAWINPUTDEVICE registration;
|
||||
registration.usUsagePage = usagepage();
|
||||
registration.usUsage = usage();
|
||||
registration.dwFlags = RIDEV_DEVNOTIFY;
|
||||
if (background_input())
|
||||
registration.dwFlags |= RIDEV_INPUTSINK;
|
||||
registration.dwFlags = RIDEV_DEVNOTIFY | RIDEV_INPUTSINK;
|
||||
registration.hwndTarget = dynamic_cast<win_window_info &>(*osd_common_t::window_list().front()).platform_window();
|
||||
|
||||
// register the device
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
event_based_device::reset();
|
||||
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
||||
}
|
||||
|
||||
@ -219,6 +220,7 @@ public:
|
||||
|
||||
virtual void reset() override
|
||||
{
|
||||
event_based_device::reset();
|
||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||
memset(&m_win32_mouse, 0, sizeof(m_win32_mouse));
|
||||
m_vscroll = m_hscroll = 0;
|
||||
@ -303,6 +305,7 @@ class win32_lightgun_device_base : public event_based_device<MouseUpdateEventArg
|
||||
public:
|
||||
virtual void reset() override
|
||||
{
|
||||
event_based_device::reset();
|
||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user