tags 633501 + patch
forwarded 633501 http://java.net/jira/browse/JINPUT-44
thanks

Hi all,

I've reported this bug upstream at http://java.net/jira/browse/JINPUT-44 , and submitted a patch (attached, and also at http://ldpreload.com/p/jinput-remove-getDeviceUsageBits.patch ) to eliminate all code related to this nonexistent ioctl. The package builds cleanly with this patch applied via debian/patches, and I've verified that the resulting .so no longer references an EVIOCGUSAGE symbol, but I don't have enough of an idea of how this package works to properly test that it addresses the reported crash. (At the very least, I can't reproduce the crash simply by installing this package, or adding "import net.java.games.input.*" to a Hello World class.)

Java team, if you would like me to prepare a debdiff or NMU including this patch, let me know (and let me know how to test it), and I'll be happy to do so.

--
Geoffrey Thomas
http://ldpreload.com
geo...@ldpreload.com
Index: trunk/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java
===================================================================
--- trunk/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java	(revision 247)
+++ trunk/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java	(working copy)
@@ -94,28 +94,6 @@
 	}
 
 	private final Controller.Type guessType() throws IOException {
-		Controller.Type type_from_usages = guessTypeFromUsages();
-		if (type_from_usages == Controller.Type.UNKNOWN)
-			return guessTypeFromComponents();
-		else
-			return type_from_usages;
-	}
-	
-	private final Controller.Type guessTypeFromUsages() throws IOException {
-		byte[] usage_bits = getDeviceUsageBits();
-		if (isBitSet(usage_bits, NativeDefinitions.USAGE_MOUSE))
-			return Controller.Type.MOUSE;
-		else if (isBitSet(usage_bits, NativeDefinitions.USAGE_KEYBOARD))
-			return Controller.Type.KEYBOARD;
-		else if (isBitSet(usage_bits, NativeDefinitions.USAGE_GAMEPAD))
-			return Controller.Type.GAMEPAD;
-		else if (isBitSet(usage_bits, NativeDefinitions.USAGE_JOYSTICK))
-			return Controller.Type.STICK;
-		else
-			return Controller.Type.UNKNOWN;
-	}
-
-	private final Controller.Type guessTypeFromComponents() throws IOException {
 		List components = getComponents();
 		if (components.size() == 0)
 			return Controller.Type.UNKNOWN;
@@ -342,15 +320,6 @@
 	}
 	private final static native void nGetBits(long fd, int ev_type, byte[] evtype_bits) throws IOException;
 
-	private final byte[] getDeviceUsageBits() throws IOException {
-		byte[] bits = new byte[NativeDefinitions.USAGE_MAX/8 + 1];
-		if (getVersion() >= 0x010001) {
-			nGetDeviceUsageBits(fd, bits);
-		}
-		return bits;
-	}
-	private final static native void nGetDeviceUsageBits(long fd, byte[] type_bits) throws IOException;
-
 	public final synchronized void pollKeyStates() throws IOException {
 		nGetKeyStates(fd, key_states);
 	}
Index: trunk/plugins/linux/src/native/net_java_games_input_LinuxEventDevice.c
===================================================================
--- trunk/plugins/linux/src/native/net_java_games_input_LinuxEventDevice.c	(revision 247)
+++ trunk/plugins/linux/src/native/net_java_games_input_LinuxEventDevice.c	(working copy)
@@ -112,20 +112,6 @@
 	return num_effects;
 }
 
-JNIEXPORT void JNICALL Java_net_java_games_input_LinuxEventDevice_nGetDeviceUsageBits(JNIEnv *env, jclass unused, jlong fd_address, jbyteArray usages_array) {
-#if EV_VERSION >= 0x010001
-	int fd = (int)fd_address;
-	jsize len = (*env)->GetArrayLength(env, usages_array);
-	jbyte *usages = (*env)->GetByteArrayElements(env, usages_array, NULL);
-	if (usages == NULL)
-		return;
-	int res = ioctl(fd, EVIOCGUSAGE(len), usages);
-	(*env)->ReleaseByteArrayElements(env, usages_array, usages, 0);
-	if (res == -1)
-		throwIOException(env, "Failed to get device usages (%d)\n", errno);
-#endif
-}
-
 JNIEXPORT void JNICALL Java_net_java_games_input_LinuxEventDevice_nGetBits(JNIEnv *env, jclass unused, jlong fd_address, jint evtype, jbyteArray bits_array) {
 	int fd = (int)fd_address;
 	jsize len = (*env)->GetArrayLength(env, bits_array);

Reply via email to