diff options
Diffstat (limited to 'plugins/linux/src/native')
-rw-r--r-- | plugins/linux/src/native/EventDevice.cpp | 10 | ||||
-rw-r--r-- | plugins/linux/src/native/EventDevice.h | 1 | ||||
-rw-r--r-- | plugins/linux/src/native/eventInterface.cpp | 14 | ||||
-rw-r--r-- | plugins/linux/src/native/jinput.cpp | 4 | ||||
-rw-r--r-- | 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;i<numDeviceFiles;i++) { - tempDeviceList[i] = new EventDevice(deviceFileNames[i]); - if(tempDeviceList[i]->getBusType()!=-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<evNumDevices;i++) { - evDeviceList[i] = tempDeviceList[i]; + while(tempDeviceList[evTempDeviceCount] == NULL) { + evTempDeviceCount++; + } + evDeviceList[i] = tempDeviceList[evTempDeviceCount]; + //printf("Copied device %d to %d\n", evTempDeviceCount, i); + evTempDeviceCount++; } evInited=1; diff --git a/plugins/linux/src/native/jinput.cpp b/plugins/linux/src/native/jinput.cpp index e20feeb..3ce6c6a 100644 --- a/plugins/linux/src/native/jinput.cpp +++ b/plugins/linux/src/native/jinput.cpp @@ -52,11 +52,11 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init (JNIEnv *, jobject) { if(evInit()!=0) { - fprintf(stderr, "Failed to init native jinput\n"); + fprintf(stderr, "Failed to init native event interface\n"); return -1; } if(jsInit()!=0) { - fprintf(stderr, "Failed to init native jinput\n"); + fprintf(stderr, "Failed to init native joystick interface\n"); return -1; } diff --git a/plugins/linux/src/native/joystickInterface.cpp b/plugins/linux/src/native/joystickInterface.cpp index 2bcc8bc..bfa4231 100644 --- a/plugins/linux/src/native/joystickInterface.cpp +++ b/plugins/linux/src/native/joystickInterface.cpp @@ -102,10 +102,17 @@ int jsInit() { } } + int highDeviceCountNumber = i; + int jsTempDeviceCount = 0; // Now we know for certain which devices are open, we can take notes jsDeviceList = (Device **)malloc(jsNumDevices * sizeof(Device *)); for(i=0;i<jsNumDevices;i++) { - jsDeviceList[i] = tempDeviceList[i]; + while(tempDeviceList[jsTempDeviceCount] == NULL) { + jsTempDeviceCount++; + } + jsDeviceList[i] = tempDeviceList[jsTempDeviceCount]; + //printf("Copied joystick %d to %d\n", jsTempDeviceCount, i); + jsTempDeviceCount++; } jsInited=1; |