Rename throttle and rudder to z and rz

This commit is contained in:
Iwan Timmer
2014-04-10 16:30:38 +02:00
parent 94a8fed2f1
commit 16badc4f99
4 changed files with 21 additions and 25 deletions

View File

@@ -1,25 +1,22 @@
abs_x = 0
abs_y = 1
abs_z = 2
abs_rx = 3
abs_ry = 4
abs_rz = 5
abs_deadzone = 0
abs_dpad_y = 16
abs_dpad_x = 17
abs_throttle = 6
abs_rudder = 7
btn_throttle = 312
btn_rudder = 313
reverse_x = false
reverse_y = false
reverse_rx = false
reverse_ry = false
reverse_dpad_y = false
reverse_dpad_x = false
reverse_throttle = false
reverse_rudder = false
reverse_z = false
reverse_rz = false
btn_south = 304
btn_east = 305
@@ -33,6 +30,8 @@ btn_thumbl = 317
btn_thumbr = 318
btn_tl = 310
btn_tr = 311
btn_tl2 = 312
btn_tr2 = 313
btn_dpad_up = 544
btn_dpad_down = 545

View File

@@ -145,23 +145,19 @@ public class EvdevConstants {
/* Gamepad constants */
public static final short ABS_X = 0x00;
public static final short ABS_Y = 0x01;
public static final short ABS_Z = 0x02;
public static final short ABS_RX = 0x03;
public static final short ABS_RY = 0x04;
public static final short ABS_RZ = 0x05;
public static final short ABS_HAT0X = 0x10;
public static final short ABS_HAT0Y = 0x11;
public static final short ABS_THROTTLE = 0x06;
public static final short ABS_RUDDER = 0x07;
public static final short BTN_SOUTH = 0x130;
public static final short BTN_EAST = 0x131;
public static final short BTN_NORTH = 0x133;
public static final short BTN_WEST = 0x134;
public static final short BTN_THROTTLE = 0x137;
public static final short BTN_RUDDER = 0x138;
public static final short BTN_SELECT = 0x13a;
public static final short BTN_START = 0x13b;
public static final short BTN_MODE = 0x13c;
@@ -169,6 +165,8 @@ public class EvdevConstants {
public static final short BTN_THUMBR = 0x13e;
public static final short BTN_TL = 0x136;
public static final short BTN_TR = 0x137;
public static final short BTN_TL2 = 0x138;
public static final short BTN_TR2 = 0x139;
public static final short BTN_DPAD_UP = 0x220;
public static final short BTN_DPAD_DOWN = 0x221;

View File

@@ -55,8 +55,8 @@ public class EvdevHandler implements Runnable {
absLY = new EvdevAbsolute(device, mapping.abs_y, !mapping.reverse_y);
absRX = new EvdevAbsolute(device, mapping.abs_rx, mapping.reverse_rx);
absRY = new EvdevAbsolute(device, mapping.abs_ry, !mapping.reverse_ry);
absLT = new EvdevAbsolute(device, mapping.abs_rudder, mapping.reverse_rudder);
absRT = new EvdevAbsolute(device, mapping.abs_throttle, mapping.reverse_throttle);
absLT = new EvdevAbsolute(device, mapping.abs_z, mapping.reverse_z);
absRT = new EvdevAbsolute(device, mapping.abs_rz, mapping.reverse_rz);
absDX = new EvdevAbsolute(device, mapping.abs_dpad_x, mapping.reverse_dpad_x);
absDY = new EvdevAbsolute(device, mapping.abs_dpad_y, mapping.reverse_dpad_y);
@@ -143,9 +143,9 @@ public class EvdevHandler implements Runnable {
} else if (value==EvdevConstants.KEY_RELEASED){
buttonFlags &= ~gamepadButton;
}
} else if (code==mapping.btn_throttle) {
} else if (code==mapping.btn_tl2) {
leftTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
} else if (code==mapping.btn_rudder) {
} else if (code==mapping.btn_tr2) {
rightTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
}
conn.sendControllerInput(buttonFlags, leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY);
@@ -165,9 +165,9 @@ public class EvdevHandler implements Runnable {
rightStickX = accountForDeadzone(absRX.getShort(value));
else if (code==mapping.abs_ry)
rightStickY = accountForDeadzone(absRY.getShort(value));
else if (code==mapping.abs_throttle)
else if (code==mapping.abs_z)
leftTrigger = absLT.getByte(value);
else if (code==mapping.abs_rudder)
else if (code==mapping.abs_rz)
rightTrigger = absRT.getByte(value);
else if (code==mapping.abs_dpad_x) {
int dir = absRT.getDirection(value);

View File

@@ -15,23 +15,20 @@ public class GamepadMapping {
public short abs_x = EvdevConstants.ABS_X;
public short abs_y = EvdevConstants.ABS_Y;
public short abs_z = EvdevConstants.ABS_Z;
public short abs_rx = EvdevConstants.ABS_RX;
public short abs_ry = EvdevConstants.ABS_RY;
public short abs_rz = EvdevConstants.ABS_RZ;
public short abs_deadzone = 0;
public short abs_dpad_y = EvdevConstants.ABS_HAT0X;
public short abs_dpad_x = EvdevConstants.ABS_HAT0Y;
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;
public boolean reverse_dpad_y, reverse_dpad_x;
public boolean reverse_throttle, reverse_rudder;
public boolean reverse_z, reverse_rz;
public short btn_south = EvdevConstants.BTN_SOUTH;
public short btn_east = EvdevConstants.BTN_EAST;
@@ -45,6 +42,8 @@ public class GamepadMapping {
public short btn_thumbr = EvdevConstants.BTN_THUMBR;
public short btn_tl = EvdevConstants.BTN_TL;
public short btn_tr = EvdevConstants.BTN_TR;
public short btn_tl2 = EvdevConstants.BTN_TL2;
public short btn_tr2 = EvdevConstants.BTN_TR2;
public short btn_dpad_up = EvdevConstants.BTN_DPAD_UP;
public short btn_dpad_down = EvdevConstants.BTN_DPAD_DOWN;