Skip to content

Commit

Permalink
fixed hardware mouse choppiness caused by duplicated events
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Apr 27, 2024
1 parent 3bc573e commit 9a98f2b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/stream/input/session_evmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/stream/input/session_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 7 additions & 6 deletions src/app/stream/input/session_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/app/stream/session_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 9a98f2b

Please sign in to comment.