Merge pull request #4592 from koying/fixlinhotplug
[vuplus_xbmc] / xbmc / input / linux / LinuxInputDevices.cpp
index bb556b6..ee21474 100644 (file)
 #include "system.h"
 #if defined(HAS_LINUX_EVENTS)
 
+#if defined(HAS_LIBAMCODEC)
+#include "utils/AMLUtils.h"
+#endif
+
 #include <linux/version.h>
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
@@ -743,21 +747,24 @@ void CLinuxInputDevice::SetupKeyboardAutoRepeat(int fd)
 {
   bool enable = true;
 
-#if defined(HAS_AMLPLAYER)
-  // ignore the native aml driver named 'key_input',
-  //  it is the dedicated power key handler (am_key_input)
-  if (strncmp(m_deviceName, "key_input", strlen("key_input")) == 0)
-    return;
-  // ignore the native aml driver named 'aml_keypad',
-  //  it is the dedicated IR remote handler (amremote)
-  else if (strncmp(m_deviceName, "aml_keypad", strlen("aml_keypad")) == 0)
-    return;
-
-  // turn off any keyboard autorepeat, there is a kernel bug
-  // where if the cpu is max'ed then key up is missed and
-  // we get a flood of EV_REP that never stop until next
-  // key down/up. Very nasty when seeking during video playback.
-  enable = false;
+#if defined(HAS_LIBAMCODEC)
+  if (aml_present())
+  {
+    // ignore the native aml driver named 'key_input',
+    //  it is the dedicated power key handler (am_key_input)
+    if (strncmp(m_deviceName, "key_input", strlen("key_input")) == 0)
+      return;
+    // ignore the native aml driver named 'aml_keypad',
+    //  it is the dedicated IR remote handler (amremote)
+    else if (strncmp(m_deviceName, "aml_keypad", strlen("aml_keypad")) == 0)
+      return;
+
+    // turn off any keyboard autorepeat, there is a kernel bug
+    // where if the cpu is max'ed then key up is missed and
+    // we get a flood of EV_REP that never stop until next
+    // key down/up. Very nasty when seeking during video playback.
+    enable = false;
+  }
 #endif
 
   if (enable)
@@ -924,9 +931,9 @@ void CLinuxInputDevice::GetInfo(int fd)
   //printf("pref: %d\n", m_devicePreferredId);
 }
 
-char* CLinuxInputDevice::GetDeviceName()
+const std::string& CLinuxInputDevice::GetFileName()
 {
-  return m_deviceName;
+  return m_fileName;
 }
 
 bool CLinuxInputDevice::IsUnplugged()
@@ -938,6 +945,11 @@ bool CLinuxInputDevices::CheckDevice(const char *device)
 {
   int fd;
 
+  // Does the device exists?
+  struct stat buffer;
+  if (stat(device, &buffer) != 0)
+    return false;
+
   /* Check if we are able to open the device */
   fd = open(device, O_RDWR);
   if (fd < 0)
@@ -1009,7 +1021,7 @@ void CLinuxInputDevices::CheckHotplugged()
 
     for (size_t j = 0; j < m_devices.size(); j++)
     {
-      if (strcmp(m_devices[j]->GetDeviceName(),buf) == 0)
+      if (m_devices[j]->GetFileName().compare(buf) == 0)
       {
         ispresent = true;
         break;