fixes for issues 25 and 26

Sigsgv with logitec USB keyboard with volume controls and mouse wheel

when valid event device list in /dev/input/event* has invalid devices in the middle of the sequence, a sigsegv is seen
This commit is contained in:
endolf 2004-04-21 09:48:55 +00:00
parent 54ecf9687a
commit 2dc9aae5e2
7 changed files with 32 additions and 26 deletions

View file

@ -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);
}

View file

@ -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