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,40 +564,37 @@ 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;
case KeyEvent.KEYCODE_BUTTON_Z:
return KeyEvent.KEYCODE_BUTTON_R1;
case KeyEvent.KEYCODE_BUTTON_C:
return KeyEvent.KEYCODE_BUTTON_B;
case KeyEvent.KEYCODE_BUTTON_X:
return KeyEvent.KEYCODE_BUTTON_Y;
case KeyEvent.KEYCODE_BUTTON_B:
return KeyEvent.KEYCODE_BUTTON_A;
case KeyEvent.KEYCODE_BUTTON_A:
return KeyEvent.KEYCODE_BUTTON_X; return KeyEvent.KEYCODE_BUTTON_X;
case 305:
case KeyEvent.KEYCODE_BUTTON_SELECT: return KeyEvent.KEYCODE_BUTTON_A;
return KeyEvent.KEYCODE_BUTTON_THUMBL; case 306:
return KeyEvent.KEYCODE_BUTTON_B;
case KeyEvent.KEYCODE_BUTTON_START: case 307:
return KeyEvent.KEYCODE_BUTTON_THUMBR; return KeyEvent.KEYCODE_BUTTON_Y;
case 308:
case KeyEvent.KEYCODE_BUTTON_L2: return KeyEvent.KEYCODE_BUTTON_L1;
case 309:
return KeyEvent.KEYCODE_BUTTON_R1;
/*
**** Using analog triggers instead ****
case 310:
return KeyEvent.KEYCODE_BUTTON_L2;
case 311:
return KeyEvent.KEYCODE_BUTTON_R2;
*/
case 312:
return KeyEvent.KEYCODE_BUTTON_SELECT; return KeyEvent.KEYCODE_BUTTON_SELECT;
case 313:
case KeyEvent.KEYCODE_BUTTON_R2:
return KeyEvent.KEYCODE_BUTTON_START; return KeyEvent.KEYCODE_BUTTON_START;
case 314:
// These are duplicate trigger events return KeyEvent.KEYCODE_BUTTON_THUMBL;
case KeyEvent.KEYCODE_BUTTON_R1: case 315:
case KeyEvent.KEYCODE_BUTTON_L1: return KeyEvent.KEYCODE_BUTTON_THUMBR;
case 316:
return KeyEvent.KEYCODE_BUTTON_MODE;
default:
return 0; return 0;
} }
} }