From f73d0b8719fe82e2e362685ae8c8451fa48572dd Mon Sep 17 00:00:00 2001 From: endolf Date: Sat, 4 Oct 2003 12:48:51 +0000 Subject: Fix and updated error messages for issue 20 git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@53 e343933a-64c8-49c5-92b1-88f2ce3e89e8 --- plugins/linux/src/native/EventDevice.cpp | 10 ++++++++-- plugins/linux/src/native/EventDevice.h | 1 + plugins/linux/src/native/eventInterface.cpp | 14 +++++++++++--- plugins/linux/src/native/jinput.cpp | 4 ++-- plugins/linux/src/native/joystickInterface.cpp | 9 ++++++++- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp index de9b5a4..068a023 100644 --- a/plugins/linux/src/native/EventDevice.cpp +++ b/plugins/linux/src/native/EventDevice.cpp @@ -40,9 +40,11 @@ EventDevice::EventDevice(char *deviceFileName) { fd = open(deviceFileName, O_RDWR | O_NONBLOCK); if(fd<0) { - char errorMessage[512]; + /*char errorMessage[512]; sprintf(errorMessage, "Error opening device %s\n", deviceFileName); - perror(errorMessage); + perror(errorMessage);*/ + inited = 0; + return; } if(ioctl(fd, EVIOCGNAME(sizeof(tempName)), tempName) < 0) { @@ -191,6 +193,10 @@ EventDevice::EventDevice(char *deviceFileName) { inited = 1; } +int EventDevice::isValidDevice() { + return inited; +} + int EventDevice::getNumberRelAxes(){ if(inited!=1) return -1; return numRelAxes; diff --git a/plugins/linux/src/native/EventDevice.h b/plugins/linux/src/native/EventDevice.h index 1174a5f..58f9195 100644 --- a/plugins/linux/src/native/EventDevice.h +++ b/plugins/linux/src/native/EventDevice.h @@ -79,6 +79,7 @@ class EventDevice : public Device { int getAbsAxisMinimum(int axisNumber); int getAbsAxisMaximum(int axisNumber); int getAbsAxisFuzz(int axisNumber); + int isValidDevice(); }; diff --git a/plugins/linux/src/native/eventInterface.cpp b/plugins/linux/src/native/eventInterface.cpp index 303c667..654a0bd 100644 --- a/plugins/linux/src/native/eventInterface.cpp +++ b/plugins/linux/src/native/eventInterface.cpp @@ -95,16 +95,24 @@ int evInit() { evNumDevices = 0; for(i=0;igetBusType()!=-1) { + EventDevice *tempDevice = new EventDevice(deviceFileNames[i]); + if(tempDevice->isValidDevice()==1) { + tempDeviceList[i] = tempDevice; evNumDevices++; } } + int highDeviceCountNumber = i; + int evTempDeviceCount = 0; // Now we know for certain which devices are open, we can take notes evDeviceList = (Device **)malloc(evNumDevices * sizeof(Device *)); for(i=0;i