Added an option to map the touchpad button for Sony controllers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/test/controllermap.c b/test/controllermap.c
index a70764a..3c915e1 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -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,