Added an option to map the touchpad button for Sony controllers

main
Sam Lantinga 2021-11-29 09:00:26 -08:00
parent f6fdbc1e37
commit 4b571c624c
1 changed files with 13 additions and 1 deletions

View File

@ -119,7 +119,7 @@ static int s_arrBindingOrder[] = {
SDL_CONTROLLER_BUTTON_PADDLE2,
SDL_CONTROLLER_BUTTON_PADDLE3,
SDL_CONTROLLER_BUTTON_PADDLE4,
-1,
SDL_CONTROLLER_BUTTON_TOUCHPAD,
};
SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT);
@ -167,6 +167,7 @@ static SDL_bool s_bBindingComplete;
static SDL_Window *window;
static SDL_Renderer *screen;
static SDL_bool done = SDL_FALSE;
static SDL_bool bind_touchpad = SDL_FALSE;
SDL_Texture *
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
@ -234,6 +235,13 @@ SetCurrentBinding(int iBinding)
return;
}
if (s_arrBindingOrder[iBinding] == SDL_CONTROLLER_BUTTON_TOUCHPAD &&
!bind_touchpad)
{
SetCurrentBinding(iBinding + 1);
return;
}
s_iCurrentBinding = iBinding;
pBinding = &s_arrBindings[s_arrBindingOrder[s_iCurrentBinding]];
@ -731,6 +739,10 @@ main(int argc, char *argv[])
exit(1);
}
if (argv[1] && SDL_strcmp(argv[1], "--bind-touchpad") == 0) {
bind_touchpad = SDL_TRUE;
}
/* Create a window to display joystick axis position */
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,