[AD] set_mouse_speed for X

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I have attached a small patch that makes set_mouse_speed work in X. It depends on the "xset" utility, and won't do anything if you don't have it or if your X mouse driver doesn't support changing the acceleration. I'm not sure this is the best way to do it, but it works for me. I have also attached a small test program.

Attachment: diff
Description: Binary data

#include <allegro.h>

int callback(void* dp3, int dp2)
{
	int speed = 9 - (dp2 / 10);
	set_mouse_speed(speed, speed);
	return D_O_K;
}

DIALOG the_dialog[] =
{
   /* (dialog proc)     (x)   (y)   (w)   (h) (fg)(bg) (key) (flags)     (d1) (d2)    (dp)                   (dp2) (dp3) */
   { d_clear_proc,        0,   0,    0,    0,   0,  0,    0,      0,       0,   0,    NULL,                   NULL, NULL  },
   { d_slider_proc,     270, 240,  100,   12,   0,  0,    0,      0,     100,  20,    NULL,                   callback, NULL  },
   { NULL,                0,   0,    0,    0,   0,  0,    0,      0,       0,   0,    NULL,                   NULL, NULL  }
};

int main(void)
{
	allegro_init();
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	install_keyboard();
	install_mouse();

	set_dialog_color(the_dialog, makecol(0, 0, 0), makecol(255, 255, 255));
	do_dialog(the_dialog, 1);

	return 0;
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/