]> xenbits.xen.org Git - xenclient/ioemu-pq.git/commitdiff
Fix for serach and replace bugs in new input code
authorroot <root@kiffu-2.uk.xensource.com>
Mon, 3 Aug 2009 13:41:47 +0000 (14:41 +0100)
committerroot <root@kiffu-2.uk.xensource.com>
Mon, 3 Aug 2009 13:41:47 +0000 (14:41 +0100)
master/new-input-code

index 9b172f06992b8f8488f7f6e5ede435c3f7a94245..652d2eb98de8732c4193d69173c4f23dc23f9c58 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/hid-linux.c b/hid-linux.c
-index f2e0bce..8cb3e30 100644
+index f2e0bce..c011dbd 100644
 --- a/hid-linux.c
 +++ b/hid-linux.c
 @@ -43,11 +43,8 @@
@@ -15,7 +15,7 @@ index f2e0bce..8cb3e30 100644
  
  #define DEBUG_HID_LINUX
  
-@@ -64,468 +61,592 @@ while (0);
+@@ -64,468 +61,602 @@ while (0);
  # define DEBUG(_format_, args...) (void)0
  #endif
  
@@ -73,6 +73,11 @@ index f2e0bce..8cb3e30 100644
  };
  
 -static char keycode2ascii(int keycode)
++static int hid_linux_detect_binding (void);
++static void hid_linux_key_inject (int code, uint32_t keycode);
++static char *hid_linux_xs_read (const char *key);
++
++
 +static char
 +keycode2ascii (int keycode)
  {
@@ -233,7 +238,7 @@ index f2e0bce..8cb3e30 100644
 +          DEBUG ("binding payload %d\n",
 +                 (int) (linux_hid_binding[i].payload));
 +          linux_hid_binding[i].cb (linux_hid_binding[i].payload);
-+          linux_hid_reset_keyboard ();
++          hid_linux_reset_keyboard ();
 +          return 1;
 +        }
      }
@@ -342,9 +347,9 @@ index f2e0bce..8cb3e30 100644
 -          return;
 -    hid_linux_key_inject(code, keycode);
 +  if (code == 1)
-+    if (linux_hid_detect_binding ())
++    if (hid_linux_detect_binding ())
 +      return;
-+  linux_hid_key_inject (code, keycode);
++  hid_linux_key_inject (code, keycode);
  }
  
 -static void hid_linux_read(void *opaque)
@@ -502,10 +507,10 @@ index f2e0bce..8cb3e30 100644
 +              double div = 1;
 +              char *str = NULL;
 +
-+              str = linux_hid_xs_read ("touchpad-limit");
++              str = hid_linux_xs_read ("touchpad-limit");
 +              if (str)
 +                l = strtol (str, NULL, 10);
-+              str = linux_hid_xs_read ("touchpad-div");
++              str = hid_linux_xs_read ("touchpad-div");
 +              if (str)
 +                div = strtol (str, NULL, 10) / 1000.;
 +
@@ -557,12 +562,12 @@ index f2e0bce..8cb3e30 100644
 +  for (i = 0; i < 256; i++)
 +    if (linux_hid_driver.key_status[i])
 +      {
-+        linux_hid_key_inject (0, i);
++        hid_linux_key_inject (0, i);
 +        linux_hid_driver.key_status[i] = 0;
 +      }
-+}
-+
-+
+ }
 +static int
 +hid_linux_secure_read (int fd)
 +{
@@ -576,19 +581,20 @@ index f2e0bce..8cb3e30 100644
 +
 +  if (read_sz <= 0)
 +    return -1;
-+
+-static void hid_linux_redirect_fds(int *fd, IOHandler *cb)
 +  for (i = 0; i < read_sz / (sizeof (struct input_event)); i++)
 +    if (event[i].type == EV_KEY && event[i].code < BTN_MOUSE &&
 +        event[i].value > 0)
 +      linux_hid_driver.secure_key (keycode2ascii (event[i].code));
 +
 +  return 0;
- }
--static void hid_linux_redirect_fds(int *fd, IOHandler *cb)
-+static int hid_linux_do_read (void *opaque)
++}
++
++
++
++static int
++hid_linux_do_read (void *opaque)
  {
 -    assert(fd != NULL);
 +  int result;
@@ -611,7 +617,9 @@ index f2e0bce..8cb3e30 100644
 -      fd++;
 +      /* The read failed - stop watching and close the fd */
 +
-+      fprintf(stderr,"read failed on /dev/input/event%d fd=%d dropping it\n",slot,linux_hid_driver.fds[slot]);
++      fprintf (stderr,
++               "read failed on /dev/input/event%d fd=%d dropping it\n", slot,
++               linux_hid_driver.fds[slot]);
 +
 +      qemu_set_fd_handler (linux_hid_driver.fds[slot], NULL, NULL, NULL);
 +      close (linux_hid_driver.fds[slot]);
@@ -813,31 +821,27 @@ index f2e0bce..8cb3e30 100644
 +
 +
 +  if (strcasestr (name, "keyboard"))
-+    {
+     {
+-        if (fd != -1)
+-            close(fd);
 +      fprintf (stderr, "/dev/input/event%d added keyboard on fd %d (%s)\n",
 +               slot, fd, name);
 +      linux_hid_driver.types[slot] = HID_TYPE_KEYBOARD;
-+
+-      sprintf(path, "%s%i", EVENT_PATH, i++);
 +      set_handler (slot, linux_hid_driver.keyboard_grabbed);
-+
+-      if (i>=HID_LINUX_MAX_DEV_NO)
+-              break;
 +    }
 +  else
-     {
--        if (fd != -1)
--            close(fd);
++    {
 +      fprintf (stderr, "/dev/input/event%d added mouse on fd %d (%s)\n",
 +               slot, fd, name);
 +      linux_hid_driver.types[slot] = HID_TYPE_MOUSE;
 +      set_handler (slot, linux_hid_driver.mouse_grabbed);
 +    }
  
--      sprintf(path, "%s%i", EVENT_PATH, i++);
--      if (i>=HID_LINUX_MAX_DEV_NO)
--              break;
-+  return 0;
-+}
 -      if (stat(path, &st) == -1)
 -              continue;
  
@@ -847,6 +851,8 @@ index f2e0bce..8cb3e30 100644
 -      assert(c != HID_LINUX_MAX_DEV);
 -      if (hid_linux_driver.controller_paths[c])
 -          continue;
++  return 0;
++}
  
 -      if ((fd = open(path, O_RDONLY)) == -1)
 -          break;
@@ -856,22 +862,21 @@ index f2e0bce..8cb3e30 100644
 -          DEBUG("Input get name failed on %s\n", path);
 -            break;
 -      }
-+static void
-+hid_linux_scan (void *opaque)
-+{
-+  char name[128];
-+  int i;
  
 -        if (ioctl(fd, EVIOCGID, &id) == -1)
 -      {
 -          DEBUG("Input get id failed on %s\n", path);
 -            continue;
 -      }
-+  fprintf (stderr, "hid_linux_scan()\n");
  
 -        /* Only get devices on usb and i8042 */
 -        if (id.bustype != BUS_I8042 && id.bustype != BUS_USB)
 -            continue;
++static void
++hid_linux_scan (void *opaque)
++{
++  char name[128];
++  int i;
  
 -        if (strcasestr(name, "keyboard"))
 -        {
@@ -883,18 +888,21 @@ index f2e0bce..8cb3e30 100644
 -            DEBUG("Add %s %s as a mouse, fd=%d, bus=%d\n", path, name, fd, id.bustype);
 -            controllers = hid_linux_driver.mouse_fds;
 -        }
-+  for (i = 0; i < N_DEVS; ++i)
-+    {
++  fprintf (stderr, "hid_linux_scan()\n");
  
 -      for ( j = 0; j < (HID_LINUX_MAX_DEV / 2) && controllers[j] != -1; j++)
 -          ;
 -      assert(j != (HID_LINUX_MAX_DEV / 2));
-+/* Do We already have this device open and working */
-+      if (linux_hid_driver.fds[i] >= 0)
-+        continue;
  
 -      controllers[j] = fd;
 -      controllers[j + 1] = -1;
++  for (i = 0; i < N_DEVS; ++i)
++    {
++
++/* Do We already have this device open and working */
++      if (linux_hid_driver.fds[i] >= 0)
++        continue;
++
 +      sprintf (name, "/dev/input/event%d", i);
  
 -      if (grab)
@@ -915,7 +923,7 @@ index f2e0bce..8cb3e30 100644
 -      hid_linux_driver.controller_paths[c + 1] = NULL;
 +/* Switch to NBIO*/
 +      {
-+        long arg;
++        long arg = 0;
 +        arg = fcntl (linux_hid_driver.fds[i], F_GETFL, arg);
 +        arg |= O_NONBLOCK;
 +        fcntl (linux_hid_driver.fds[i], F_SETFL, arg);
@@ -935,7 +943,8 @@ index f2e0bce..8cb3e30 100644
 -      close(fd);
 +
 +/* Schedule ourselves */
-+  qemu_mod_timer (linux_hid_driver.scan_timer, qemu_get_clock (rt_clock) + 2000);
++  qemu_mod_timer (linux_hid_driver.scan_timer,
++                  qemu_get_clock (rt_clock) + 2000);
 +
  }
  
@@ -963,7 +972,8 @@ index f2e0bce..8cb3e30 100644
 +
 +/* Kick off the periodic scan for devices */
 +  if (!linux_hid_driver.scan_timer)
-+    linux_hid_driver.scan_timer = qemu_new_timer (rt_clock, hid_linux_scan, NULL);
++    linux_hid_driver.scan_timer =
++      qemu_new_timer (rt_clock, hid_linux_scan, NULL);
 +
-+  linux_hid_scan ();
++  hid_linux_scan (NULL);
  }