Skip to content

Commit

Permalink
Merge pull request #4592 from koying/fixlinhotplug
Browse files Browse the repository at this point in the history
FIX: [linux] fix & optimize input device checking
  • Loading branch information
jmarshallnz committed May 6, 2014
2 parents f252277 + 420dfd6 commit 61df9a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions xbmc/input/linux/LinuxInputDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/input/linux/LinuxInputDevices.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CLinuxInputDevice
CLinuxInputDevice(const std::string fileName, int index);
~CLinuxInputDevice();
XBMC_Event ReadEvent();
char* GetDeviceName();
const std::string& GetFileName();
bool IsUnplugged();

private:
Expand Down

0 comments on commit 61df9a4

Please sign in to comment.