GNOME Bugzilla – Bug 121347
Patch to provide GDK_MOUSE_DEVICE
Last modified: 2013-03-18 04:03:07 UTC
Implements the environment variable GDK_MOUSE_DEVICE which allows a user to select the input device --- /tmp/gdkmouse-fb.c 2003-09-02 13:43:32.000000000 +0200 +++ gdkmouse-fb.c 2003-09-03 10:10:45.000000000 +0200 @@ -15,6 +15,9 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Changes: Tue Sep 2 15:41:57 SAST 2003 Marc Welz + * Added GDK_MOUSE_DEVICE environment variable */ #include <gdk/gdk.h> @@ -36,6 +39,7 @@ struct _GdkFBMouse { gint fd; /* Set by open */ + gchar *file; /* These are written to by parse_packet */ gdouble x, y; @@ -252,7 +256,8 @@ */ struct _GdkFBMouseDevice { - char *name; + gchar *name; + gchar *file; gint packet_size; gboolean (*open)(GdkFBMouse *mouse); void (*close)(GdkFBMouse *mouse); @@ -280,6 +285,7 @@ static GdkFBMouseDevice mouse_devs[] = { { "ps2", + "/dev/psaux", 3, gdk_fb_mouse_ps2_open, gdk_fb_mouse_ps2_close, @@ -287,6 +293,7 @@ { 0xc0, 0x00 } }, { "imps2", + "/dev/psaux", 4, gdk_fb_mouse_imps2_open, gdk_fb_mouse_ps2_close, @@ -294,6 +301,7 @@ { 0xc0, 0x00 } }, { "ms", + "/dev/mouse", 3, gdk_fb_mouse_ms_open, gdk_fb_mouse_ms_close, @@ -301,6 +309,7 @@ { 0x40, 0x40 } }, { "fidmour", + "/dev/fidmour", 5, gdk_fb_mouse_fidmour_open, gdk_fb_mouse_fidmour_close, @@ -312,7 +321,7 @@ gboolean gdk_fb_mouse_init (gboolean open_dev) { - char *mouse_type; + gchar *mouse_type, *mouse_file; int i; gdk_fb_mouse = g_new0 (GdkFBMouse, 1); @@ -336,6 +345,12 @@ gdk_fb_mouse->dev = &mouse_devs[i]; + mouse_file = getenv ("GDK_MOUSE_DEVICE"); + if (!mouse_file) + mouse_file = mouse_devs[i].file; + + gdk_fb_mouse->file = mouse_file; + gdk_fb_mouse->x = gdk_display->fb_width / 2; gdk_fb_mouse->y = gdk_display->fb_height / 2; @@ -476,7 +491,7 @@ guchar buf[7]; int i = 0; - fd = gdk_fb_mouse_dev_open ("/dev/psaux", O_RDWR); + fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR); if (fd < 0) return FALSE; @@ -511,7 +526,7 @@ guchar buf[7]; int i = 0; - fd = gdk_fb_mouse_dev_open ("/dev/psaux", O_RDWR); + fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR); if (fd < 0) return FALSE; @@ -632,10 +647,10 @@ guchar buf[7]; struct termios tty; - fd = gdk_fb_mouse_dev_open ("/dev/mouse", O_RDWR); + fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR); if (fd < 0) { - g_print ("Error opening /dev/mouse: %s\n", strerror (errno)); + g_print ("Error opening %s: %s\n", mouse->file, strerror (errno)); return FALSE; } @@ -741,7 +756,7 @@ { gint fd; - fd = gdk_fb_mouse_dev_open ("/dev/fidmour", O_RDONLY); + fd = gdk_fb_mouse_dev_open (mouse->file, O_RDONLY); if (fd < 0) return FALSE;
Created attachment 19695 [details] [review] PATCH for GDK_MOUSE_DEVICE
Added to HEAD. Thanks.