diff options
author | endolf <[email protected]> | 2007-08-12 21:59:25 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2007-08-12 21:59:25 +0000 |
commit | 44a23d21c5dd47d73eb2017f1a3383a25d6b7931 (patch) | |
tree | 3e2d1f91f4a9a3302e5d6f824aac86921cef6c5b | |
parent | a46e691452656fa28a840390fcf9b9a6280f5ebd (diff) |
Complete - task 36: Linux plugin not reporting normalised values
https://jinput.dev.java.net/issues/show_bug.cgi?id=36
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@202 e343933a-64c8-49c5-92b1-88f2ce3e89e8
4 files changed, 71 insertions, 10 deletions
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxCombinedController.java b/plugins/linux/src/java/net/java/games/input/LinuxCombinedController.java new file mode 100644 index 0000000..a88c7c9 --- /dev/null +++ b/plugins/linux/src/java/net/java/games/input/LinuxCombinedController.java @@ -0,0 +1,32 @@ +package net.java.games.input; + +import java.io.IOException; + +public class LinuxCombinedController extends AbstractController { + + private LinuxAbstractController eventController; + private LinuxJoystickAbstractController joystickController; + + LinuxCombinedController(LinuxAbstractController eventController, LinuxJoystickAbstractController joystickController) { + super(eventController.getName(), joystickController.getComponents(), eventController.getControllers(), eventController.getRumblers()); + this.eventController = eventController; + this.joystickController = joystickController; + } + + protected boolean getNextDeviceEvent(Event event) throws IOException { + return joystickController.getNextDeviceEvent(event); + } + + public final PortType getPortType() { + return eventController.getPortType(); + } + + public final void pollDevice() throws IOException { + eventController.pollDevice(); + joystickController.pollDevice(); + } + + public Type getType() { + return eventController.getType(); + } +} 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 2b93099..189747c 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java @@ -226,14 +226,44 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen private final Controller[] enumerateControllers() { List controllers = new ArrayList(); - enumerateEventControllers(controllers); - if (controllers.size() == 0) { - /* Some linux distros, even modern ones, can't figure out - * how to give event devices proper access rights, so we'll have - * to fallback to the legacy joystick interface. - */ - enumerateJoystickControllers(controllers); + List eventControllers = new ArrayList(); + List jsControllers = new ArrayList(); + enumerateEventControllers(eventControllers); + enumerateJoystickControllers(jsControllers); + + for(int i=0;i<eventControllers.size();i++) { + for(int j=0;j<jsControllers.size();j++) { + Controller evController = (Controller) eventControllers.get(i); + Controller jsController = (Controller) jsControllers.get(j); + + // compare + // Check if the nodes have the same name + if(evController.getName().equals(jsController.getName())) { + // Check they have the same component count + Component[] evComponents = evController.getComponents(); + Component[] jsComponents = jsController.getComponents(); + if(evComponents.length==jsComponents.length) { + boolean foundADifference = false; + // check the component pairs are of the same type + for(int k=0;k<evComponents.length;k++) { + // Check the type of the component is the same + if(!(evComponents[k].getIdentifier() == jsComponents[k].getIdentifier())) { + foundADifference = true; + } + } + + if(!foundADifference) { + controllers.add(new LinuxCombinedController((LinuxAbstractController)eventControllers.remove(i), (LinuxJoystickAbstractController)jsControllers.remove(j))); + i--; + j--; + } + } + } + } } + controllers.addAll(eventControllers); + controllers.addAll(jsControllers); + Controller[] controllers_array = new Controller[controllers.size()]; controllers.toArray(controllers_array); return controllers_array; @@ -317,7 +347,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6]; for (int i = 0; i < device.getNumButtons(); i++) { - Component.Identifier.Button button_id = (Component.Identifier.Button)LinuxNativeTypesMap.getButtonID(buttonMap[i]); + Component.Identifier button_id = (Component.Identifier)LinuxNativeTypesMap.getButtonID(buttonMap[i]); if (button_id != null) { LinuxJoystickButton button = new LinuxJoystickButton(button_id); device.registerButton(i, button); diff --git a/plugins/linux/src/java/net/java/games/input/LinuxJoystickButton.java b/plugins/linux/src/java/net/java/games/input/LinuxJoystickButton.java index f8d47d5..e0a3b3d 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxJoystickButton.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxJoystickButton.java @@ -47,7 +47,7 @@ import java.io.IOException; final class LinuxJoystickButton extends AbstractComponent { private float value; - public LinuxJoystickButton(Component.Identifier.Button button_id) { + public LinuxJoystickButton(Component.Identifier button_id) { super(button_id.getName(), button_id); } diff --git a/plugins/linux/src/java/net/java/games/input/LinuxJoystickPOV.java b/plugins/linux/src/java/net/java/games/input/LinuxJoystickPOV.java index 2ae5dc2..ed5593c 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxJoystickPOV.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxJoystickPOV.java @@ -24,7 +24,6 @@ public class LinuxJoystickPOV extends LinuxJoystickAxis { protected void updateValue() { - LinuxEnvironmentPlugin.logln("Updating pov " + hatX.getName() + ", " + hatY.getName()); float last_x = hatX.getPollData(); float last_y = hatY.getPollData(); |