mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Fix for some mice with new raw input for linux, if you move mouse very gently vertically, it is treated as moving horizontally instead
This commit is contained in:
parent
a7a42f1f5d
commit
135b0fedae
14
src/Window.c
14
src/Window.c
@ -1812,15 +1812,23 @@ static cc_bool rawMouseInited, rawMouseSupported;
|
|||||||
static int xiOpcode;
|
static int xiOpcode;
|
||||||
|
|
||||||
static void HandleGenericEvent(XEvent* e) {
|
static void HandleGenericEvent(XEvent* e) {
|
||||||
|
const double* values;
|
||||||
XIRawEvent* ev;
|
XIRawEvent* ev;
|
||||||
|
double dx, dy;
|
||||||
|
|
||||||
if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return;
|
if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return;
|
||||||
if (!XGetEventData(win_display, &e->xcookie)) return;
|
if (!XGetEventData(win_display, &e->xcookie)) return;
|
||||||
|
|
||||||
if (e->xcookie.evtype == XI_RawMotion && Input_RawMode) {
|
if (e->xcookie.evtype == XI_RawMotion && Input_RawMode) {
|
||||||
ev = (XIRawEvent*)e->xcookie.data;
|
ev = (XIRawEvent*)e->xcookie.data;
|
||||||
|
values = ev->raw_values;
|
||||||
|
|
||||||
|
/* Raw motion events may not always have values for both axes */
|
||||||
|
dx = XIMaskIsSet(ev->valuators.mask, 0) ? *values++ : 0;
|
||||||
|
dy = XIMaskIsSet(ev->valuators.mask, 1) ? *values++ : 0;
|
||||||
|
|
||||||
/* Using 0.5f here makes the sensitivity about same as normal cursor movement */
|
/* Using 0.5f here makes the sensitivity about same as normal cursor movement */
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved,
|
Event_RaiseRawMove(&PointerEvents.RawMoved, dx * 0.5f, dy * 0.5f);
|
||||||
ev->raw_values[0] * 0.5f, ev->raw_values[1] * 0.5f);
|
|
||||||
}
|
}
|
||||||
XFreeEventData(win_display, &e->xcookie);
|
XFreeEventData(win_display, &e->xcookie);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user