Skip to content
14 changes: 14 additions & 0 deletions port/src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static s32 numJoysticks = 0;

static s32 useHIDAPI = 1;
static s32 useRawInput = 1;
static s32 useNintendoLayout = 0;

static s32 mouseEnabled = 1;
static s32 mouseX, mouseY;
Expand Down Expand Up @@ -709,6 +710,18 @@ s32 inputInit(void)
SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, "1");
}

if (useNintendoLayout) {
// use the Nintendo-style face button layout across both menus and gameplay
// this is default hint in SDL 2.0.6 and later
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "1"); // uses button labels (A/B/X/Y)
} else {
#if SDL_VERSION_ATLEAST(2, 0, 6)
// use the Xbox-style face button layout
// this is set by default, but it's explicitly set here to avoid confusion
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0"); // Uses positional face buttons (SOUTH/EAST/WEST/NORTH)
#endif
}

if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC)) {
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC);
}
Expand Down Expand Up @@ -1515,6 +1528,7 @@ PD_CONSTRUCTOR static void inputConfigInit(void)
configRegisterInt("Input.FirstGamepadNum", &firstController, 0, 3);
configRegisterInt("Input.UseHIDAPI", &useHIDAPI, 0, 1);
configRegisterInt("Input.UseRawInput", &useRawInput, 0, 1);
configRegisterInt("Input.UseNintendoLayout", &useNintendoLayout, 0, 1);

char secname[] = "Input.Player1.Binds";
char keyname[256] = { 0 };
Expand Down