aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jcmarsha@gmail.com>2014-05-07 11:46:52 +1200
committerjmarshallnz <jcmarsha@gmail.com>2014-05-07 11:46:52 +1200
commit61df9a4a37198878f89ab4c20c8f26850932dc6d (patch)
tree8fc628493128fa7238223259c0acb0552c42d5f2
parentf2522774be4a37baec9688379081095658f2b57c (diff)
parent420dfd6adc755e62e2a44482a13def05b04d50a5 (diff)
Merge pull request #4592 from koying/fixlinhotplug
FIX: [linux] fix & optimize input device checking
-rw-r--r--xbmc/input/linux/LinuxInputDevices.cpp11
-rw-r--r--xbmc/input/linux/LinuxInputDevices.h2
2 files changed, 9 insertions, 4 deletions
diff --git a/xbmc/input/linux/LinuxInputDevices.cpp b/xbmc/input/linux/LinuxInputDevices.cpp
index 4b642ae7e6..ee21474288 100644
--- a/xbmc/input/linux/LinuxInputDevices.cpp
+++ b/xbmc/input/linux/LinuxInputDevices.cpp
@@ -931,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()
@@ -945,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)
@@ -1016,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;
diff --git a/xbmc/input/linux/LinuxInputDevices.h b/xbmc/input/linux/LinuxInputDevices.h
index c385ed76aa..384a83aa9d 100644
--- a/xbmc/input/linux/LinuxInputDevices.h
+++ b/xbmc/input/linux/LinuxInputDevices.h
@@ -41,7 +41,7 @@ public:
CLinuxInputDevice(const std::string fileName, int index);
~CLinuxInputDevice();
XBMC_Event ReadEvent();
- char* GetDeviceName();
+ const std::string& GetFileName();
bool IsUnplugged();
private: