From 15625ec8d811ed32ae9b5f299514bc070d685135 Mon Sep 17 00:00:00 2001 From: Ningyuan Li Date: Sun, 28 Apr 2024 01:48:46 +0900 Subject: [PATCH] fixed hardware mouse choppiness caused by duplicated events --- src/app/stream/input/session_evmouse.c | 2 +- src/app/stream/input/session_input.h | 2 +- src/app/stream/input/session_mouse.c | 13 +++++++------ src/app/stream/session_events.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/stream/input/session_evmouse.c b/src/app/stream/input/session_evmouse.c index 1e8863484..f5f044a3e 100644 --- a/src/app/stream/input/session_evmouse.c +++ b/src/app/stream/input/session_evmouse.c @@ -83,7 +83,7 @@ static void mouse_listener(const evmouse_event_t *event, void *userdata) { break; } case SDL_MOUSEMOTION: { - stream_input_handle_mmotion(&session->input, &event->motion); + stream_input_handle_mmotion(&session->input, &event->motion, true); break; } case SDL_MOUSEWHEEL: { diff --git a/src/app/stream/input/session_input.h b/src/app/stream/input/session_input.h index d23e46d75..d327bde12 100644 --- a/src/app/stream/input/session_input.h +++ b/src/app/stream/input/session_input.h @@ -67,7 +67,7 @@ void stream_input_handle_ctouchpad(stream_input_t *input, const SDL_ControllerTo void stream_input_handle_cdevice(stream_input_t *input, const SDL_ControllerDeviceEvent *event); -void stream_input_handle_mmotion(stream_input_t *input, const SDL_MouseMotionEvent *event); +void stream_input_handle_mmotion(stream_input_t *input, const SDL_MouseMotionEvent *event, bool hw_mouse); void stream_input_handle_mbutton(stream_input_t *input, const SDL_MouseButtonEvent *event); diff --git a/src/app/stream/input/session_mouse.c b/src/app/stream/input/session_mouse.c index cb80db306..6f3114e87 100644 --- a/src/app/stream/input/session_mouse.c +++ b/src/app/stream/input/session_mouse.c @@ -59,19 +59,20 @@ void stream_input_handle_mwheel(stream_input_t *input, const SDL_MouseWheelEvent } } -void stream_input_handle_mmotion(stream_input_t *input, const SDL_MouseMotionEvent *event) { +void stream_input_handle_mmotion(stream_input_t *input, const SDL_MouseMotionEvent *event, bool hw_mouse) { if (input->view_only) { return; } - if (input->no_sdl_mouse) { - LiSendMouseMoveEvent((short) event->xrel, (short) event->yrel); - return; - } if (event->which == SDL_TOUCH_MOUSEID && LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS) { // Don't send mouse events from touch devices if the host supports pen/touch events return; } - if (app_get_mouse_relative() && event->which != SDL_TOUCH_MOUSEID) { + if (input->no_sdl_mouse) { + if (!hw_mouse) { + return; + } + LiSendMouseMoveEvent((short) event->xrel, (short) event->yrel); + } else if (app_get_mouse_relative() && event->which != SDL_TOUCH_MOUSEID) { LiSendMouseMoveEvent((short) event->xrel, (short) event->yrel); } else { LiSendMousePositionEvent((short) event->x, (short) event->y, (short) input->session->display_width, diff --git a/src/app/stream/session_events.c b/src/app/stream/session_events.c index 9bf51e8d4..c4961f9a0 100644 --- a/src/app/stream/session_events.c +++ b/src/app/stream/session_events.c @@ -37,7 +37,7 @@ bool session_handle_input_event(session_t *session, const SDL_Event *event) { break; } case SDL_MOUSEMOTION: { - stream_input_handle_mmotion(input, &event->motion); + stream_input_handle_mmotion(input, &event->motion, false); break; } case SDL_MOUSEWHEEL: {