Use scancode mapping for DS4 for consistent mappings across devices

This commit is contained in:
Cameron Gutman 2016-11-05 20:08:42 -07:00
parent e7dc3a4c11
commit 453fbb5f58

View File

@ -564,41 +564,38 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
} }
if (context.isDualShock4) { if (context.isDualShock4) {
switch (event.getKeyCode()) { switch (event.getScanCode()) {
case KeyEvent.KEYCODE_BUTTON_Y: case 304:
return KeyEvent.KEYCODE_BUTTON_L1; return KeyEvent.KEYCODE_BUTTON_X;
case 305:
case KeyEvent.KEYCODE_BUTTON_Z: return KeyEvent.KEYCODE_BUTTON_A;
return KeyEvent.KEYCODE_BUTTON_R1; case 306:
return KeyEvent.KEYCODE_BUTTON_B;
case KeyEvent.KEYCODE_BUTTON_C: case 307:
return KeyEvent.KEYCODE_BUTTON_B; return KeyEvent.KEYCODE_BUTTON_Y;
case 308:
case KeyEvent.KEYCODE_BUTTON_X: return KeyEvent.KEYCODE_BUTTON_L1;
return KeyEvent.KEYCODE_BUTTON_Y; case 309:
return KeyEvent.KEYCODE_BUTTON_R1;
case KeyEvent.KEYCODE_BUTTON_B: /*
return KeyEvent.KEYCODE_BUTTON_A; **** Using analog triggers instead ****
case 310:
case KeyEvent.KEYCODE_BUTTON_A: return KeyEvent.KEYCODE_BUTTON_L2;
return KeyEvent.KEYCODE_BUTTON_X; case 311:
return KeyEvent.KEYCODE_BUTTON_R2;
case KeyEvent.KEYCODE_BUTTON_SELECT: */
return KeyEvent.KEYCODE_BUTTON_THUMBL; case 312:
return KeyEvent.KEYCODE_BUTTON_SELECT;
case KeyEvent.KEYCODE_BUTTON_START: case 313:
return KeyEvent.KEYCODE_BUTTON_THUMBR; return KeyEvent.KEYCODE_BUTTON_START;
case 314:
case KeyEvent.KEYCODE_BUTTON_L2: return KeyEvent.KEYCODE_BUTTON_THUMBL;
return KeyEvent.KEYCODE_BUTTON_SELECT; case 315:
return KeyEvent.KEYCODE_BUTTON_THUMBR;
case KeyEvent.KEYCODE_BUTTON_R2: case 316:
return KeyEvent.KEYCODE_BUTTON_START; return KeyEvent.KEYCODE_BUTTON_MODE;
default:
// These are duplicate trigger events return 0;
case KeyEvent.KEYCODE_BUTTON_R1:
case KeyEvent.KEYCODE_BUTTON_L1:
return 0;
} }
} }
// If this is a Serval controller sending an unknown key code, it's probably // If this is a Serval controller sending an unknown key code, it's probably