Skip to content

Commit

Permalink
abxy-nsew
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 13, 2023
1 parent efe1558 commit 5ff34b3
Show file tree
Hide file tree
Showing 26 changed files with 265 additions and 253 deletions.
8 changes: 4 additions & 4 deletions docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ The following symbols have been renamed:
* SDL_CONTROLLER_BINDTYPE_BUTTON => SDL_GAMEPAD_BINDTYPE_BUTTON
* SDL_CONTROLLER_BINDTYPE_HAT => SDL_GAMEPAD_BINDTYPE_HAT
* SDL_CONTROLLER_BINDTYPE_NONE => SDL_GAMEPAD_BINDTYPE_NONE
* SDL_CONTROLLER_BUTTON_A => SDL_GAMEPAD_BUTTON_A
* SDL_CONTROLLER_BUTTON_B => SDL_GAMEPAD_BUTTON_B
* SDL_CONTROLLER_BUTTON_A => SDL_GAMEPAD_BUTTON_SOUTH
* SDL_CONTROLLER_BUTTON_B => SDL_GAMEPAD_BUTTON_EAST
* SDL_CONTROLLER_BUTTON_BACK => SDL_GAMEPAD_BUTTON_BACK
* SDL_CONTROLLER_BUTTON_DPAD_DOWN => SDL_GAMEPAD_BUTTON_DPAD_DOWN
* SDL_CONTROLLER_BUTTON_DPAD_LEFT => SDL_GAMEPAD_BUTTON_DPAD_LEFT
Expand All @@ -516,8 +516,8 @@ The following symbols have been renamed:
* SDL_CONTROLLER_BUTTON_RIGHTSTICK => SDL_GAMEPAD_BUTTON_RIGHT_STICK
* SDL_CONTROLLER_BUTTON_START => SDL_GAMEPAD_BUTTON_START
* SDL_CONTROLLER_BUTTON_TOUCHPAD => SDL_GAMEPAD_BUTTON_TOUCHPAD
* SDL_CONTROLLER_BUTTON_X => SDL_GAMEPAD_BUTTON_X
* SDL_CONTROLLER_BUTTON_Y => SDL_GAMEPAD_BUTTON_Y
* SDL_CONTROLLER_BUTTON_X => SDL_GAMEPAD_BUTTON_WEST
* SDL_CONTROLLER_BUTTON_Y => SDL_GAMEPAD_BUTTON_NORTH
* SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT => SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
* SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR => SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
* SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT => SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
Expand Down
8 changes: 4 additions & 4 deletions include/SDL3/SDL_gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ typedef enum
typedef enum
{
SDL_GAMEPAD_BUTTON_INVALID = -1,
SDL_GAMEPAD_BUTTON_A,
SDL_GAMEPAD_BUTTON_B,
SDL_GAMEPAD_BUTTON_X,
SDL_GAMEPAD_BUTTON_Y,
SDL_GAMEPAD_BUTTON_SOUTH,
SDL_GAMEPAD_BUTTON_EAST,
SDL_GAMEPAD_BUTTON_WEST,
SDL_GAMEPAD_BUTTON_NORTH,
SDL_GAMEPAD_BUTTON_BACK,
SDL_GAMEPAD_BUTTON_GUIDE,
SDL_GAMEPAD_BUTTON_START,
Expand Down
2 changes: 1 addition & 1 deletion include/SDL3/SDL_joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ typedef struct SDL_VirtualJoystickDesc
Uint16 product_id; /**< the USB product ID of this joystick */
Uint16 padding; /**< unused */
Uint32 button_mask; /**< A mask of which buttons are valid for this controller
e.g. (1 << SDL_GAMEPAD_BUTTON_A) */
e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
Uint32 axis_mask; /**< A mask of which axes are valid for this controller
e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
const char *name; /**< the name of the joystick */
Expand Down
8 changes: 4 additions & 4 deletions include/SDL3/SDL_oldnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
#define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_GAMEPAD_BINDTYPE_BUTTON
#define SDL_CONTROLLER_BINDTYPE_HAT SDL_GAMEPAD_BINDTYPE_HAT
#define SDL_CONTROLLER_BINDTYPE_NONE SDL_GAMEPAD_BINDTYPE_NONE
#define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_A
#define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_B
#define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_SOUTH
#define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_EAST
#define SDL_CONTROLLER_BUTTON_BACK SDL_GAMEPAD_BUTTON_BACK
#define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_GAMEPAD_BUTTON_DPAD_DOWN
#define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_GAMEPAD_BUTTON_DPAD_LEFT
Expand All @@ -182,8 +182,8 @@
#define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_GAMEPAD_BUTTON_RIGHT_STICK
#define SDL_CONTROLLER_BUTTON_START SDL_GAMEPAD_BUTTON_START
#define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_GAMEPAD_BUTTON_TOUCHPAD
#define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_X
#define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_Y
#define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_WEST
#define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_NORTH
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
Expand Down
16 changes: 8 additions & 8 deletions src/joystick/SDL_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,10 @@ static void PopMappingChangeTracking(void)
*/
static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID guid)
{
const int face_button_mask = ((1 << SDL_GAMEPAD_BUTTON_A) |
(1 << SDL_GAMEPAD_BUTTON_B) |
(1 << SDL_GAMEPAD_BUTTON_X) |
(1 << SDL_GAMEPAD_BUTTON_Y));
const int face_button_mask = ((1 << SDL_GAMEPAD_BUTTON_SOUTH) |
(1 << SDL_GAMEPAD_BUTTON_EAST) |
(1 << SDL_GAMEPAD_BUTTON_WEST) |
(1 << SDL_GAMEPAD_BUTTON_NORTH));
SDL_bool existing;
char mapping_string[1024];
int button_mask;
Expand All @@ -644,20 +644,20 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID gui

SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));

if (button_mask & (1 << SDL_GAMEPAD_BUTTON_A)) {
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_SOUTH)) {
SDL_strlcat(mapping_string, "a:b0,", sizeof(mapping_string));
}
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_B)) {
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_EAST)) {
SDL_strlcat(mapping_string, "b:b1,", sizeof(mapping_string));
} else if (button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) {
/* Use the back button as "B" for easy UI navigation with TV remotes */
SDL_strlcat(mapping_string, "b:b4,", sizeof(mapping_string));
button_mask &= ~(1 << SDL_GAMEPAD_BUTTON_BACK);
}
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_X)) {
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_WEST)) {
SDL_strlcat(mapping_string, "x:b2,", sizeof(mapping_string));
}
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_Y)) {
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_NORTH)) {
SDL_strlcat(mapping_string, "y:b3,", sizeof(mapping_string));
}
if (button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) {
Expand Down
14 changes: 7 additions & 7 deletions src/joystick/android/SDL_sysjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ static int keycode_to_SDL(int keycode)
switch (keycode) {
/* Some gamepad buttons (API 9) */
case AKEYCODE_BUTTON_A:
button = SDL_GAMEPAD_BUTTON_A;
button = SDL_GAMEPAD_BUTTON_SOUTH;
break;
case AKEYCODE_BUTTON_B:
button = SDL_GAMEPAD_BUTTON_B;
button = SDL_GAMEPAD_BUTTON_EAST;
break;
case AKEYCODE_BUTTON_X:
button = SDL_GAMEPAD_BUTTON_X;
button = SDL_GAMEPAD_BUTTON_WEST;
break;
case AKEYCODE_BUTTON_Y:
button = SDL_GAMEPAD_BUTTON_Y;
button = SDL_GAMEPAD_BUTTON_NORTH;
break;
case AKEYCODE_BUTTON_L1:
button = SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
Expand Down Expand Up @@ -136,7 +136,7 @@ static int keycode_to_SDL(int keycode)
case AKEYCODE_DPAD_CENTER:
/* This is handled better by applications as the A button */
/*button = 19;*/
button = SDL_GAMEPAD_BUTTON_A;
button = SDL_GAMEPAD_BUTTON_SOUTH;
break;

/* More gamepad buttons (API 12), these get mapped to 20...35*/
Expand Down Expand Up @@ -174,9 +174,9 @@ static int keycode_to_SDL(int keycode)
static SDL_Scancode button_to_scancode(int button)
{
switch (button) {
case SDL_GAMEPAD_BUTTON_A:
case SDL_GAMEPAD_BUTTON_SOUTH:
return SDL_SCANCODE_RETURN;
case SDL_GAMEPAD_BUTTON_B:
case SDL_GAMEPAD_BUTTON_EAST:
return SDL_SCANCODE_ESCAPE;
case SDL_GAMEPAD_BUTTON_BACK:
return SDL_SCANCODE_ESCAPE;
Expand Down
28 changes: 14 additions & 14 deletions src/joystick/apple/SDL_mfijoystick.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
#endif

/* These buttons are part of the original MFi spec */
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_A);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_B);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_X);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_Y);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_NORTH);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
nbuttons += 6;
Expand Down Expand Up @@ -472,10 +472,10 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
}

/* These buttons are part of the original MFi spec */
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_A);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_B);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_X);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_Y);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_NORTH);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
#if TARGET_OS_TV
Expand All @@ -495,8 +495,8 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
else if (controller.microGamepad) {
int nbuttons = 0;

device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_A);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_B); /* Button X on microGamepad */
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH);
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST); /* Button X on microGamepad */
nbuttons += 2;

device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_START);
Expand Down Expand Up @@ -1748,16 +1748,16 @@ static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *
if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
switch (button) {
case SDL_GAMEPAD_BUTTON_A:
case SDL_GAMEPAD_BUTTON_SOUTH:
GetAppleSFSymbolsNameForElement(elements[GCInputButtonA], elementName);
break;
case SDL_GAMEPAD_BUTTON_B:
case SDL_GAMEPAD_BUTTON_EAST:
GetAppleSFSymbolsNameForElement(elements[GCInputButtonB], elementName);
break;
case SDL_GAMEPAD_BUTTON_X:
case SDL_GAMEPAD_BUTTON_WEST:
GetAppleSFSymbolsNameForElement(elements[GCInputButtonX], elementName);
break;
case SDL_GAMEPAD_BUTTON_Y:
case SDL_GAMEPAD_BUTTON_NORTH:
GetAppleSFSymbolsNameForElement(elements[GCInputButtonY], elementName);
break;
case SDL_GAMEPAD_BUTTON_BACK:
Expand Down
8 changes: 4 additions & 4 deletions src/joystick/hidapi/SDL_hidapi_gamecube.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ static Uint8 RemapButton(SDL_DriverGameCube_Context *ctx, Uint8 button)
if (!ctx->m_bUseButtonLabels) {
/* Use button positions */
switch (button) {
case SDL_GAMEPAD_BUTTON_B:
return SDL_GAMEPAD_BUTTON_X;
case SDL_GAMEPAD_BUTTON_X:
return SDL_GAMEPAD_BUTTON_B;
case SDL_GAMEPAD_BUTTON_EAST:
return SDL_GAMEPAD_BUTTON_WEST;
case SDL_GAMEPAD_BUTTON_WEST:
return SDL_GAMEPAD_BUTTON_EAST;
default:
break;
}
Expand Down
16 changes: 8 additions & 8 deletions src/joystick/hidapi/SDL_hidapi_luna.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ static void HIDAPI_DriverLuna_HandleUSBStatePacket(SDL_Joystick *joystick, SDL_D
Uint64 timestamp = SDL_GetTicksNS();

if (ctx->last_state[1] != data[1]) {
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SOUTH, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_EAST, (data[1] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_WEST, (data[1] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_NORTH, (data[1] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[1] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_BACK, (data[1] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
Expand Down Expand Up @@ -332,10 +332,10 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
}

if (ctx->last_state[14] != data[14]) {
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SOUTH, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_EAST, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_WEST, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_NORTH, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
}
Expand Down
Loading

0 comments on commit 5ff34b3

Please sign in to comment.