@@ -256,8 +256,20 @@ void scrollMouse(int x, int y)
256
256
257
257
#elif defined(USE_X11 )
258
258
259
- int ydir = 4 ; /* Button 4 is up, 5 is down. */
260
- int xdir = 6 ;
259
+ /*
260
+ X11 Mouse Button Numbering
261
+ 1 = left button
262
+ 2 = middle button (pressing the scroll wheel)
263
+ 3 = right button
264
+ 4 = turn scroll wheel up
265
+ 5 = turn scroll wheel down
266
+ 6 = push scroll wheel left
267
+ 7 = push scroll wheel right
268
+ 8 = 4th button (aka browser backward button)
269
+ 9 = 5th button (aka browser forward button)
270
+ */
271
+ int ydir = 4 ; // Button 4 is up, 5 is down.
272
+ int xdir = 6 ; // Button 6 is left, 7 is right.
261
273
Display * display = XGetMainDisplay ();
262
274
263
275
if (y < 0 ){
@@ -274,8 +286,8 @@ void scrollMouse(int x, int y)
274
286
XTestFakeButtonEvent (display , xdir , 0 , CurrentTime );
275
287
}
276
288
for (yi = 0 ; yi < abs (y ); yi ++ ) {
277
- YTestFakeButtonEvent (display , ydir , 1 , CurrentTime );
278
- YTestFakeButtonEvent (display , ydir , 0 , CurrentTime );
289
+ XTestFakeButtonEvent (display , ydir , 1 , CurrentTime );
290
+ XTestFakeButtonEvent (display , ydir , 0 , CurrentTime );
279
291
}
280
292
281
293
XFlush (display );
@@ -285,18 +297,18 @@ void scrollMouse(int x, int y)
285
297
mouseScrollInputH .type = INPUT_MOUSE ;
286
298
mouseScrollInputH .mi .dx = 0 ;
287
299
mouseScrollInputH .mi .dy = 0 ;
288
- mouseScrollInputH .mi .dwFlags = MOUSEEVENTF_WHEEL ;
300
+ mouseScrollInputH .mi .dwFlags = MOUSEEVENTF_HWHEEL ;
289
301
mouseScrollInputH .mi .time = 0 ;
290
302
mouseScrollInputH .mi .dwExtraInfo = 0 ;
291
- mouseScrollInputH .mi .mouseData = WHEEL_DELTA * x ;
303
+ mouseScrollInputH .mi .mouseData = x ;
292
304
293
305
mouseScrollInputV .type = INPUT_MOUSE ;
294
306
mouseScrollInputV .mi .dx = 0 ;
295
307
mouseScrollInputV .mi .dy = 0 ;
296
- mouseScrollInputV .mi .dwFlags = MOUSEEVENTF_HWHEEL ;
308
+ mouseScrollInputV .mi .dwFlags = MOUSEEVENTF_WHEEL ;
297
309
mouseScrollInputV .mi .time = 0 ;
298
310
mouseScrollInputV .mi .dwExtraInfo = 0 ;
299
- mouseScrollInputV .mi .mouseData = WHEEL_DELTA * y ;
311
+ mouseScrollInputV .mi .mouseData = y ;
300
312
301
313
SendInput (1 , & mouseScrollInputH , sizeof (mouseScrollInputH ));
302
314
SendInput (1 , & mouseScrollInputV , sizeof (mouseScrollInputV ));
0 commit comments