aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorendolf <[email protected]>2005-07-16 13:07:45 +0000
committerendolf <[email protected]>2005-07-16 13:07:45 +0000
commitd85221f6061b39249b11b26744c1eac1a65a4a45 (patch)
tree952a7e8831b94aebcb26855093f09d8dfd79cf69
parent0148692068637a1e39beb01728c96f7f548381d1 (diff)
Couple if inux rumbler differences, including including the added file
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@105 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java29
-rw-r--r--plugins/linux/src/native/EventDevice.cpp25
2 files changed, 45 insertions, 9 deletions
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
new file mode 100644
index 0000000..5c704a9
--- /dev/null
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDeviceRumbler.java
@@ -0,0 +1,29 @@
+package net.java.games.input;
+
+import net.java.games.input.Component.Identifier;
+
+public class LinuxDeviceRumbler implements Rumbler {
+
+ private int deviceID;
+
+ public LinuxDeviceRumbler(int deviceID) {
+ this.deviceID = deviceID;
+ }
+
+ public void rumble(float intensity) {
+ // TODO Auto-generated method stub
+ nativeRumble(deviceID, intensity);
+ }
+
+ public String getAxisName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Identifier getAxisIdentifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private native void nativeRumble(int deviceID, float intensity);
+}
diff --git a/plugins/linux/src/native/EventDevice.cpp b/plugins/linux/src/native/EventDevice.cpp
index e5430c5..ff2a1d9 100644
--- a/plugins/linux/src/native/EventDevice.cpp
+++ b/plugins/linux/src/native/EventDevice.cpp
@@ -414,26 +414,37 @@ bool EventDevice::getFFEnabled() {
void EventDevice::rumble(float force) {
if(force>1) force=1;
if(force<-1) force=-1;
- LOG_TRACE("Rumbling at %d%%, (shh, pretend)\n", (int)(force*100));
+ //LOG_TRACE("Rumbling at %d%%, (shh, pretend)\n", (int)(force*100));
if(effect_playing==true) {
stop.type=EV_FF;
stop.code = effect.id;
stop.value=0;
- if (ioctl(fd, EVIOCRMFF, effect.id) == -1) {
+ LOG_TRACE("Removing effect %d\n", effect.id);
+ if (ioctl(fd, EVIOCRMFF, &effect) == -1) {
perror("Remove effect");
}
+ } else {
+ effect.id=-1;
}
effect.type=FF_RUMBLE;
- effect.id=-1;
+ //effect.id=-1;
effect.u.rumble.strong_magnitude = (int)(0x8000*force);
effect.u.rumble.weak_magnitude = (int)(0xc000*force);
- effect.replay.length = 5000;
+ effect.replay.length = 15000;
effect.replay.delay = 0;
+ if(effect_playing==true) {
+ LOG_TRACE("Stoping %d\n", stop.code);
+ if (write(fd, (const void*) &stop, sizeof(stop)) == -1) {
+ perror("Failed to stop effect");
+ }
+ effect_playing=false;
+ }
+ LOG_TRACE("Uploading effect %d\n", effect.id);
if (ioctl(fd, EVIOCSFF, &effect) == -1) {
perror("Upload effect");
}
@@ -442,11 +453,7 @@ void EventDevice::rumble(float force) {
play.code=effect.id;
play.value=1;
- if(effect_playing==true) {
- if (write(fd, (const void*) &stop, sizeof(stop)) == -1) {
- perror("Failed to stop effect");
- }
- }
+ LOG_TRACE("Playing effect %d\n", play.code);
if (write(fd, (const void*) &play, sizeof(play)) == -1) {
perror("Failed to play effect");
} else {