aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/linux/src/java
diff options
context:
space:
mode:
authorendolf <[email protected]>2005-08-30 19:37:53 +0000
committerendolf <[email protected]>2005-08-30 19:37:53 +0000
commit321ce0606e9c9178010fd50a96017ca6437a486c (patch)
tree202703cf9b800371b14009cba6e775dac623bea4 /plugins/linux/src/java
parent47321b68065397cba6e520c139c39af4e8fe8fcc (diff)
Unless cleanup is called from the same thread as init, the cleanup
doesn't happen properly and events are left of the ff device meaning we run out of device space. Added a thread that init and cleanup are called from via methods on the interface. Then it became apparent that rumble would only work from the same thread as the others too, so thats added in there. Nastyness all round. git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@120 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins/linux/src/java')
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDevice.java71
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java8
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java65
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java22
4 files changed, 24 insertions, 142 deletions
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 228886e..a475643 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
@@ -112,7 +112,7 @@ public class LinuxDevice extends AbstractController {
this.nativeID = nativeID;
- portType = LinuxNativeTypesMap.getPortType(getNativePortType(nativeID));
+ portType = LinuxNativeTypesMap.getPortType(JInputLibrary.getNativePortType(nativeID));
for(int i=0;i<8;i++) {
hatAxisIDs[i] = -1;
@@ -493,7 +493,7 @@ public class LinuxDevice extends AbstractController {
* @return false if the controller is no longer valid.
*/
public boolean poll() {
- int retval = nativePoll(nativeID, buttonData, relAxesData, absAxesData);
+ int retval = JInputLibrary.poll(nativeID, buttonData, relAxesData, absAxesData);
if(retval>=0) return true;
return false;
}
@@ -532,7 +532,7 @@ public class LinuxDevice extends AbstractController {
* @return The axis fuzz.
*/
public float getAbsAxisFuzz(int axisID) {
- return (float) getNativeAbsAxisFuzz(nativeID, axisID);
+ return (float) JInputLibrary.getAbsAxisFuzz(nativeID, axisID);
}
/**
@@ -541,7 +541,7 @@ public class LinuxDevice extends AbstractController {
* @return The maximum value
*/
public float getAbsAxisMaximum(int axisID) {
- return (float) getNativeAbsAxisMaximum(nativeID, axisID);
+ return (float) JInputLibrary.getAbsAxisMaximum(nativeID, axisID);
}
/**
@@ -550,7 +550,7 @@ public class LinuxDevice extends AbstractController {
* @return The minimum axis value
*/
public float getAbsAxisMinimum(int axisID) {
- return (float) getNativeAbsAxisMinimum(nativeID, axisID);
+ return (float) JInputLibrary.getAbsAxisMinimum(nativeID, axisID);
}
/** Return the enumeration of supported button types for this device
@@ -560,83 +560,30 @@ public class LinuxDevice extends AbstractController {
if(supportedButtons.length==0) {
return;
}
- getNativeSupportedButtons(nativeID, supportedButtons);
+ JInputLibrary.getSupportedButtons(nativeID, supportedButtons);
}
/** Return the enumeration of supported absolute axis types for this device
* @param suportedAbsAxes The array to populate
*/
private void getSupportedAbsAxes(int suportedAbsAxes[]) {
- getNativeSupportedAbsAxes(nativeID, suportedAbsAxes);
+ JInputLibrary.getSupportedAbsAxes(nativeID, suportedAbsAxes);
}
/** Return the enumeration of supported relative axis types for this device
* @param supportedRelAxes The array to populate
*/
private void getSupportedRelAxes(int supportedRelAxes[]) {
- getNativeSupportedRelAxes(nativeID, supportedRelAxes);
+ JInputLibrary.getSupportedRelAxes(nativeID, supportedRelAxes);
}
/** Returns the status of FF support for this device
*
*/
private boolean getFFEnabled() {
- return getNativeFFEnabled(nativeID);
+ return JInputLibrary.getFFEnabled(nativeID);
}
- /** Native call to get the supported absolute axes for a device
- * @param deviceID The native device number
- * @param supportedAbsAxes aray to populate
- */
- private native void getNativeSupportedAbsAxes(int deviceID, int supportedAbsAxes[]);
- /** Native call to get the supported relative axes for a device
- * @param deviceID The native device ID
- * @param supportedRelAxes the array to populate
- */
- private native void getNativeSupportedRelAxes(int deviceID, int supportedRelAxes[]);
- /** Native call to get the supported buttons for a device
- * @param deviceID The native device ID
- * @param supportedButtons The array to populate
- */
- private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]);
- /** Call to poll the device at the native library
- * @param deviceID The native device ID
- * @param buttonData Array to populate with button values
- * @param relAxesData Array to populate with relative axes values
- * @param absAxesData Array to populate with absolute axes values
- * @return the number of events read
- */
- private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]);
- /** Returns the fuzz of an axis fro mthe native lib
- * @param deviceID The native device id
- * @param axisID The native axis ID
- * @return The fuzz
- */
- private native int getNativeAbsAxisFuzz(int deviceID, int axisID);
- /** Gets the maximum value for an absloute axis fr omthe native library
- * @param deviceID The native device ID
- * @param axisID The native axis ID
- * @return The Max value
- */
- private native int getNativeAbsAxisMaximum(int deviceID, int axisID);
- /** Gets the minimum value for an absloute axis from the native library
- * @param deviceID The native device ID
- * @param axisID The native axis number
- * @return The min value
- */
- private native int getNativeAbsAxisMinimum(int deviceID, int axisID);
- /** Gets the port type from the native lib
- * @param deviceID The device to get the port type for
- * @return The port type
- */
- private native int getNativePortType(int deviceID);
-
- /** Gets the status of FF support for this device
- * @param deviceID The device to get the port type for
- * @return The port type
- */
- private native boolean getNativeFFEnabled(int deviceID);
-
/**
* A device that represents a joystick coolie hat.
* @author Jeremy Booth ([email protected])
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
index 48d0502..4f28f1c 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
@@ -18,7 +18,7 @@ public class LinuxDeviceRumbler implements Rumbler {
public void rumble(float intensity) {
// TODO Auto-generated method stub
- nativeRumble(deviceID, intensity);
+ JInputLibrary.rumble(deviceID, intensity);
}
public String getAxisName() {
@@ -32,11 +32,7 @@ public class LinuxDeviceRumbler implements Rumbler {
}
private void cleanup() {
- nativeCleanup(deviceID);
+ rumble(0f);
}
- private native void nativeRumble(int deviceID, float intensity);
-
- private native void nativeCleanup(int deviceID);
-
}
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 fc19780..4dcb27f 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
@@ -32,37 +32,21 @@ import net.java.games.util.plugins.Plugin;
*/
public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
- static {
- if(isSupported()) {
- System.loadLibrary("jinput-linux");
- }
- }
-
/** List of controllers
*/
private Controller[] controllers;
/** Creates a new instance of LinuxEnvironmentPlugin */
public LinuxEnvironmentPlugin() {
- if(isSupported()) {
- LinuxNativeTypesMap.init();
- init();
+ if(JInputLibrary.isSupported()) {
+ LinuxNativeTypesMap.init();
+ JInputLibrary.init();
createControllers();
} else {
controllers = new Controller[0];
}
}
- public static boolean isSupported() {
- System.out.println("OS name is: " + System.getProperty("os.name"));
- if(System.getProperty("os.name").indexOf("Linux")!=-1) {
- System.out.println("Linux plugin is supported");
- return true;
- }
- System.out.println("Linux plugin is not supported");
- return false;
- }
-
/** 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,
@@ -75,7 +59,7 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu
/** Create the controllers
*/
private void createControllers() {
- int numDevices = getNumberOfDevices();
+ int numDevices = JInputLibrary.getNumberOfDevices();
Controller[] tempControllers = new Controller[numDevices];
@@ -102,13 +86,15 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu
* @param deviceNumber The device ID
* @return The new device
*/
- private Controller createDevice(int deviceNumber) {
- String name = getDeviceName(deviceNumber);
- int numAbsAxes = getNumAbsAxes(deviceNumber);
- int numRelAxes = getNumRelAxes(deviceNumber);
- int numButtons = getNumButtons(deviceNumber);
+ private Controller createDevice(int deviceNumber) {
+ String name = JInputLibrary.getDeviceName(deviceNumber);
+ int numAbsAxes = JInputLibrary.getNumAbsAxes(deviceNumber);
+ int numRelAxes = JInputLibrary.getNumRelAxes(deviceNumber);
+ int numButtons = JInputLibrary.getNumButtons(deviceNumber);
Controller device = null;
+ System.out.println("Java working on device " + name);
+
int mouseCharacteristic = 0;
int keyboardCharacteristic = 0;
int joystickCharacteristic = 0;
@@ -153,33 +139,4 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu
return device;
}
- /** Get the name of a device from the native library
- * @param deviceID The device id
- * @return The devices name
- */
- private native String getDeviceName(int deviceID);
- /** Get the number of absolute axes for the requested device
- * @param deviceID The device ID
- * @return The number of abs axes
- */
- private native int getNumAbsAxes(int deviceID);
- /** Get the nmber or relative axes from the native library
- * @param deviceID The native device ID
- * @return The number of raltive axes for the device
- */
- private native int getNumRelAxes(int deviceID);
- /** Gets the number of buttons for the requested devce from the native library
- * @param deviceID The device ID
- * @return The number of buttons
- */
- private native int getNumButtons(int deviceID);
- /** Initialises the native library
- * @return <0 if something went wrong
- */
- private native int init();
- /** Gets the number of devices the native library found
- * @return Th number of devices
- */
- private native int getNumberOfDevices();
-
}
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
index f6533bd..7c16343 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
@@ -115,7 +115,7 @@ public class LinuxKeyboard extends StandardKeyboard {
* @return False if this device is invalid.
*/
public boolean poll() {
- int retval = nativePoll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData);
+ int retval = JInputLibrary.poll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData);
if(retval>=0) return true;
return false;
}
@@ -169,25 +169,7 @@ public class LinuxKeyboard extends StandardKeyboard {
* @param supportedButtons The array if key types to populate
*/
private void getSupportedButtons(int supportedButtons[]) {
- getNativeSupportedButtons(nativeID, supportedButtons);
+ JInputLibrary.getSupportedButtons(nativeID, supportedButtons);
}
- /** Gets the supported key types for a particular native device
- * @param deviceID The device ID
- * @param supportedButtons The array to populate with teh supported key ids
- */
- private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]);
- /** Calls the native library to poll the device
- * @param deviceID The device ID
- * @param buttonData Aray to populate with button values
- * @param relAxesData Array to populate with relative axis values
- * @param absAxesData Array to populate with absolute axes values
- * @return <0 if soething went wrong
- */
- private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]);
- /** Gets the port type from the native library for a particular keyboard
- * @param deviceID The keybaord id
- * @return native port ype
- */
- private native int getNativePortType(int deviceID);
}