aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxCombinedController.java32
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java46
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxJoystickButton.java2
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxJoystickPOV.java1
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();