Patch for gdk/linux-fb/gdkmouse-fb.c to provide GDK_MOUSE_DEVICE



Hi 

Attached is a tiny patch to allow users to set the mouse 
device file for the linux frame buffer. Useful if you
happen to have a USB mouse or if you want to chose between
/dev/input/{mice,mouse0,etc}

export GDK_MOUSE_TYPE=imps2
export GDK_MOUSE_DEVICE=/dev/input/mice

Patch is against gtk 2.2.3. I am unsure about style - I 
used char, but should I have used gchar ? 

regards

marc

PS: Please CC me, I am not subscribed to the list 
--- /tmp/gdkmouse-fb.c	2003-09-02 13:43:32.000000000 +0200
+++ gdkmouse-fb.c	2003-09-02 16:03:51.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 */
+  char *file;
 
   /* These are written to by parse_packet */
   gdouble x, y;
@@ -253,6 +257,7 @@
 
 struct _GdkFBMouseDevice {
   char *name;
+  char *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;
+  char *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;
   


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]