mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-17 07:16:00 +00:00
SDL now represents gamepad buttons as positional elements with a separate label
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user. Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect. Fixes https://github.com/libsdl-org/SDL/issues/6117
This commit is contained in:
@@ -135,7 +135,6 @@ typedef struct
|
||||
Uint64 timestamp;
|
||||
EWiiCommunicationState m_eCommState;
|
||||
EWiiExtensionControllerType m_eExtensionControllerType;
|
||||
SDL_bool m_bUseButtonLabels;
|
||||
SDL_bool m_bPlayerLights;
|
||||
int m_nPlayerIndex;
|
||||
SDL_bool m_bRumbleActive;
|
||||
@@ -610,12 +609,6 @@ static void InitializeExtension(SDL_DriverWii_Context *ctx)
|
||||
ResetButtonPacketType(ctx);
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_GameControllerButtonReportingHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)userdata;
|
||||
ctx->m_bUseButtonLabels = SDL_GetStringBoolean(hint, SDL_TRUE);
|
||||
}
|
||||
|
||||
static void UpdateSlotLED(SDL_DriverWii_Context *ctx)
|
||||
{
|
||||
Uint8 leds;
|
||||
@@ -786,9 +779,6 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
|
||||
}
|
||||
}
|
||||
|
||||
SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS,
|
||||
SDL_GameControllerButtonReportingHintChanged, ctx);
|
||||
|
||||
/* Initialize player index (needed for setting LEDs) */
|
||||
ctx->m_nPlayerIndex = SDL_GetJoystickPlayerIndex(joystick);
|
||||
ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, SDL_TRUE);
|
||||
@@ -940,43 +930,10 @@ static const Uint8 GAMEPAD_BUTTON_DEFS[3][8] = {
|
||||
SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
0xFF /* ZR */,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
0xFF /*ZL*/,
|
||||
},
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_STICK,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_STICK,
|
||||
0xFF /* Charging */,
|
||||
0xFF /* Plugged In */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
}
|
||||
};
|
||||
|
||||
static const Uint8 GAMEPAD_BUTTON_DEFS_POSITIONAL[3][8] = {
|
||||
{
|
||||
0xFF /* Unused */,
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_START,
|
||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
},
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
0xFF /* ZR */,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_NORTH,
|
||||
SDL_GAMEPAD_BUTTON_EAST,
|
||||
SDL_GAMEPAD_BUTTON_WEST,
|
||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||
0xFF /*ZL*/,
|
||||
},
|
||||
{
|
||||
@@ -1006,43 +963,10 @@ static const Uint8 MP_GAMEPAD_BUTTON_DEFS[3][8] = {
|
||||
0xFF /* Motion Plus data */,
|
||||
0xFF /* Motion Plus data */,
|
||||
0xFF /* ZR */,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
0xFF /*ZL*/,
|
||||
},
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_STICK,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_STICK,
|
||||
0xFF /* Charging */,
|
||||
0xFF /* Plugged In */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
}
|
||||
};
|
||||
|
||||
static const Uint8 MP_GAMEPAD_BUTTON_DEFS_POSITIONAL[3][8] = {
|
||||
{
|
||||
0xFF /* Unused */,
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_START,
|
||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
},
|
||||
{
|
||||
0xFF /* Motion Plus data */,
|
||||
0xFF /* Motion Plus data */,
|
||||
0xFF /* ZR */,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_NORTH,
|
||||
SDL_GAMEPAD_BUTTON_EAST,
|
||||
SDL_GAMEPAD_BUTTON_WEST,
|
||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||
0xFF /*ZL*/,
|
||||
},
|
||||
{
|
||||
@@ -1083,7 +1007,7 @@ static const Uint8 MP_FIXUP_DPAD_BUTTON_DEFS[2][8] = {
|
||||
static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, const WiiButtonData *data)
|
||||
{
|
||||
static const Uint8 axes[] = { SDL_GAMEPAD_AXIS_LEFTX, SDL_GAMEPAD_AXIS_RIGHTX, SDL_GAMEPAD_AXIS_LEFTY, SDL_GAMEPAD_AXIS_RIGHTY };
|
||||
const Uint8(*buttons)[8] = ctx->m_bUseButtonLabels ? GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS_POSITIONAL;
|
||||
const Uint8(*buttons)[8] = GAMEPAD_BUTTON_DEFS;
|
||||
Uint8 zl, zr;
|
||||
int i;
|
||||
|
||||
@@ -1112,7 +1036,7 @@ static void HandleWiiUProButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *jo
|
||||
|
||||
static void HandleGamepadControllerButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, const WiiButtonData *data)
|
||||
{
|
||||
const Uint8(*buttons)[8] = ctx->m_bUseButtonLabels ? ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS) : ((ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS_POSITIONAL : GAMEPAD_BUTTON_DEFS_POSITIONAL);
|
||||
const Uint8(*buttons)[8] = (ctx->m_ucMotionPlusMode == WII_MOTIONPLUS_MODE_GAMEPAD) ? MP_GAMEPAD_BUTTON_DEFS : GAMEPAD_BUTTON_DEFS;
|
||||
Uint8 lx, ly, rx, ry, zl, zr;
|
||||
|
||||
if (data->ucNExtensionBytes < 6) {
|
||||
@@ -1194,10 +1118,10 @@ static void HandleWiiRemoteButtonDataAsMainController(SDL_DriverWii_Context *ctx
|
||||
0xFF /* Unused */,
|
||||
},
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_NORTH,
|
||||
SDL_GAMEPAD_BUTTON_WEST,
|
||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||
SDL_GAMEPAD_BUTTON_EAST,
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
0xFF /* Unused */,
|
||||
0xFF /* Unused */,
|
||||
@@ -1637,9 +1561,6 @@ static void HIDAPI_DriverWii_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joysti
|
||||
{
|
||||
SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context;
|
||||
|
||||
SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS,
|
||||
SDL_GameControllerButtonReportingHintChanged, ctx);
|
||||
|
||||
SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED,
|
||||
SDL_PlayerLEDHintChanged, ctx);
|
||||
|
||||
|
Reference in New Issue
Block a user