From a678f1599cbd524caf4fc2220b51b02025dbe15a Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 8 Jun 2022 21:44:42 -0500 Subject: [PATCH] Reset to rescanControllers basic --- .../input/DefaultControllerEnvironment.java | 4 +- src/overview.html | 4 +- .../games/input/AWTEnvironmentPlugin.java | 5 -- .../games/input/LinuxEnvironmentPlugin.java | 58 ++++--------------- .../java/games/input/LinuxEventDevice.java | 4 -- .../java/games/input/LinuxJoystickDevice.java | 9 --- 6 files changed, 14 insertions(+), 70 deletions(-) diff --git a/src/core/net/java/games/input/DefaultControllerEnvironment.java b/src/core/net/java/games/input/DefaultControllerEnvironment.java index bfebaf9..29645a1 100644 --- a/src/core/net/java/games/input/DefaultControllerEnvironment.java +++ b/src/core/net/java/games/input/DefaultControllerEnvironment.java @@ -138,13 +138,13 @@ class DefaultControllerEnvironment extends ControllerEnvironment { pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin"; } else if(osName.equals("Mac OS X")) { pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin"; - } else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7") || osName.equals("Windows 8") || osName.equals("Windows 10") || osName.equals("Windows 11")) { + } else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7")) { pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin"; } else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) { pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin"; } else if (osName.startsWith("Windows")) { log.warning("Found unknown Windows version: " + osName); - log.warning("Attempting to use default Windows Plugin."); + log.warning("Attempting to use default windows plug-in."); pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin"; } else { log.warning("Trying to use default plugin, OS name " + osName +" not recognised"); diff --git a/src/overview.html b/src/overview.html index 6468318..9290060 100644 --- a/src/overview.html +++ b/src/overview.html @@ -5,9 +5,9 @@ - This is a fork of the jinput project. The fork is at https://github.com/sigonasr2/jinput2.10. + This is a fork of the jinput project. The fork is at https://github.com/hervegirod/jinput2.

- The original jinput project is at https://github.com/jinput/jinput. + The original jinput project is at https://github.com/jinput/jinput diff --git a/src/plugins/awt/net/java/games/input/AWTEnvironmentPlugin.java b/src/plugins/awt/net/java/games/input/AWTEnvironmentPlugin.java index 4d217a1..870aca4 100644 --- a/src/plugins/awt/net/java/games/input/AWTEnvironmentPlugin.java +++ b/src/plugins/awt/net/java/games/input/AWTEnvironmentPlugin.java @@ -45,11 +45,6 @@ public class AWTEnvironmentPlugin extends ControllerEnvironment implements Plugi return controllers; } - - /** - * Returns a list of all controllers available to this environment, - * or an empty array if there are no controllers in this environment. - */ public Controller[] rescanControllers() { return new Controller[]{new AWTKeyboard(), new AWTMouse()}; } diff --git a/src/plugins/linux/net/java/games/input/LinuxEnvironmentPlugin.java b/src/plugins/linux/net/java/games/input/LinuxEnvironmentPlugin.java index c6e7ffe..d015663 100644 --- a/src/plugins/linux/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/src/plugins/linux/net/java/games/input/LinuxEnvironmentPlugin.java @@ -47,8 +47,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen private static boolean supported = false; private final Controller[] controllers; - private final List joystickDevices = new ArrayList<>(); - private final List eventDevices = new ArrayList<>(); + private final List devices = new ArrayList(); private final static LinuxDeviceThread device_thread = new LinuxDeviceThread(); /** @@ -123,9 +122,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } public final Controller[] rescanControllers() { - Controller[] newControllers = enumerateControllers(); - log("Linux plugin claims to have found " + newControllers.length + " controllers"); - return newControllers; + return enumerateControllers(); } private final static Component[] createComponents(List event_components, LinuxEventDevice device) { @@ -235,19 +232,15 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen // compare // Check if the nodes have the same name if(evController.getName().equals(jsController.getName())) { - System.out.println("Same names. "+jsController.getName()); // Check they have the same component count Component[] evComponents = evController.getComponents(); Component[] jsComponents = jsController.getComponents(); if(evComponents.length == jsComponents.length) { - System.out.println("Same component count."+evComponents.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())) { - - System.out.println("Differing components: "+evComponents[k].getIdentifier()+"//"+jsComponents[k].getIdentifier()); foundADifference = true; } } @@ -402,24 +395,13 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen File event_file = joystick_device_files[i]; try { String path = getAbsolutePathPrivileged(event_file); - LinuxJoystickDevice device; - if (joystickDevices.size()>i) { - device=joystickDevices.get(i); - if (device==null) { - device = new LinuxJoystickDevice(path); - joystickDevices.set(i,device); - } - } else { - device = new LinuxJoystickDevice(path); - joystickDevices.add(device); - } + LinuxJoystickDevice device = new LinuxJoystickDevice(path); Controller controller = createJoystickFromJoystickDevice(device); if(controller != null) { controllers.add(controller); - } else { + devices.add(device); + } else device.close(); - joystickDevices.set(i,null); - } } catch(IOException e) { log("Failed to open device (" + event_file + "): " + e.getMessage()); } @@ -462,26 +444,14 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen File event_file = event_device_files[i]; try { String path = getAbsolutePathPrivileged(event_file); - LinuxEventDevice device; - //System.out.println(event_file+":"+i); - if (eventDevices.size()>i) { - device=eventDevices.get(i); - if (device==null) { - device = new LinuxEventDevice(path); - eventDevices.set(i,device); - } - } else { - device = new LinuxEventDevice(path); - eventDevices.add(device); - } + LinuxEventDevice device = new LinuxEventDevice(path); try { Controller controller = createControllerFromDevice(device); if(controller != null) { controllers.add(controller); - } else { + devices.add(device); + } else device.close(); - eventDevices.set(i,null); - } } catch(IOException e) { log("Failed to create Controller: " + e.getMessage()); device.close(); @@ -494,17 +464,9 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen private final class ShutdownHook extends Thread { public final void run() { - for(int i = 0; i < eventDevices.size(); i++) { - try { - LinuxEventDevice device = eventDevices.get(i); - device.close(); - } catch(IOException e) { - log("Failed to close device: " + e.getMessage()); - } - } - for(int i = 0; i < joystickDevices.size(); i++) { + for(int i = 0; i < devices.size(); i++) { try { - LinuxJoystickDevice device = joystickDevices.get(i); + LinuxDevice device = devices.get(i); device.close(); } catch(IOException e) { log("Failed to close device: " + e.getMessage()); diff --git a/src/plugins/linux/net/java/games/input/LinuxEventDevice.java b/src/plugins/linux/net/java/games/input/LinuxEventDevice.java index bd09ffc..a69f9e8 100644 --- a/src/plugins/linux/net/java/games/input/LinuxEventDevice.java +++ b/src/plugins/linux/net/java/games/input/LinuxEventDevice.java @@ -364,8 +364,4 @@ final class LinuxEventDevice implements LinuxDevice { protected void finalize() throws IOException { close(); } - @Override - public boolean equals(Object obj) { - return obj instanceof LinuxEventDevice&&((LinuxEventDevice)obj).getName().equals(getName()); - } } diff --git a/src/plugins/linux/net/java/games/input/LinuxJoystickDevice.java b/src/plugins/linux/net/java/games/input/LinuxJoystickDevice.java index 1525706..c749684 100644 --- a/src/plugins/linux/net/java/games/input/LinuxJoystickDevice.java +++ b/src/plugins/linux/net/java/games/input/LinuxJoystickDevice.java @@ -235,13 +235,4 @@ final class LinuxJoystickDevice implements LinuxDevice { protected void finalize() throws IOException { close(); } - @Override - public boolean equals(Object obj) { - try { - return obj instanceof LinuxJoystickDevice&&((LinuxJoystickDevice)obj).getDeviceName().equals(getDeviceName()); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - } }