All pastes #333477 Raw Edit

Untitled

public text v1 · immutable
#333477 ·published 2007-01-30 23:04 UTC
rendered paste body
--- xmouse.c	2005-03-15 11:37:18.000000000 -0700
+++ /home/trent/allegro-4.2.1/src/x/xmouse.c	2007-01-30 15:58:55.000000000 -0700
@@ -40,7 +40,9 @@
 static int mymickey_x = 0;
 static int mymickey_y = 0;
 
-
+static int mouse_mult = -1;       /* mouse acceleration multiplier */
+static int mouse_div = -1;        /* mouse acceleration divisor */
+static int mouse_threshold = -1;  /* mouse acceleration threshold */
 
 static int _xwin_mousedrv_init(void);
 static void _xwin_mousedrv_exit(void);
@@ -132,6 +134,13 @@
  */
 static void _xwin_mousedrv_exit(void)
 {
+   if (mouse_mult >= 0) {
+      XLOCK();
+      XChangePointerControl(_xwin.display, 1, 1, mouse_mult,
+         mouse_div, mouse_threshold);
+      XUNLOCK();
+   }
+
    XLOCK();
 
    _xwin_mouse_interrupt = 0;
@@ -190,10 +199,29 @@
 
 /* _xwin_mousedrv_set_speed:
  *  Sets the speed of the mickey-mode mouse.
+ *  Each step slows down or speeds the mouse up by 0.5x.
  */
 static void _xwin_mousedrv_set_speed(int xspeed, int yspeed)
 {
-   /* Use xset utility with "m" option.  */
+   int speed;
+   int hundredths;
+
+   if (mouse_mult<0) {
+      XLOCK();
+      XGetPointerControl(_xwin.display, &mouse_mult, &mouse_div, &mouse_threshold);
+      XUNLOCK();
+   }
+
+   speed = MAX(1, (xspeed + yspeed) / 2);
+
+   hundredths = (mouse_mult * 100 / mouse_div);
+   hundredths -= (speed-2) * 50;
+   hundredths = MAX(0, hundredths);
+
+   XLOCK();
+   XChangePointerControl(_xwin.display, 1, 1, hundredths,
+      100, mouse_threshold);
+   XUNLOCK();
 }