mirror of
https://github.com/holub/mame
synced 2025-07-07 10:58:41 +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
|
class event_based_device : public device_info
|
||||||
{
|
{
|
||||||
private:
|
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;
|
std::queue<TEvent> m_event_queue;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
m_event_queue.pop();
|
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);
|
std::lock_guard<std::mutex> scope_lock(m_device_lock);
|
||||||
|
|
||||||
@ -128,6 +128,12 @@ public:
|
|||||||
m_event_queue.pop();
|
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
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
rawinput_device::reset();
|
||||||
m_pause_pressed = std::chrono::steady_clock::time_point::min();
|
m_pause_pressed = std::chrono::steady_clock::time_point::min();
|
||||||
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
||||||
m_e1 = 0xffff;
|
m_e1 = 0xffff;
|
||||||
@ -325,7 +326,6 @@ public:
|
|||||||
virtual void poll(bool relative_reset) override
|
virtual void poll(bool relative_reset) override
|
||||||
{
|
{
|
||||||
rawinput_device::poll(relative_reset);
|
rawinput_device::poll(relative_reset);
|
||||||
|
|
||||||
if (m_keyboard.state[0x80 | 0x45] && (std::chrono::steady_clock::now() > (m_pause_pressed + std::chrono::milliseconds(30))))
|
if (m_keyboard.state[0x80 | 0x45] && (std::chrono::steady_clock::now() > (m_pause_pressed + std::chrono::milliseconds(30))))
|
||||||
m_keyboard.state[0x80 | 0x45] = 0x00;
|
m_keyboard.state[0x80 | 0x45] = 0x00;
|
||||||
}
|
}
|
||||||
@ -452,6 +452,7 @@ public:
|
|||||||
|
|
||||||
virtual void reset() override
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
rawinput_device::reset();
|
||||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||||
m_x = m_y = m_v = m_h = 0;
|
m_x = m_y = m_v = m_h = 0;
|
||||||
}
|
}
|
||||||
@ -498,11 +499,9 @@ public:
|
|||||||
|
|
||||||
virtual void process_event(RAWINPUT const &rawinput) override
|
virtual void process_event(RAWINPUT const &rawinput) override
|
||||||
{
|
{
|
||||||
|
|
||||||
// If this data was intended for a rawinput mouse
|
// If this data was intended for a rawinput mouse
|
||||||
if (rawinput.data.mouse.usFlags == MOUSE_MOVE_RELATIVE)
|
if (rawinput.data.mouse.usFlags == MOUSE_MOVE_RELATIVE)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_x += rawinput.data.mouse.lLastX * input_device::RELATIVE_PER_PIXEL;
|
m_x += rawinput.data.mouse.lLastX * input_device::RELATIVE_PER_PIXEL;
|
||||||
m_y += rawinput.data.mouse.lLastY * 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
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
rawinput_device::reset();
|
||||||
memset(&m_lightgun, 0, sizeof(m_lightgun));
|
memset(&m_lightgun, 0, sizeof(m_lightgun));
|
||||||
m_v = 0;
|
m_v = 0;
|
||||||
m_h = 0;
|
m_h = 0;
|
||||||
@ -608,7 +608,6 @@ public:
|
|||||||
// If this data was intended for a rawinput lightgun
|
// If this data was intended for a rawinput lightgun
|
||||||
if (rawinput.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
|
if (rawinput.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
|
||||||
{
|
{
|
||||||
|
|
||||||
// update the X/Y positions
|
// update the X/Y positions
|
||||||
m_lightgun.lX = normalize_absolute_axis(rawinput.data.mouse.lLastX, 0, input_device::ABSOLUTE_MAX);
|
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);
|
m_lightgun.lY = normalize_absolute_axis(rawinput.data.mouse.lLastY, 0, input_device::ABSOLUTE_MAX);
|
||||||
@ -703,9 +702,7 @@ public:
|
|||||||
RAWINPUTDEVICE registration;
|
RAWINPUTDEVICE registration;
|
||||||
registration.usUsagePage = usagepage();
|
registration.usUsagePage = usagepage();
|
||||||
registration.usUsage = usage();
|
registration.usUsage = usage();
|
||||||
registration.dwFlags = RIDEV_DEVNOTIFY;
|
registration.dwFlags = RIDEV_DEVNOTIFY | RIDEV_INPUTSINK;
|
||||||
if (background_input())
|
|
||||||
registration.dwFlags |= RIDEV_INPUTSINK;
|
|
||||||
registration.hwndTarget = dynamic_cast<win_window_info &>(*osd_common_t::window_list().front()).platform_window();
|
registration.hwndTarget = dynamic_cast<win_window_info &>(*osd_common_t::window_list().front()).platform_window();
|
||||||
|
|
||||||
// register the device
|
// register the device
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
virtual void reset() override
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
event_based_device::reset();
|
||||||
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
memset(&m_keyboard, 0, sizeof(m_keyboard));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +220,7 @@ public:
|
|||||||
|
|
||||||
virtual void reset() override
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
event_based_device::reset();
|
||||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||||
memset(&m_win32_mouse, 0, sizeof(m_win32_mouse));
|
memset(&m_win32_mouse, 0, sizeof(m_win32_mouse));
|
||||||
m_vscroll = m_hscroll = 0;
|
m_vscroll = m_hscroll = 0;
|
||||||
@ -303,6 +305,7 @@ class win32_lightgun_device_base : public event_based_device<MouseUpdateEventArg
|
|||||||
public:
|
public:
|
||||||
virtual void reset() override
|
virtual void reset() override
|
||||||
{
|
{
|
||||||
|
event_based_device::reset();
|
||||||
memset(&m_mouse, 0, sizeof(m_mouse));
|
memset(&m_mouse, 0, sizeof(m_mouse));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user