Couple if inux rumbler differences, including including the added file

This commit is contained in:
endolf 2005-07-16 13:07:45 +00:00
parent df432c29ae
commit d4c72ba15c
2 changed files with 45 additions and 9 deletions

View file

@ -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);
}

View file

@ -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 {