aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorendolf <[email protected]>2003-10-04 12:48:51 +0000
committerendolf <[email protected]>2003-10-04 12:48:51 +0000
commitf73d0b8719fe82e2e362685ae8c8451fa48572dd (patch)
treea399ccf435e007be0331a92df118307c55d72189 /plugins
parente9fb8f194a4e54e067bee7850173c47285836b39 (diff)
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/linux/src/native/EventDevice.cpp10
-rw-r--r--plugins/linux/src/native/EventDevice.h1
-rw-r--r--plugins/linux/src/native/eventInterface.cpp14
-rw-r--r--plugins/linux/src/native/jinput.cpp4
-rw-r--r--plugins/linux/src/native/joystickInterface.cpp9
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;