aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.xml1
-rw-r--r--coreAPI/build.xml6
-rw-r--r--coreAPI/src/java/net/java/games/input/ControllerEnvironment.java5
-rw-r--r--coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java65
-rw-r--r--plugins/OSX/build.xml4
-rwxr-xr-xplugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java5
-rw-r--r--plugins/awt/build.xml4
-rw-r--r--plugins/awt/src/net/java/games/input/AWTEnvironmentPlugin.java5
-rw-r--r--plugins/linux/build.xml4
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDevice.java3
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java1013
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java7
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxJoystickDevice.java5
-rw-r--r--plugins/windows/build.xml4
-rw-r--r--plugins/windows/src/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java5
-rw-r--r--plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java5
-rw-r--r--plugins/windows/src/java/net/java/games/input/RawInputEnvironmentPlugin.java5
-rw-r--r--plugins/wintab/build.xml6
-rw-r--r--plugins/wintab/src/java/net/java/games/input/WinTabEnvironmentPlugin.java5
19 files changed, 690 insertions, 467 deletions
diff --git a/build.xml b/build.xml
index 1873a70..44d7f1e 100644
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<project name="Sun Games Initiative Client Technologies" basedir="." default="all" xmlns:artifact="urn:maven-artifact-ant">
+ <echo message="${os.arch}"/>
<property name="api.version" value="2.0.6"/>
<property name="mvn.version" value="${api.version}-SNAPSHOT"/>
diff --git a/coreAPI/build.xml b/coreAPI/build.xml
index f585b00..56b531d 100644
--- a/coreAPI/build.xml
+++ b/coreAPI/build.xml
@@ -10,7 +10,7 @@
</target>
<target name="compile" depends="init">
- <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
+ <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.5" target="1.5">
<include name="net/**"/>
<exclude name="**/Version.java"/>
<!-- To add something to the classpath: -->
@@ -26,7 +26,7 @@
<filter token="API_VERSION" value="${api.version}"/>
</filterset>
</copy>
- <javac srcdir="build/src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
+ <javac srcdir="build/src/java" destdir="classes" debug="true" deprecation="true" source="1.5" target="1.5">
<include name="net/**" />
</javac>
<echo message="Build version class for ${api.version} build ${build.number}"/>
@@ -44,7 +44,7 @@
<target name="javadoc" depends="init" description="Javadoc for my API.">
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
- additionalparam="-source 1.4"
+ additionalparam="-source 1.5"
excludepackagenames="net.java.games.input.example.*,net.java.games.input.test.*">
<sourcepath>
<pathelement location="src/java"/>
diff --git a/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java
index 17208f7..3a7c21e 100644
--- a/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java
+++ b/coreAPI/src/java/net/java/games/input/ControllerEnvironment.java
@@ -100,6 +100,11 @@ public abstract class ControllerEnvironment {
* or an empty array if there are no controllers in this environment.
*/
public abstract Controller[] getControllers();
+ /**
+ * Rescans the devices and provides a list of new controllers.
+ * @return a list of all controllers available to this environment.
+ */
+ public abstract Controller[] rescanControllers();
/**
* Adds a listener for controller state change events.
diff --git a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java
index 431a9ff..b193ef0 100644
--- a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java
+++ b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java
@@ -105,9 +105,10 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
/**
* List of all controllers in this environment
*/
- private ArrayList controllers;
+ private ArrayList<Controller> controllers;
private Collection loadedPlugins = new ArrayList();
+ private ArrayList<ControllerEnvironment> environments = new ArrayList<ControllerEnvironment>();
/**
* Public no-arg constructor.
@@ -122,7 +123,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
public Controller[] getControllers() {
if (controllers == null) {
// Controller list has not been scanned.
- controllers = new ArrayList();
+ controllers = new ArrayList<Controller>();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
scanControllers();
@@ -159,6 +160,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
Class ceClass = Class.forName(className);
ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance();
if(ce.isSupported()) {
+ environments.add(ce);
addControllers(ce.getControllers());
loadedPlugins.add(ce.getClass().getName());
} else {
@@ -170,6 +172,65 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
}
}
}
+ if(!environments.isEmpty()){
+ Controller[] newScanControllers = environments.get(0).getControllers();
+ Controller[] ret = new Controller[newScanControllers.length];
+ for(int i = 0; i < newScanControllers.length; i++){
+ ret[i] = newScanControllers[i];
+ }
+ return ret;
+ }
+
+ Controller[] ret = new Controller[controllers.size()];
+ Iterator it = controllers.iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ ret[i] = (Controller)it.next();
+ i++;
+ }
+ return ret;
+ }
+
+ /**
+ * 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() {
+ if(!environments.isEmpty()){
+ Controller[] newScanControllers = environments.get(0).rescanControllers();
+ // need to add controllers that were connected
+ for(int i = 0; i < newScanControllers.length; i++){
+ boolean controllerExist = false;
+ for(Controller controller:controllers){
+ if(newScanControllers[i] == controller){
+ controllerExist = true;
+ break;
+ }
+ }
+ if(!controllerExist){
+ controllers.add(newScanControllers[i]);
+ }
+ }
+ ArrayList<Controller> removeControllers = new ArrayList<Controller>();
+ // need to remove controllers that have disconnected
+ for(Controller controller:controllers){
+ boolean controllerExist = false;
+ for(int i = 0; i < newScanControllers.length; i++){
+ if(controller == newScanControllers[i]){
+ controllerExist = true;
+ break;
+ }
+ }
+ if(!controllerExist){
+ //controllers.remove(controller);
+ removeControllers.add(controller);
+ }
+ }
+ for(Controller controller: removeControllers){
+ controllers.remove(controller);
+ }
+ }
+
Controller[] ret = new Controller[controllers.size()];
Iterator it = controllers.iterator();
int i = 0;
diff --git a/plugins/OSX/build.xml b/plugins/OSX/build.xml
index 659f766..148e161 100644
--- a/plugins/OSX/build.xml
+++ b/plugins/OSX/build.xml
@@ -18,7 +18,7 @@
</target>
<target depends="init" name="compile">
- <javac debug="true" deprecation="true" destdir="${build}" source="1.4" srcdir="src/java">
+ <javac debug="true" deprecation="true" destdir="${build}" source="1.5" srcdir="src/java">
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
<pathelement location="../../lib/jutils.jar"/>
@@ -39,7 +39,7 @@
<mkdir dir="apidocs"/>
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
- additionalparam="-source 1.4"
+ additionalparam="-source 1.5"
link="../../../coreAPI/apidocs">
<sourcepath>
<pathelement location="src/java"/>
diff --git a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java
index b20c428..4df7b40 100755
--- a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java
+++ b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java
@@ -285,4 +285,9 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
controllers.toArray(controllers_array);
return controllers_array;
}
+
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/plugins/awt/build.xml b/plugins/awt/build.xml
index 431ad63..3a87342 100644
--- a/plugins/awt/build.xml
+++ b/plugins/awt/build.xml
@@ -7,7 +7,7 @@
</target>
<target depends="init" name="compile">
- <javac debug="true" deprecation="true" destdir="classes" source="1.4" target="1.4" srcdir="src">
+ <javac debug="true" deprecation="true" destdir="classes" source="1.5" target="1.5" srcdir="src">
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
<pathelement location="../../lib/jutils.jar"/>
@@ -28,7 +28,7 @@
<mkdir dir="apidocs"/>
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
- additionalparam="-source 1.4"
+ additionalparam="-source 1.5"
link="../../../coreAPI/apidocs">
<sourcepath>
<pathelement location="src"/>
diff --git a/plugins/awt/src/net/java/games/input/AWTEnvironmentPlugin.java b/plugins/awt/src/net/java/games/input/AWTEnvironmentPlugin.java
index b6b062a..d675cd7 100644
--- a/plugins/awt/src/net/java/games/input/AWTEnvironmentPlugin.java
+++ b/plugins/awt/src/net/java/games/input/AWTEnvironmentPlugin.java
@@ -48,4 +48,9 @@ public class AWTEnvironmentPlugin extends ControllerEnvironment implements Plugi
public boolean isSupported() {
return true;
}
+
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/plugins/linux/build.xml b/plugins/linux/build.xml
index 0187a01..97ea608 100644
--- a/plugins/linux/build.xml
+++ b/plugins/linux/build.xml
@@ -12,7 +12,7 @@
<target depends="init" name="compile">
<!-- <ant dir="src/native" target="createNativeDefinitions.java"/>-->
- <javac debug="true" deprecation="true" destdir="classes" source="1.4" target="1.4" srcdir="src/java">
+ <javac debug="true" deprecation="true" destdir="classes" source="1.5" target="1.5" srcdir="src/java">
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
<pathelement location="../../lib/jutils.jar"/>
@@ -33,7 +33,7 @@
<mkdir dir="apidocs"/>
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
- additionalparam="-source 1.4"
+ additionalparam="-source 1.5"
link="../../../coreAPI/apidocs">
<sourcepath>
<pathelement location="src/java"/>
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
index 2f26a68..a8ea612 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
@@ -36,4 +36,7 @@ import java.util.ArrayList;
*/
interface LinuxDevice {
void close() throws IOException;
+ public String getName();
+ public String getFilename();
+
}
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 1a1a85c..fe6bfa8 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
@@ -25,8 +25,7 @@
*/
package net.java.games.input;
-import net.java.games.util.plugins.Plugin;
-
+// === java imports === //
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@@ -36,501 +35,613 @@ import java.io.File;
import java.io.FilenameFilter;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.HashMap;
+// === jinput imports === //
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.java.games.util.plugins.Plugin;
/** Environment plugin for linux
* @author elias
* @author Jeremy Booth ([email protected])
*/
public final class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
- private final static String LIBNAME = "jinput-linux";
- private final static String POSTFIX64BIT = "64";
- private static boolean supported = false;
-
- private final Controller[] controllers;
- private final List devices = new ArrayList();
- private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
-
- /**
- * Static utility method for loading native libraries.
- * It will try to load from either the path given by
- * the net.java.games.input.librarypath property
- * or through System.loadLibrary().
- *
- */
- static void loadLibrary(final String lib_name) {
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public final Object run() {
- String lib_path = System.getProperty("net.java.games.input.librarypath");
- try {
- if (lib_path != null)
- System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
- else
- System.loadLibrary(lib_name);
- } catch (UnsatisfiedLinkError e) {
- logln("Failed to load library: " + e.getMessage());
- e.printStackTrace();
- supported = false;
- }
- return null;
- }
- });
- }
-
- static String getPrivilegedProperty(final String property) {
- return (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property);
- }
- });
- }
-
-
- static String getPrivilegedProperty(final String property, final String default_value) {
- return (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property, default_value);
- }
- });
- }
-
- static {
- String osName = getPrivilegedProperty("os.name", "").trim();
- if(osName.equals("Linux")) {
- supported = true;
- if("i386".equals(getPrivilegedProperty("os.arch"))) {
- loadLibrary(LIBNAME);
- } else {
- loadLibrary(LIBNAME + POSTFIX64BIT);
- }
- }
- }
-
- public final static Object execute(LinuxDeviceTask task) throws IOException {
- return device_thread.execute(task);
- }
+// ============= Class variables ============== //
+ private final static String LIBNAME = "jinput-linux";
+ private final static String POSTFIX64BIT = "64";
+ private static boolean supported = false;
+ private List<Controller> controllers = new ArrayList<Controller>();
+ //private Controller[] controllers;
+ private List<LinuxDevice> devices = new ArrayList<LinuxDevice>();
+ private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
+ private HashMap<LinuxDevice,Controller> controllerDeviceMap = new HashMap<LinuxDevice,Controller>();
+// ============= Constructors ============== //
public LinuxEnvironmentPlugin() {
- if(isSupported()) {
- this.controllers = enumerateControllers();
- logln("Linux plugin claims to have found " + controllers.length + " controllers");
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public final Object run() {
- Runtime.getRuntime().addShutdownHook(new ShutdownHook());
- return null;
- }
- });
- } else {
- controllers = new Controller[0];
- }
+ Controller[] arrayControllers = scanControllers();
+ for(int i = 0; i < arrayControllers.length; i++){
+ controllers.add(arrayControllers[i]);
+ }
}
-
+// ============= Public Methods ============== //
/** Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
* @return Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
*/
public final Controller[] getControllers() {
- return controllers;
+ Controller[] ret = new Controller[controllers.size()];
+ int i = 0;
+ for(Controller controller:controllers){
+ ret[i] = controllers.get(i);
+ i++;
+ }
+ return ret;
}
-
- private final static Component[] createComponents(List event_components, LinuxEventDevice device) {
- LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
- List components = new ArrayList();
- for (int i = 0; i < event_components.size(); i++) {
- LinuxEventComponent event_component = (LinuxEventComponent)event_components.get(i);
- Component.Identifier identifier = event_component.getIdentifier();
-
- if (identifier == Component.Identifier.Axis.POV) {
- int native_code = event_component.getDescriptor().getCode();
- switch (native_code) {
- case NativeDefinitions.ABS_HAT0X:
- povs[0][0] = event_component;
- break;
- case NativeDefinitions.ABS_HAT0Y:
- povs[0][1] = event_component;
- break;
- case NativeDefinitions.ABS_HAT1X:
- povs[1][0] = event_component;
- break;
- case NativeDefinitions.ABS_HAT1Y:
- povs[1][1] = event_component;
- break;
- case NativeDefinitions.ABS_HAT2X:
- povs[2][0] = event_component;
- break;
- case NativeDefinitions.ABS_HAT2Y:
- povs[2][1] = event_component;
- break;
- case NativeDefinitions.ABS_HAT3X:
- povs[3][0] = event_component;
- break;
- case NativeDefinitions.ABS_HAT3Y:
- povs[3][1] = event_component;
- break;
- default:
- logln("Unknown POV instance: " + native_code);
- break;
- }
- } else if (identifier != null) {
- LinuxComponent component = new LinuxComponent(event_component);
- components.add(component);
- device.registerComponent(event_component.getDescriptor(), component);
- }
+ @Override
+ public Controller[] rescanControllers(){
+ Controller controllerArray[] = null;
+ if(isSupported()) {
+
+ List eventControllers = new ArrayList();
+ List jsControllers = new ArrayList();
+
+ for(Controller controller:controllers){
+ if(controller.getType() == Controller.Type.MOUSE ||
+ controller.getType() == Controller.Type.KEYBOARD){
+ eventControllers.add(controller);
+ }else{
+ jsControllers.add(controller);
}
- for (int i = 0; i < povs.length; i++) {
- LinuxEventComponent x = povs[i][0];
- LinuxEventComponent y = povs[i][1];
- if (x != null && y != null) {
- LinuxComponent controller_component = new LinuxPOV(x, y);
- components.add(controller_component);
- device.registerComponent(x.getDescriptor(), controller_component);
- device.registerComponent(y.getDescriptor(), controller_component);
- }
+ }
+ rescanEventControllers(eventControllers);
+ // TODO implment rescan joystick controllers
+ //enumerateJoystickControllers(jsControllers);
+
+ controllerArray = enumerateControllers(eventControllers, jsControllers);
+
+ //logln("Linux plugin claims to have found " + controllerArray.length + " controllers");
+ } else {
+ controllerArray = new Controller[0];
+ }
+ return controllerArray;
+ }
+
+
+// ============= Protected Methods ============== //
+// ============= Private Methods ============== //
+ private Controller[] scanControllers(){
+ Controller controllerArray[] = null;
+ if(isSupported()) {
+ controllerArray = enumerateControllers();
+ AccessController.doPrivileged( new PrivilegedAction() {
+ public final Object run() {
+ Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+ return null;
}
- Component[] components_array = new Component[components.size()];
- components.toArray(components_array);
- return components_array;
- }
-
- private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
- Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers());
- if (mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null)
- return mouse;
- else
- return null;
- }
-
- private final static Keyboard createKeyboardFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
- Keyboard keyboard = new LinuxKeyboard(device, components, new Controller[]{}, device.getRumblers());
- return keyboard;
- }
-
- private final static Controller createJoystickFromDevice(LinuxEventDevice device, Component[] components, Controller.Type type) throws IOException {
- Controller joystick = new LinuxAbstractController(device, components, new Controller[]{}, device.getRumblers(), type);
- return joystick;
- }
-
- private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException {
- List event_components = device.getComponents();
- Component[] components = createComponents(event_components, device);
- Controller.Type type = device.getType();
-
- if (type == Controller.Type.MOUSE) {
- return createMouseFromDevice(device, components);
- } else if (type == Controller.Type.KEYBOARD) {
- return createKeyboardFromDevice(device, components);
- } else if (type == Controller.Type.STICK || type == Controller.Type.GAMEPAD) {
- return createJoystickFromDevice(device, components, type);
- } else
- return null;
+ });
+ } else {
+ controllerArray = new Controller[0];
+ }
+ return controllerArray;
+ }
+
+ private final void enumerateEventControllers(List<Controller> controllers) {
+ final File dev = new File("/dev/input");
+ File[] event_device_files = listFilesPrivileged(dev, new FilenameFilter() {
+ public final boolean accept(File dir, String name) {
+ return name.startsWith("event");
+ }
+ });
+ if (event_device_files == null)
+ return;
+ for (int i = 0; i < event_device_files.length; i++) {
+ File event_file = event_device_files[i];
+ try {
+ String path = getAbsolutePathPrivileged(event_file);
+ LinuxEventDevice device = new LinuxEventDevice(path);
+ try {
+ Controller controller = createControllerFromDevice(device);
+ if (controller != null) {
+ controllers.add(controller);
+ controllerDeviceMap.put(device, controller);
+ devices.add(device);
+ } else
+ device.close();
+ } catch (IOException e) {
+ logln("Failed to create Controller: " + e.getMessage());
+ device.close();
+ }
+ } catch (IOException e) {
+ logln("Failed to open device (" + event_file + "): " + e.getMessage());
+ }
}
-
- private final Controller[] enumerateControllers() {
- List controllers = new ArrayList();
- 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--;
- break;
- }
- }
- }
+ }
+
+ private void rescanEventControllers(List<Controller> controllers){
+ final File dev = new File("/dev/input");
+ File[] event_device_files = listFilesPrivileged(dev, new FilenameFilter() {
+ public final boolean accept(File dir, String name) {
+ return name.startsWith("event");
+ }
+ });
+ if (event_device_files == null)
+ return;
+ for (int i = 0; i < event_device_files.length; i++) {
+ File event_file = event_device_files[i];
+
+ // check for new events
+ boolean isNewEvent = true;
+ for(LinuxDevice testDevice:devices){
+ if(event_file.getName().equals(testDevice.getFilename())){
+ isNewEvent = false;
+ break;
+ }
+ }
+
+ if(isNewEvent){
+ try {
+ String path = getAbsolutePathPrivileged(event_file);
+ LinuxEventDevice device = new LinuxEventDevice(path);
+ try {
+ Controller controller = createControllerFromDevice(device);
+ if (controller != null) {
+ controllers.add(controller);
+ devices.add(device);
+ controllerDeviceMap.put(device, controller);
+ } else {
+ device.close();
}
+ } catch (IOException e) {
+ logln("Failed to create Controller: " + e.getMessage());
+ device.close();
+ }
+ } catch (IOException e) {
+ logln("Failed to open device (" + event_file + "): " + e.getMessage());
}
- controllers.addAll(eventControllers);
- controllers.addAll(jsControllers);
-
- Controller[] controllers_array = new Controller[controllers.size()];
- controllers.toArray(controllers_array);
- return controllers_array;
+ }
}
-
- private final static Component.Identifier.Button getButtonIdentifier(int index) {
- switch (index) {
- case 0:
- return Component.Identifier.Button._0;
- case 1:
- return Component.Identifier.Button._1;
- case 2:
- return Component.Identifier.Button._2;
- case 3:
- return Component.Identifier.Button._3;
- case 4:
- return Component.Identifier.Button._4;
- case 5:
- return Component.Identifier.Button._5;
- case 6:
- return Component.Identifier.Button._6;
- case 7:
- return Component.Identifier.Button._7;
- case 8:
- return Component.Identifier.Button._8;
- case 9:
- return Component.Identifier.Button._9;
- case 10:
- return Component.Identifier.Button._10;
- case 11:
- return Component.Identifier.Button._11;
- case 12:
- return Component.Identifier.Button._12;
- case 13:
- return Component.Identifier.Button._13;
- case 14:
- return Component.Identifier.Button._14;
- case 15:
- return Component.Identifier.Button._15;
- case 16:
- return Component.Identifier.Button._16;
- case 17:
- return Component.Identifier.Button._17;
- case 18:
- return Component.Identifier.Button._18;
- case 19:
- return Component.Identifier.Button._19;
- case 20:
- return Component.Identifier.Button._20;
- case 21:
- return Component.Identifier.Button._21;
- case 22:
- return Component.Identifier.Button._22;
- case 23:
- return Component.Identifier.Button._23;
- case 24:
- return Component.Identifier.Button._24;
- case 25:
- return Component.Identifier.Button._25;
- case 26:
- return Component.Identifier.Button._26;
- case 27:
- return Component.Identifier.Button._27;
- case 28:
- return Component.Identifier.Button._28;
- case 29:
- return Component.Identifier.Button._29;
- case 30:
- return Component.Identifier.Button._30;
- case 31:
- return Component.Identifier.Button._31;
- default:
- return null;
+ // now check for a device that previous was connected and since has disconnected
+ ArrayList<LinuxDevice> removeDevices = new ArrayList<LinuxDevice>();
+ for(LinuxDevice testDevice:devices){
+ boolean fileExists = false;
+ for(int i = 0; i < event_device_files.length; i++){
+ File event_file = event_device_files[i];
+ if(testDevice.getFilename().equals(event_file.getName())){
+ fileExists = true;
+ break;
}
+ }
+ if(!fileExists){
+ removeDevices.add(testDevice);
+ }
+ }
+ for(LinuxDevice testDevice:removeDevices){
+ devices.remove(testDevice);
+ try {
+ testDevice.close();
+ } catch (IOException ex) { }
+ Controller controller = controllerDeviceMap.get(testDevice);
+ if(controller != null){
+ controllers.remove(controller);
+ this.controllers.remove(controller);
+ controllerDeviceMap.remove(testDevice);
+ }
}
+ }
- private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) {
- List components = new ArrayList();
- byte[] axisMap = device.getAxisMap();
- char[] buttonMap = device.getButtonMap();
- LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6];
-
- for (int i = 0; i < device.getNumButtons(); 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);
- components.add(button);
+ private final Controller[] enumerateControllers() {
+ List eventControllers = new ArrayList();
+ List jsControllers = new ArrayList();
+ enumerateEventControllers(eventControllers);
+ enumerateJoystickControllers(jsControllers);
+ return enumerateControllers(eventControllers,jsControllers);
+ }
+
+ private final Controller[] enumerateControllers(List<Controller>eventControllers, List<Controller>jsControllers) {
+
+ List localControllers = new ArrayList();
+
+ for(int i=0;i<eventControllers.size();i++) {
+ for(int j=0;j<jsControllers.size();j++) {
+ Controller evController = eventControllers.get(i);
+ Controller jsController = 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;
+ }
}
- }
- for (int i = 0; i < device.getNumAxes(); i++) {
- Component.Identifier.Axis axis_id;
- axis_id = (Component.Identifier.Axis) LinuxNativeTypesMap.getAbsAxisID(axisMap[i]);
- LinuxJoystickAxis axis = new LinuxJoystickAxis(axis_id);
- device.registerAxis(i, axis);
-
- if(axisMap[i]==NativeDefinitions.ABS_HAT0X) {
- hatBits[0] = axis;
- } else if(axisMap[i]==NativeDefinitions.ABS_HAT0Y) {
- hatBits[1] = axis;
- axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[0], hatBits[1]);
- device.registerPOV((LinuxJoystickPOV)axis);
- components.add(axis);
- } else if(axisMap[i]==NativeDefinitions.ABS_HAT1X) {
- hatBits[2] = axis;
- } else if(axisMap[i]==NativeDefinitions.ABS_HAT1Y) {
- hatBits[3] = axis;
- axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[2], hatBits[3]);
- device.registerPOV((LinuxJoystickPOV)axis);
- components.add(axis);
- } else if(axisMap[i]==NativeDefinitions.ABS_HAT2X) {
- hatBits[4] = axis;
- } else if(axisMap[i]==NativeDefinitions.ABS_HAT2Y) {
- hatBits[5] = axis;
- axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[4], hatBits[5]);
- device.registerPOV((LinuxJoystickPOV)axis);
- components.add(axis);
- } else {
- components.add(axis);
+ if(!foundADifference) {
+ localControllers.add(new LinuxCombinedController((LinuxAbstractController)eventControllers.remove(i), (LinuxJoystickAbstractController)jsControllers.remove(j)));
+ i--;
+ j--;
+ break;
}
+ }
}
-
- return new LinuxJoystickAbstractController(device, (Component[])components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{});
+ }
}
+ localControllers.addAll(eventControllers);
+ localControllers.addAll(jsControllers);
+
+ Controller[] controllers_array = new Controller[localControllers.size()];
+ localControllers.toArray(controllers_array);
+ return controllers_array;
+ }
+// ============= Implemented Methods ============== //
+// ============= Extended Methods ============== //
+// ============= Internal Classes ============== //
+// ============= Static Methods ============== //
- private final void enumerateJoystickControllers(List controllers) {
- File[] joystick_device_files = enumerateJoystickDeviceFiles("/dev/input");
- if (joystick_device_files == null || joystick_device_files.length == 0) {
- joystick_device_files = enumerateJoystickDeviceFiles("/dev");
- if (joystick_device_files == null)
- return;
+ /**
+ * Static utility method for loading native libraries.
+ * It will try to load from either the path given by
+ * the net.java.games.input.librarypath property
+ * or through System.loadLibrary().
+ *
+ */
+ static void loadLibrary(final String lib_name) {
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public final Object run() {
+ String lib_path = System.getProperty("net.java.games.input.librarypath");
+ try {
+ if (lib_path != null)
+ System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
+ else
+ System.loadLibrary(lib_name);
+ } catch (UnsatisfiedLinkError e) {
+ logln("Failed to load library: " + e.getMessage());
+ e.printStackTrace();
+ supported = false;
+ }
+ return null;
}
- for (int i = 0; i < joystick_device_files.length; i++) {
- File event_file = joystick_device_files[i];
- try {
- String path = getAbsolutePathPrivileged(event_file);
- LinuxJoystickDevice device = new LinuxJoystickDevice(path);
- Controller controller = createJoystickFromJoystickDevice(device);
- if (controller != null) {
- controllers.add(controller);
- devices.add(device);
- } else
- device.close();
- } catch (IOException e) {
- logln("Failed to open device (" + event_file + "): " + e.getMessage());
- }
+ }
+ );
+ }
+
+ static String getPrivilegedProperty(final String property) {
+ return (String)AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(property);
+ }
+ });
+ }
+
+
+ static String getPrivilegedProperty(final String property, final String default_value) {
+ return (String)AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(property, default_value);
+ }
+ });
+ }
+
+ static {
+ String osName = getPrivilegedProperty("os.name", "").trim();
+ if(osName.equals("Linux")) {
+ supported = true;
+ if("i386".equals(getPrivilegedProperty("os.arch"))) {
+ loadLibrary(LIBNAME);
+ } else {
+ loadLibrary(LIBNAME + POSTFIX64BIT);
+ }
+ }
+ }
+
+ public final static Object execute(LinuxDeviceTask task) throws IOException {
+ return device_thread.execute(task);
+ }
+
+
+
+ private final static Component[] createComponents(List event_components, LinuxEventDevice device) {
+ LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
+ List components = new ArrayList();
+ for (int i = 0; i < event_components.size(); i++) {
+ LinuxEventComponent event_component = (LinuxEventComponent)event_components.get(i);
+ Component.Identifier identifier = event_component.getIdentifier();
+
+ if (identifier == Component.Identifier.Axis.POV) {
+ int native_code = event_component.getDescriptor().getCode();
+ switch (native_code) {
+ case NativeDefinitions.ABS_HAT0X:
+ povs[0][0] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT0Y:
+ povs[0][1] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT1X:
+ povs[1][0] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT1Y:
+ povs[1][1] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT2X:
+ povs[2][0] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT2Y:
+ povs[2][1] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT3X:
+ povs[3][0] = event_component;
+ break;
+ case NativeDefinitions.ABS_HAT3Y:
+ povs[3][1] = event_component;
+ break;
+ default:
+ logln("Unknown POV instance: " + native_code);
+ break;
}
+ } else if (identifier != null) {
+ LinuxComponent component = new LinuxComponent(event_component);
+ components.add(component);
+ device.registerComponent(event_component.getDescriptor(), component);
+ }
}
+ for (int i = 0; i < povs.length; i++) {
+ LinuxEventComponent x = povs[i][0];
+ LinuxEventComponent y = povs[i][1];
+ if (x != null && y != null) {
+ LinuxComponent controller_component = new LinuxPOV(x, y);
+ components.add(controller_component);
+ device.registerComponent(x.getDescriptor(), controller_component);
+ device.registerComponent(y.getDescriptor(), controller_component);
+ }
+ }
+ Component[] components_array = new Component[components.size()];
+ components.toArray(components_array);
+ return components_array;
+ }
+
+ private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
+ Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers());
+ if (mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null)
+ return mouse;
+ else
+ return null;
+ }
+
+ private final static Keyboard createKeyboardFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
+ Keyboard keyboard = new LinuxKeyboard(device, components, new Controller[]{}, device.getRumblers());
+ return keyboard;
+ }
+
+ private final static Controller createJoystickFromDevice(LinuxEventDevice device, Component[] components, Controller.Type type) throws IOException {
+ Controller joystick = new LinuxAbstractController(device, components, new Controller[]{}, device.getRumblers(), type);
+ return joystick;
+ }
+
+ private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException {
+ List event_components = device.getComponents();
+ Component[] components = createComponents(event_components, device);
+ Controller.Type type = device.getType();
+
+ if (type == Controller.Type.MOUSE) {
+ return createMouseFromDevice(device, components);
+ } else if (type == Controller.Type.KEYBOARD) {
+ return createKeyboardFromDevice(device, components);
+ } else if (type == Controller.Type.STICK || type == Controller.Type.GAMEPAD) {
+ return createJoystickFromDevice(device, components, type);
+ } else
+ return null;
+ }
+
- private final static File[] enumerateJoystickDeviceFiles(final String dev_path) {
- final File dev = new File(dev_path);
- return listFilesPrivileged(dev, new FilenameFilter() {
- public final boolean accept(File dir, String name) {
- return name.startsWith("js");
- }
- });
+ private final static Component.Identifier.Button getButtonIdentifier(int index) {
+ switch (index) {
+ case 0:
+ return Component.Identifier.Button._0;
+ case 1:
+ return Component.Identifier.Button._1;
+ case 2:
+ return Component.Identifier.Button._2;
+ case 3:
+ return Component.Identifier.Button._3;
+ case 4:
+ return Component.Identifier.Button._4;
+ case 5:
+ return Component.Identifier.Button._5;
+ case 6:
+ return Component.Identifier.Button._6;
+ case 7:
+ return Component.Identifier.Button._7;
+ case 8:
+ return Component.Identifier.Button._8;
+ case 9:
+ return Component.Identifier.Button._9;
+ case 10:
+ return Component.Identifier.Button._10;
+ case 11:
+ return Component.Identifier.Button._11;
+ case 12:
+ return Component.Identifier.Button._12;
+ case 13:
+ return Component.Identifier.Button._13;
+ case 14:
+ return Component.Identifier.Button._14;
+ case 15:
+ return Component.Identifier.Button._15;
+ case 16:
+ return Component.Identifier.Button._16;
+ case 17:
+ return Component.Identifier.Button._17;
+ case 18:
+ return Component.Identifier.Button._18;
+ case 19:
+ return Component.Identifier.Button._19;
+ case 20:
+ return Component.Identifier.Button._20;
+ case 21:
+ return Component.Identifier.Button._21;
+ case 22:
+ return Component.Identifier.Button._22;
+ case 23:
+ return Component.Identifier.Button._23;
+ case 24:
+ return Component.Identifier.Button._24;
+ case 25:
+ return Component.Identifier.Button._25;
+ case 26:
+ return Component.Identifier.Button._26;
+ case 27:
+ return Component.Identifier.Button._27;
+ case 28:
+ return Component.Identifier.Button._28;
+ case 29:
+ return Component.Identifier.Button._29;
+ case 30:
+ return Component.Identifier.Button._30;
+ case 31:
+ return Component.Identifier.Button._31;
+ default:
+ return null;
}
+ }
- private static String getAbsolutePathPrivileged(final File file) {
- return (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return file.getAbsolutePath();
- }
- });
+ private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) {
+ List components = new ArrayList();
+ byte[] axisMap = device.getAxisMap();
+ char[] buttonMap = device.getButtonMap();
+ LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6];
+
+ for (int i = 0; i < device.getNumButtons(); 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);
+ components.add(button);
+ }
}
+ for (int i = 0; i < device.getNumAxes(); i++) {
+ Component.Identifier.Axis axis_id;
+ axis_id = (Component.Identifier.Axis) LinuxNativeTypesMap.getAbsAxisID(axisMap[i]);
+ LinuxJoystickAxis axis = new LinuxJoystickAxis(axis_id);
+
+ device.registerAxis(i, axis);
- private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) {
- return (File[])AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- File[] files = dir.listFiles(filter);
- Arrays.sort(files, new Comparator(){
- public int compare(Object f1, Object f2) {
- return ((File)f1).getName().compareTo(((File)f2).getName());
- }
- });
- return files;
- }
- });
+ if(axisMap[i]==NativeDefinitions.ABS_HAT0X) {
+ hatBits[0] = axis;
+ } else if(axisMap[i]==NativeDefinitions.ABS_HAT0Y) {
+ hatBits[1] = axis;
+ axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[0], hatBits[1]);
+ device.registerPOV((LinuxJoystickPOV)axis);
+ components.add(axis);
+ } else if(axisMap[i]==NativeDefinitions.ABS_HAT1X) {
+ hatBits[2] = axis;
+ } else if(axisMap[i]==NativeDefinitions.ABS_HAT1Y) {
+ hatBits[3] = axis;
+ axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[2], hatBits[3]);
+ device.registerPOV((LinuxJoystickPOV)axis);
+ components.add(axis);
+ } else if(axisMap[i]==NativeDefinitions.ABS_HAT2X) {
+ hatBits[4] = axis;
+ } else if(axisMap[i]==NativeDefinitions.ABS_HAT2Y) {
+ hatBits[5] = axis;
+ axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[4], hatBits[5]);
+ device.registerPOV((LinuxJoystickPOV)axis);
+ components.add(axis);
+ } else {
+ components.add(axis);
+ }
}
+
+ return new LinuxJoystickAbstractController(device, (Component[])components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{});
+ }
- private final void enumerateEventControllers(List controllers) {
- final File dev = new File("/dev/input");
- File[] event_device_files = listFilesPrivileged(dev, new FilenameFilter() {
- public final boolean accept(File dir, String name) {
- return name.startsWith("event");
- }
- });
- if (event_device_files == null)
- return;
- for (int i = 0; i < event_device_files.length; i++) {
- File event_file = event_device_files[i];
- try {
- String path = getAbsolutePathPrivileged(event_file);
- LinuxEventDevice device = new LinuxEventDevice(path);
- try {
- Controller controller = createControllerFromDevice(device);
- if (controller != null) {
- controllers.add(controller);
- devices.add(device);
- } else
- device.close();
- } catch (IOException e) {
- logln("Failed to create Controller: " + e.getMessage());
- device.close();
- }
- } catch (IOException e) {
- logln("Failed to open device (" + event_file + "): " + e.getMessage());
- }
- }
+ private final void enumerateJoystickControllers(List controllers) {
+ File[] joystick_device_files = enumerateJoystickDeviceFiles("/dev/input");
+ if (joystick_device_files == null || joystick_device_files.length == 0) {
+ joystick_device_files = enumerateJoystickDeviceFiles("/dev");
+ if (joystick_device_files == null)
+ return;
+ }
+ for (int i = 0; i < joystick_device_files.length; i++) {
+ File event_file = joystick_device_files[i];
+ try {
+ String path = getAbsolutePathPrivileged(event_file);
+ LinuxJoystickDevice device = new LinuxJoystickDevice(path);
+ Controller controller = createJoystickFromJoystickDevice(device);
+ if (controller != null) {
+ controllers.add(controller);
+ devices.add(device);
+ controllerDeviceMap.put(device, controller);
+ } else
+ device.close();
+ } catch (IOException e) {
+ logln("Failed to open device (" + event_file + "): " + e.getMessage());
+ }
+ }
}
- /**
- * Attempt to find devices using uinput used for forwarding events.
- * TODO try to work this out!
- */
- /*
- private final void enumerateUInputControllers(List controllers) {
- final File dev = new File("/dev/uinput");
- File[] event_device_files = listFilesPrivileged(dev, new FilenameFilter() {
- public final boolean accept(File dir, String name) {
- return name.startsWith("event");
- }
+ private final static File[] enumerateJoystickDeviceFiles(final String dev_path) {
+ final File dev = new File(dev_path);
+ return listFilesPrivileged(dev, new FilenameFilter() {
+ public final boolean accept(File dir, String name) {
+ return name.startsWith("js");
+ }
+ });
+ }
+
+ private static String getAbsolutePathPrivileged(final File file) {
+ return (String)AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return file.getAbsolutePath();
+ }
+ });
+ }
+
+ private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) {
+ return (File[])AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ File[] files = dir.listFiles(filter);
+ Arrays.sort(files, new Comparator(){
+ public int compare(Object f1, Object f2) {
+ return ((File)f1).getName().compareTo(((File)f2).getName());
+ }
});
- if (event_device_files == null)
- return;
- for (int i = 0; i < event_device_files.length; i++) {
- File event_file = event_device_files[i];
- try {
- String path = getAbsolutePathPrivileged(event_file);
- LinuxEventDevice device = new LinuxEventDevice(path);
- try {
- Controller controller = createControllerFromDevice(device);
- if (controller != null) {
- controllers.add(controller);
- devices.add(device);
- } else
- device.close();
- } catch (IOException e) {
- logln("Failed to create Controller: " + e.getMessage());
- device.close();
- }
- } catch (IOException e) {
- logln("Failed to open device (" + event_file + "): " + e.getMessage());
- }
- }
+ return files;
+ }
+ });
}
- */
-
- private final class ShutdownHook extends Thread {
- public final void run() {
- for (int i = 0; i < devices.size(); i++) {
- try {
- LinuxDevice device = (LinuxDevice)devices.get(i);
- device.close();
- } catch (IOException e) {
- logln("Failed to close device: " + e.getMessage());
- }
- }
+
+
+
+ private final class ShutdownHook extends Thread {
+ public final void run() {
+ for (int i = 0; i < devices.size(); i++) {
+ try {
+ LinuxDevice device = (LinuxDevice)devices.get(i);
+ device.close();
+ } catch (IOException e) {
+ logln("Failed to close device: " + e.getMessage());
}
+ }
}
+ }
- public boolean isSupported() {
- return supported;
- }
+ public boolean isSupported() {
+ return supported;
+ }
}
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 noexpandtab
+ */
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java
index 1517147..79b7707 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxEventDevice.java
@@ -25,6 +25,7 @@
*/
package net.java.games.input;
+import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
@@ -52,6 +53,7 @@ final class LinuxEventDevice implements LinuxDevice {
* it doesn't hurt to have multiple threads read/write from/to it
*/
private final byte[] key_states = new byte[NativeDefinitions.KEY_MAX/8 + 1];
+ private String filename;
public LinuxEventDevice(String filename) throws IOException {
long fd;
@@ -76,6 +78,8 @@ final class LinuxEventDevice implements LinuxDevice {
close();
throw e;
}
+ File file = new File(filename);
+ this.filename = file.getName();
}
private final static native long nOpen(String filename, boolean rw) throws IOException;
@@ -336,6 +340,9 @@ final class LinuxEventDevice implements LinuxDevice {
public final String getName() {
return name;
}
+ public String getFilename(){
+ return filename;
+ }
private final String getDeviceName() throws IOException {
return nGetName(fd);
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxJoystickDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxJoystickDevice.java
index 0dcd5da..6b45d4a 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxJoystickDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxJoystickDevice.java
@@ -236,4 +236,9 @@ final class LinuxJoystickDevice implements LinuxDevice {
protected void finalize() throws IOException {
close();
}
+
+ @Override
+ public String getFilename() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/plugins/windows/build.xml b/plugins/windows/build.xml
index a10d7cb..39435a1 100644
--- a/plugins/windows/build.xml
+++ b/plugins/windows/build.xml
@@ -9,7 +9,7 @@
</target>
<target name="compile" depends="init">
- <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
+ <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.5" target="1.5">
<!-- To add something to the classpath: -->
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
@@ -66,7 +66,7 @@
<mkdir dir="apidocs"/>
<javadoc packagenames="net.*"
destdir="apidocs"
- additionalparam="-source 1.4">
+ additionalparam="-source 1.5">
<sourcepath>
<pathelement location="src/java"/>
</sourcepath>
diff --git a/plugins/windows/src/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java b/plugins/windows/src/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java
index c789986..dfd3b22 100644
--- a/plugins/windows/src/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java
+++ b/plugins/windows/src/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java
@@ -91,4 +91,9 @@ public class DirectAndRawInputEnvironmentPlugin extends ControllerEnvironment {
return rawPlugin.isSupported() || dinputPlugin.isSupported();
}
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
}
diff --git a/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java b/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
index deb53c3..35253f4 100644
--- a/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
+++ b/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
@@ -235,6 +235,11 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im
return controllers_array;
}
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
private final class ShutdownHook extends Thread {
public final void run() {
/* Release the devices to kill off active force feedback effects */
diff --git a/plugins/windows/src/java/net/java/games/input/RawInputEnvironmentPlugin.java b/plugins/windows/src/java/net/java/games/input/RawInputEnvironmentPlugin.java
index 36f089b..0da3180 100644
--- a/plugins/windows/src/java/net/java/games/input/RawInputEnvironmentPlugin.java
+++ b/plugins/windows/src/java/net/java/games/input/RawInputEnvironmentPlugin.java
@@ -213,4 +213,9 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple
private final static native byte[] getKeyboardClassGUID();
private final static native byte[] getMouseClassGUID();
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
} // class DirectInputEnvironment
diff --git a/plugins/wintab/build.xml b/plugins/wintab/build.xml
index 6e47c64..b444ed3 100644
--- a/plugins/wintab/build.xml
+++ b/plugins/wintab/build.xml
@@ -9,11 +9,11 @@
</target>
<target name="compile" depends="init">
- <javac srcdir="../windows/src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
+ <javac srcdir="../windows/src/java" destdir="classes" debug="true" deprecation="true" source="1.5" target="1.5">
<include name="**/DummyWindow.java"/>
</javac>
- <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
+ <javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.5" target="1.5">
<!-- To add something to the classpath: -->
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
@@ -55,7 +55,7 @@
<mkdir dir="apidocs"/>
<javadoc packagenames="net.*"
destdir="apidocs"
- additionalparam="-source 1.4">
+ additionalparam="-source 1.5">
<sourcepath>
<pathelement location="src/java"/>
</sourcepath>
diff --git a/plugins/wintab/src/java/net/java/games/input/WinTabEnvironmentPlugin.java b/plugins/wintab/src/java/net/java/games/input/WinTabEnvironmentPlugin.java
index a770ff9..4034336 100644
--- a/plugins/wintab/src/java/net/java/games/input/WinTabEnvironmentPlugin.java
+++ b/plugins/wintab/src/java/net/java/games/input/WinTabEnvironmentPlugin.java
@@ -134,6 +134,11 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl
return controllers;
}
+ @Override
+ public Controller[] rescanControllers() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
private final class ShutdownHook extends Thread {
public final void run() {
/* Release the devices to kill off active force feedback effects */