Skip to content

Display and control your Android device

Preserve original scroll values in mouse event

Romain Vimont9787fe5d261d
diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 635825c9..f7a787d1 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -897,11 +897,11 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
struct sc_mouse_scroll_event evt = {
.position = sc_input_manager_get_position(im, mouse_x, mouse_y),
#if SDL_VERSION_ATLEAST(2, 0, 18)
- .hscroll = CLAMP(event->preciseX, -1.0f, 1.0f),
- .vscroll = CLAMP(event->preciseY, -1.0f, 1.0f),
+ .hscroll = event->preciseX,
+ .vscroll = event->preciseY,
#else
- .hscroll = CLAMP(event->x, -1, 1),
- .vscroll = CLAMP(event->y, -1, 1),
+ .hscroll = event->x,
+ .vscroll = event->y,
#endif
.buttons_state = im->mouse_buttons_state,
};
diff --git a/app/src/mouse_sdk.c b/app/src/mouse_sdk.c
index 7eceffa7..1b05d02b 100644
--- a/app/src/mouse_sdk.c
+++ b/app/src/mouse_sdk.c
@@ -113,8 +113,8 @@ sc_mouse_processor_process_mouse_scroll(struct sc_mouse_processor *mp,
.type = SC_CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT,
.inject_scroll_event = {
.position = event->position,
- .hscroll = event->hscroll,
- .vscroll = event->vscroll,
+ .hscroll = CLAMP(event->hscroll, -1, 1),
+ .vscroll = CLAMP(event->vscroll, -1, 1),
.buttons = convert_mouse_buttons(event->buttons_state),
},
};