Handle "--trigger-as-button" option from xboxdrv

This commit is contained in:
admiralmachado
2014-03-11 21:13:12 +01:00
committed by Iwan Timmer
parent d61532799a
commit 161175b866
3 changed files with 15 additions and 5 deletions

View File

@@ -150,6 +150,8 @@ public class EvdevConstants {
public static final short ABS_THROTTLE = 0x06;
public static final short ABS_RUDDER = 0x07;
public static final short BTN_THROTTLE = 311;
public static final short BTN_RUDDER = 312;
public static final short BTN_SOUTH = 0x130;
public static final short BTN_EAST = 0x131;

View File

@@ -135,11 +135,17 @@ public class EvdevHandler implements Runnable {
conn.sendMouseButtonDown(mouseButton);
else if (value==EvdevConstants.KEY_RELEASED)
conn.sendMouseButtonUp(mouseButton);
} else if (gamepadButton>0) {
if (value==EvdevConstants.KEY_PRESSED) {
buttonFlags |= gamepadButton;
} else if (value==EvdevConstants.KEY_RELEASED){
buttonFlags &= ~gamepadButton;
} else {
if (gamepadButton != 0) {
if (value==EvdevConstants.KEY_PRESSED) {
buttonFlags |= gamepadButton;
} else if (value==EvdevConstants.KEY_RELEASED){
buttonFlags &= ~gamepadButton;
}
} else if (code==mapping.btn_throttle) {
leftTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
} else if (code==mapping.btn_rudder) {
rightTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
}
conn.sendControllerInput(buttonFlags, leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY);
}

View File

@@ -23,6 +23,8 @@ public class GamepadMapping {
public short abs_throttle = EvdevConstants.ABS_THROTTLE;
public short abs_rudder = EvdevConstants.ABS_RUDDER;
public short btn_throttle = EvdevConstants.BTN_THROTTLE;
public short btn_rudder = EvdevConstants.BTN_RUDDER;
public boolean reverse_x, reverse_y;
public boolean reverse_rx, reverse_ry;