[droid] add SetupKeyboardAutoRepeat function so we can blacklist devices
authordavilla <davilla@4pi.com>
Wed, 18 Jul 2012 04:45:17 +0000 (00:45 -0400)
committerCory Fields <theuni-nospam-@xbmc.org>
Wed, 8 Aug 2012 23:14:51 +0000 (19:14 -0400)
xbmc/input/linux/LinuxInputDevices.cpp

index 5494d76..a5057e2 100644 (file)
@@ -759,6 +759,36 @@ XBMC_Event CLinuxInputDevice::ReadEvent()
   return devt;
 }
 
+void CLinuxInputDevice::SetupKeyboardAutoRepeat(int fd)
+{
+  bool enable = true;
+
+  if (enable)
+  {
+    int kbdrep[2] = { 400, 80 };
+    ioctl(fd, EVIOCSREP, kbdrep);
+  }
+  else
+  {
+    struct input_event event;
+    memset(&event, 0, sizeof(event));
+
+    gettimeofday(&event.time, NULL);
+    event.type  = EV_REP;
+    event.code  = REP_DELAY;
+    event.value = 0;
+    write(fd, &event, sizeof(event));
+
+    gettimeofday(&event.time, NULL);
+    event.type  = EV_REP;
+    event.code  = REP_PERIOD;
+    event.value = 0;
+    write(fd, &event, sizeof(event));
+
+    CLog::Log(LOGINFO, "CLinuxInputDevice: auto key repeat disabled on device '%s'\n", m_deviceName);
+  }
+}
+
 /*
  * Fill device information.
  * Queries the input device and tries to classify it.
@@ -980,9 +1010,6 @@ bool CLinuxInputDevice::Open()
     return false;
   }
 
-  int kbdrep[2] = { 400, 80 };
-  ioctl(fd, EVIOCSREP, kbdrep);
-
   // Set the socket to non-blocking
   int opts = 0;
   if ((opts = fcntl(fd, F_GETFL)) < 0)
@@ -1003,6 +1030,9 @@ bool CLinuxInputDevice::Open()
   /* fill device info structure */
   GetInfo(fd);
 
+  if (m_deviceType & LI_DEVICE_KEYBOARD)
+    SetupKeyboardAutoRepeat(fd);
+
   m_fd = fd;
   m_vt_fd = -1;