diff options
7 files changed, 32 insertions, 26 deletions
diff --git a/coreAPI/src/java/net/java/games/input/PluginClassLoader.java b/coreAPI/src/java/net/java/games/input/PluginClassLoader.java index 13c580f..dd9d8e1 100644 --- a/coreAPI/src/java/net/java/games/input/PluginClassLoader.java +++ b/coreAPI/src/java/net/java/games/input/PluginClassLoader.java @@ -44,8 +44,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Iterator; -import java.util.Map; import java.util.StringTokenizer; import java.util.jar.JarEntry; import java.util.jar.JarFile; diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java index 059255a..59fb0b2 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java @@ -25,11 +25,7 @@ */ package net.java.games.input; -import net.java.games.input.AbstractController; -import net.java.games.input.Axis; -import net.java.games.input.Controller; import java.util.ArrayList; -import java.util.Iterator; /** * Represents a device that is not a keyboard or mouse. @@ -189,13 +185,15 @@ public class LinuxDevice extends AbstractController { */ private void createButtons(int numButtons) { - int supportedButtons[] = new int[numButtons]; - getSupportedButtons(supportedButtons); - buttons = new LinuxAxis[numButtons]; - for(int i=0;i<numButtons;i++) { - buttons[i] = createButton(i, supportedButtons[i]); - //axesArray.add(buttons[i]); - } + int supportedButtons[] = new int[numButtons]; + buttons = new LinuxAxis[numButtons]; + if(numButtons>0) { + getSupportedButtons(supportedButtons); + for(int i=0;i<numButtons;i++) { + buttons[i] = createButton(i, supportedButtons[i]); + //axesArray.add(buttons[i]); + } + } } /** Create the relative axes for the device @@ -567,6 +565,9 @@ public class LinuxDevice extends AbstractController { * @param supportedButtons Array to populate */ private void getSupportedButtons(int supportedButtons[]) { + if(supportedButtons.length==0) { + return; + } getNativeSupportedButtons(nativeID, supportedButtons); } diff --git a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java index 4e0fbe4..09bbfec 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java @@ -25,10 +25,6 @@ */ package net.java.games.input; -import java.util.ArrayList; -import java.util.Iterator; -import net.java.games.input.Controller; -import net.java.games.input.ControllerEnvironment; import net.java.games.util.plugins.Plugin; /** Environment plugin for linux diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp index 068a023..668b6c4 100644 --- a/plugins/linux/src/native/EventDevice.cpp +++ b/plugins/linux/src/native/EventDevice.cpp @@ -34,6 +34,8 @@ #include <malloc.h> #include <errno.h> +#include "logger.h" + EventDevice::EventDevice(char *deviceFileName) { char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown"; int i; @@ -57,6 +59,8 @@ EventDevice::EventDevice(char *deviceFileName) { name = (char *)malloc(namelength+1); strncpy(name,tempName, namelength+1); + LOG_TRACE("Device name for device file %s is %s\n", deviceFileName, name); + uint8_t evtype_bitmask[EV_MAX/8 + 1]; memset(evtype_bitmask, 0, sizeof(evtype_bitmask)); @@ -213,6 +217,7 @@ int EventDevice::getNumberButtons(){ } const char *EventDevice::getName(){ + LOG_TRACE("EventDevice::getName()\n"); return name; } @@ -336,7 +341,7 @@ int EventDevice::poll(){ // reveiced for things like numlock led change break; default: - fprintf(stderr, "Received event of type 0x%02X from %s, which I wasn't expecting, please report it to [email protected]\n", events[i].type, name); + fprintf(stderr, "Received event of type 0x%02X from %s, which I wasn't expecting, please report it to jinput forum at www.javagaming.org\n", events[i].type, name); } } return dataChanged; diff --git a/plugins/linux/src/native/build.xml b/plugins/linux/src/native/build.xml index 5e82efe..db2890a 100644 --- a/plugins/linux/src/native/build.xml +++ b/plugins/linux/src/native/build.xml @@ -42,13 +42,13 @@ <target name="compileNativeEventLib" depends="init"> <exec dir="." executable="g++" os="Linux"> - <arg line="--shared -o libeventInterface.so eventInterface.cpp EventDevice.cpp"/> + <arg line="--shared -DLOGTRACE -o libeventInterface.so eventInterface.cpp EventDevice.cpp"/> </exec> </target> <target name="compileNativeJinputLib" depends="init"> <exec dir="." executable="g++" os="Linux"> - <arg line="-I${java.home}/include -I${java.home}/include/linux --shared -o libjinput.so jinput.cpp eventInterface.cpp EventDevice.cpp joystickInterface.cpp JoystickDevice.cpp MixedDevice.cpp"/> + <arg line="-I${java.home}/include -I${java.home}/include/linux --shared -DLOGTRACE -o libjinput.so jinput.cpp eventInterface.cpp EventDevice.cpp joystickInterface.cpp JoystickDevice.cpp MixedDevice.cpp"/> </exec> </target> </project> diff --git a/plugins/linux/src/native/eventInterface.cpp b/plugins/linux/src/native/eventInterface.cpp index 2c41cbd..346965b 100644 --- a/plugins/linux/src/native/eventInterface.cpp +++ b/plugins/linux/src/native/eventInterface.cpp @@ -36,6 +36,8 @@ #include "Device.h" #include "EventDevice.h" +#include "logger.h" + int evNumDevices; int eventInterfaceVersion; Device **evDeviceList; @@ -103,6 +105,8 @@ int evInit() { if(tempDevice->isValidDevice()==1) { tempDeviceList[i] = tempDevice; evNumDevices++; + } else { + tempDeviceList[i] = NULL; } } @@ -115,7 +119,7 @@ int evInit() { evTempDeviceCount++; } evDeviceList[i] = tempDeviceList[evTempDeviceCount]; - //printf("Copied device %d to %d\n", evTempDeviceCount, i); + LOG_TRACE("Copied temp event device %d to event device %d\n", evTempDeviceCount, i); evTempDeviceCount++; } diff --git a/plugins/linux/src/native/jinput.cpp b/plugins/linux/src/native/jinput.cpp index 5f78535..69f24c5 100644 --- a/plugins/linux/src/native/jinput.cpp +++ b/plugins/linux/src/native/jinput.cpp @@ -131,7 +131,9 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_init JNIEXPORT jstring JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getDeviceName (JNIEnv *env, jobject, jint deviceID) { - LOG_TRACE("Gettign device name for jinput device %d\n", deviceID); + LOG_TRACE("Gettign device name for jinput device %d.\n", deviceID); + LOG_TRACE("jinput device %d is %d\n", deviceID, jinputDeviceList[deviceID]); + LOG_TRACE("Gettign device name for jinput device %d, (%s)\n", deviceID, jinputDeviceList[deviceID]->getName()); return env->NewStringUTF(jinputDeviceList[deviceID]->getName()); } @@ -143,7 +145,7 @@ JNIEXPORT jstring JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getDe JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumAbsAxes (JNIEnv *env, jobject, jint deviceID) { - LOG_TRACE("Gettign number of absolute axes for jinput device %d\n", deviceID); + LOG_TRACE("Gettign number of absolute axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberAbsAxes()); return jinputDeviceList[deviceID]->getNumberAbsAxes(); } @@ -155,7 +157,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumAb JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumRelAxes (JNIEnv *env, jobject, jint deviceID) { - LOG_TRACE("Gettign number of relative axes for jinput device %d\n", deviceID); + LOG_TRACE("Gettign number of relative axes for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberRelAxes()); return jinputDeviceList[deviceID]->getNumberRelAxes(); } @@ -167,7 +169,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumRe JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEnvironmentPlugin_getNumButtons (JNIEnv *, jobject, jint deviceID) { - LOG_TRACE("Gettign number of buttons for jinput device %d\n", deviceID); + LOG_TRACE("Gettign number of buttons for jinput device %d (%d)\n", deviceID, jinputDeviceList[deviceID]->getNumberButtons()); return jinputDeviceList[deviceID]->getNumberButtons(); } @@ -224,7 +226,7 @@ JNIEXPORT void JNICALL Java_net_java_games_input_LinuxDevice_getNativeSupportedB jint *buttonDataElements = env->GetIntArrayElements(buttonData, 0); - LOG_TRACE("Getting suported buttons for jinput device %d\n", deviceID); + LOG_TRACE("Getting supported buttons for jinput device %d\n", deviceID); jinputDeviceList[deviceID]->getSupportedButtons(buttonDataElements); env->ReleaseIntArrayElements(buttonData, buttonDataElements, 0); |