summaryrefslogtreecommitdiffstats
path: root/plugins/linux/src
diff options
context:
space:
mode:
authorendolf <[email protected]>2005-08-28 21:12:29 +0000
committerendolf <[email protected]>2005-08-28 21:12:29 +0000
commit0e73adaf789cc2edcfd7d746372fbbca1af5b735 (patch)
tree93887b29f3c0288b56f36f4b2e872b90befb2346 /plugins/linux/src
parent2f03e66005b873a47d3c1532453f8f50f9405feb (diff)
More testing
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/branches/forcefeedback@117 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins/linux/src')
-rw-r--r--plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java53
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java6
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java29
-rw-r--r--plugins/linux/src/native/EventDevice.cpp3
4 files changed, 79 insertions, 12 deletions
diff --git a/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java b/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java
index 5bf5e6a..85d0962 100644
--- a/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java
+++ b/plugins/linux/src/java/net/java/games/input/EventInterfaceTest.java
@@ -1,12 +1,43 @@
package net.java.games.input;
+import java.util.ArrayList;
+
public class EventInterfaceTest {
- public static void main(String args[]) {
- EventInterface.eventInit();
- int numDevices = EventInterface.getNumDevices();
+ public EventInterfaceTest() {
+ //EventInterface.eventInit();
+ //int numDevices = EventInterface.getNumDevices();
+
+ Controller[] controllers = DefaultControllerEnvironment.getDefaultEnvironment().getControllers();
+ ArrayList rumblers = new ArrayList();
+
+ for(int i=0;i<controllers.length;i++) {
+ Rumbler[] tempRumblers = controllers[i].getRumblers();
+ for (int j=0;j<tempRumblers.length;j++) {
+ rumblers.add(tempRumblers[j]);
+ }
+ }
- for(int i=0;i<numDevices;i++) {
+ for(int i=0;i<rumblers.size();i++) {
+ Rumbler rumbler = (Rumbler)rumblers.get(i);
+ rumbler.getAxisName();
+ rumbler.rumble(1f);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ rumbler.rumble(0f);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /*for(int i=0;i<numDevices;i++) {
System.out.println("Device name: " + EventInterface.getName(i));
if(EventInterface.getFFEnabled(i)) {
try {
@@ -35,7 +66,7 @@ public class EventInterfaceTest {
int absAxisData[] = new int[numAbsAxis];
int relAxisData[] = new int[numRelAxis];
int buttonData[] = new int[numButtons];
- EventInterface.getPolledData(i, relAxisData, absAxisData, buttonData);
+ //EventInterface.getPolledData(i, relAxisData, absAxisData, buttonData);
EventInterface.rumble(i,0.2f);
Thread.sleep(1000);
@@ -46,7 +77,17 @@ public class EventInterfaceTest {
}
}
- }
+ }*/
+
+ /*for(int i=0;i<EventInterface.getNumDevices();i++) {
+ EventInterface.cleanup(i);
+ }*/
+
+ LinuxEnvironmentPlugin.cleanup();
+ }
+
+ public static void main(String args[]) {
+ new EventInterfaceTest();
}
}
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 b1d15dc..f9889c1 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
@@ -34,11 +34,5 @@ public class LinuxDeviceRumbler implements Rumbler {
private void cleanup() {
System.out.println("LinuxDeviceRumbler.cleanup");
rumble(0f);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- //ignore
- }
- EventInterface.cleanup(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 a8646a8..017773d 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java
@@ -39,6 +39,12 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu
/** Creates a new instance of LinuxEnvironmentPlugin */
public LinuxEnvironmentPlugin() {
if(isSupported()) {
+ Runtime.runFinalizersOnExit(true);
+ /*Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ cleanup();
+ }
+ });*/
LinuxNativeTypesMap.init();
EventInterface.eventInit();
createControllers();
@@ -146,5 +152,28 @@ public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plu
}
return device;
}
+
+ public static void cleanup() {
+ //Give the rumblers chance to cleanup
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println("Environment cleanup");
+ for(int i=0;i<EventInterface.getNumDevices();i++) {
+ EventInterface.cleanup(i);
+ }
+ }
+
+ protected void finalize() throws Throwable {
+ // TODO Auto-generated method stub
+ System.out.println("Environment finalize");
+ for(int i=0;i<EventInterface.getNumDevices();i++) {
+ EventInterface.cleanup(i);
+ }
+ super.finalize();
+ }
}
diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp
index 71779cc..b6f8aeb 100644
--- a/plugins/linux/src/native/EventDevice.cpp
+++ b/plugins/linux/src/native/EventDevice.cpp
@@ -384,6 +384,9 @@ int EventDevice::poll(){
//printf("abs axis %d translates to abs axis %d on this device\n", events[i].code, axisIndex);
break;
}
+ case EV_FF:
+ LOG_TRACE("Got event EV_FF code %d value %d\n",events[i].code, events[i].value);
+ break;
case EV_LED:
// reveiced for things like numlock led change
break;