Differences From Artifact [f983d21e94]:
- File src/hid/platform/Linux/OFGameController.m — part of check-in [4c804d8fa7] at 2024-05-14 21:39:41 on branch gamecontroller — OFGameController: Fix mapping for Sony DualSense (user: js, size: 14763) [annotate] [blame] [check-ins using]
To Artifact [a14fd08793]:
- File
src/hid/platform/Linux/OFGameController.m
— part of check-in
[a4fa1b26f2]
at
2024-05-14 22:14:19
on branch gamecontroller
— OFGameController: Fix Xbox 360 controller mapping
It turns out the quirk for all other controllers to swap north/west was
wrong, and the Xbox 360 controller is actually the one that has
north/west swapped.The reason for this seems to be that Linux has BTN_NORTH and BTN_X
mapped to the same code, as well as BTN_WEST to BTN_Y. However, on the
Xbox 360 controller, Y is north and X is west. It seems that the Xbox
360 driver decided to return BTN_X and BTN_Y (so that the labels are
correct) while other drivers return BTN_NORTH and BTN_SOUTH (so that the
position is correct). (user: js, size: 15062) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" static const uint16_t vendorIDNintendo = 0x057E; static const uint16_t vendorIDSony = 0x054C; /* Nintendo controllers */ static const uint16_t productIDLeftJoycon = 0x2006; static const uint16_t productIDRightJoycon = 0x2007; static const uint16_t productIDN64Controller = 0x2019; /* Sony controllers */ static const uint16_t productIDDualSense = 0x0CE6; | > > > > > > > > > > > > > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" /* * Controllers with tested correct mapping: * * Microsoft X-Box 360 pad [045E:028E] * Joy-Con (L) [057E:2006] * Joy-Con (R) [057E:2007] * N64 Controller [057E:2019] * Sony Interactive Entertainment DualSense Wireless Controller [054C:0CE6] */ static const uint16_t vendorIDMicrosoft = 0x045E; static const uint16_t vendorIDNintendo = 0x057E; static const uint16_t vendorIDSony = 0x054C; /* Microsoft controllers */ static const uint16_t productIDXbox360 = 0x028E; /* Nintendo controllers */ static const uint16_t productIDLeftJoycon = 0x2006; static const uint16_t productIDRightJoycon = 0x2007; static const uint16_t productIDN64Controller = 0x2019; /* Sony controllers */ static const uint16_t productIDDualSense = 0x0CE6; |
︙ | ︙ | |||
59 60 61 62 63 64 65 | BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR, BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT }; static OFGameControllerButton buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID) { | > > > > > > > | < < < < | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR, BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT }; static OFGameControllerButton buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID) { if (vendorID == vendorIDMicrosoft && productID == productIDXbox360) { switch (button) { case BTN_Y: return OFGameControllerNorthButton; case BTN_X: return OFGameControllerWestButton; } } else if (vendorID == vendorIDNintendo && productID == productIDLeftJoycon) { switch (button) { case BTN_SELECT: return OFGameControllerMinusButton; case BTN_Z: return OFGameControllerCaptureButton; case BTN_TR: return OFGameControllerSLButton; case BTN_TR2: return OFGameControllerSRButton; } } else if (vendorID == vendorIDNintendo && productID == productIDRightJoycon) { switch (button) { case BTN_START: return OFGameControllerPlusButton; case BTN_TL: return OFGameControllerSLButton; case BTN_TL2: return OFGameControllerSRButton; } |
︙ | ︙ | |||
103 104 105 106 107 108 109 | case BTN_Y: return OFGameControllerCPadLeftButton; case BTN_C: return OFGameControllerCPadRightButton; case BTN_Z: return OFGameControllerCaptureButton; } | < < < < < < < < | | | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | case BTN_Y: return OFGameControllerCPadLeftButton; case BTN_C: return OFGameControllerCPadRightButton; case BTN_Z: return OFGameControllerCaptureButton; } } switch (button) { case BTN_NORTH: return OFGameControllerNorthButton; case BTN_SOUTH: return OFGameControllerSouthButton; case BTN_WEST: return OFGameControllerWestButton; case BTN_EAST: return OFGameControllerEastButton; case BTN_TL2: return OFGameControllerLeftTriggerButton; case BTN_TR2: return OFGameControllerRightTriggerButton; case BTN_TL: return OFGameControllerLeftShoulderButton; |
︙ | ︙ |