diff options
author | endolf <[email protected]> | 2005-11-07 07:46:34 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2005-11-07 07:46:34 +0000 |
commit | c2b01d6c50108d64084c4c8edcdb2e291ce6d8ed (patch) | |
tree | 523fba2c7147bc4ae08e54c1c6d0584d85445f98 | |
parent | cca9405b8dde9ba06a6d331447c39d156f6a94f9 (diff) |
Handle cases where there are no event devices, only js ones.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@128 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rw-r--r-- | plugins/linux/src/native/jinput.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/linux/src/native/jinput.cpp b/plugins/linux/src/native/jinput.cpp index 4140616..2123d0b 100644 --- a/plugins/linux/src/native/jinput.cpp +++ b/plugins/linux/src/native/jinput.cpp @@ -78,7 +78,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_JInputLibrary_nativeInit int i; int j; int joystickPtr = 0; - jinputDeviceList = (Device **)malloc(numEventDevices * sizeof(Device *)); + jinputDeviceList = (Device **)malloc((numEventDevices + numJoysticks) * sizeof(Device *)); for(i=0;i<numEventDevices;i++) { EventDevice *eventDevice = eventDevices[i]; int deviceCountCache = jinputNumDevices; @@ -94,6 +94,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_JInputLibrary_nativeInit // The current event device is the curre joystick device too LOG_TRACE("Creating a mixed device with id %d, combining event device %d and joystick device %d\n", jinputNumDevices, i, j); jinputDeviceList[jinputNumDevices] = new MixedDevice(jsDevice, eventDevice); + jsDevices[j] = NULL; jinputNumDevices++; joystickPtr = j; j = numJoysticks; @@ -115,6 +116,12 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_JInputLibrary_nativeInit } } + for(i=0;i<numJoysticks;i++) { + if(jsDevices[i]!=NULL) { + LOG_TRACE("Copying joystick device %d to jinput device list %d\n", i, jinputNumDevices); + jinputDeviceList[jinputNumDevices] = jsDevices[i]; + } + } return(0); |