SDL_GamepadButton(3type)

๐Ÿ’– SDL_GamepadButton(3type) ๐Ÿ’–

okay bestie, welcome to the SDL3 DATATYPES corner of the manual, and today's main character is SDL_GamepadButton โ€” literally the whole list of buttons a gamepad can have. no cap.


โœจ NAME โœจ

SDL_GamepadButton โ€” the list of buttons available on a gamepad ๐ŸŽฎ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_gamepad.h>

typedef enum SDL_GamepadButton
{
    SDL_GAMEPAD_BUTTON_INVALID = -1,
    SDL_GAMEPAD_BUTTON_SOUTH,           /**< Bottom face button (e.g. Xbox A button) */
    SDL_GAMEPAD_BUTTON_EAST,            /**< Right face button (e.g. Xbox B button) */
    SDL_GAMEPAD_BUTTON_WEST,            /**< Left face button (e.g. Xbox X button) */
    SDL_GAMEPAD_BUTTON_NORTH,           /**< Top face button (e.g. Xbox Y button) */
    SDL_GAMEPAD_BUTTON_BACK,
    SDL_GAMEPAD_BUTTON_GUIDE,
    SDL_GAMEPAD_BUTTON_START,
    SDL_GAMEPAD_BUTTON_LEFT_STICK,
    SDL_GAMEPAD_BUTTON_RIGHT_STICK,
    SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
    SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
    SDL_GAMEPAD_BUTTON_DPAD_UP,
    SDL_GAMEPAD_BUTTON_DPAD_DOWN,
    SDL_GAMEPAD_BUTTON_DPAD_LEFT,
    SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
    SDL_GAMEPAD_BUTTON_MISC1,           /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Steam Controller QAM button, Amazon Luna microphone button, Google Stadia capture button) */
    SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1,   /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button, Steam Controller R4 button) */
    SDL_GAMEPAD_BUTTON_LEFT_PADDLE1,    /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button, Steam Controller L4 button) */
    SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2,   /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button, Steam Controller R5 button) */
    SDL_GAMEPAD_BUTTON_LEFT_PADDLE2,    /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button, Steam Controller L5 button) */
    SDL_GAMEPAD_BUTTON_TOUCHPAD,        /**< PS4/PS5 touchpad button */
    SDL_GAMEPAD_BUTTON_MISC2,           /**< Additional button */
    SDL_GAMEPAD_BUTTON_MISC3,           /**< Additional button (e.g. Nintendo GameCube left trigger click) */
    SDL_GAMEPAD_BUTTON_MISC4,           /**< Additional button (e.g. Nintendo GameCube right trigger click) */
    SDL_GAMEPAD_BUTTON_MISC5,           /**< Additional button */
    SDL_GAMEPAD_BUTTON_MISC6,           /**< Additional button */
    SDL_GAMEPAD_BUTTON_COUNT
} SDL_GamepadButton;

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea, bestie ๐Ÿ“. some controllers put their face buttons in a lil diamond pattern, and when they do, the south/east/west/north buttons map straight onto the spots in that diamond. it's giving geometry, honestly. so:

  • on Xbox controllers that's A/B/X/Y
  • on Nintendo Switch controllers that's B/A/Y/X
  • on GameCube controllers that's A/X/B/Y
  • on PlayStation controllers that's Cross/Circle/Square/Triangle

and for the controllers that don't do the diamond thing? the south/east/west/north buttons just mean the buttons labeled A, B, C, D, or 1, 2, 3, 4 โ€” or, for the ones that aren't labeled at all, they're the primary, secondary, etc. buttons. simple as that ๐Ÿ’….

okay and this next bit is important so listen up ๐Ÿ“ฃ: the activate action is often the south button and the cancel action is often the east button โ€” but in some regions it's literally reversed ๐Ÿ™ˆ. so your game should let players remap actions based on user preferences. don't hardcode it, bestie, that's the vibe check you will fail.

you can also query the labels for the face buttons using SDL_GetGamepadButtonLabel() โœจ


๐Ÿ‘‘ AVAILABILITY ๐Ÿ‘‘

this enum has been available since SDL 3.2.0. periodt.


and that's the whole page, no notes ๐Ÿซถ this was brought to you by Simple Directmedia Layer, rocking SDL 3.4.18, and this lil SDL_GamepadButton(3type) moment lives in the SDL3 datatypes crew. go remap something, queen ๐Ÿ‘‘๐Ÿ’–

๐Ÿ“ฆ where this page comes from