--- xmouse.c 2005-03-15 11:37:18.000000000 -0700 +++ /home/trent/allegro-4.2.1/src/x/xmouse.c 2006-12-13 09:53:46.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,10 @@ */ static void _xwin_mousedrv_exit(void) { + if (mouse_mult >= 0) + XChangePointerControl(_xwin.display, 1, 1, mouse_mult, + mouse_div, mouse_threshold); + XLOCK(); _xwin_mouse_interrupt = 0; @@ -190,10 +196,24 @@ /* _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) + XGetPointerControl(_xwin.display, &mouse_mult, &mouse_div, &mouse_threshold); + + speed = MAX(1, (xspeed + yspeed) / 2); + + if (mouse_div == 0) + hundredths = mouse_mult * 100; + else + hundredths = (mouse_mult * 100 / mouse_div); + hundredths -= (speed-2) * 50; + + XChangePointerControl(_xwin.display, 1, 1, hundredths, + 100, mouse_threshold); }