testcontroller: Don't query the mapping list until after they are available.
The included ones need to wait until SDL_Init has run, or you'll get an empty list, and we might also be adding more from an external gamecontrollerdb.txt file, too.
This commit is contained in:
parent
df05d5eff4
commit
c5daf8adb1
1 changed files with 15 additions and 10 deletions
|
@ -1876,6 +1876,7 @@ int main(int argc, char *argv[])
|
||||||
int screen_width, screen_height;
|
int screen_width, screen_height;
|
||||||
SDL_Rect area;
|
SDL_Rect area;
|
||||||
int gamepad_index = -1;
|
int gamepad_index = -1;
|
||||||
|
SDL_bool show_mappings = SDL_FALSE;
|
||||||
SDLTest_CommonState *state;
|
SDLTest_CommonState *state;
|
||||||
|
|
||||||
/* Initialize test framework */
|
/* Initialize test framework */
|
||||||
|
@ -1902,16 +1903,7 @@ int main(int argc, char *argv[])
|
||||||
consumed = SDLTest_CommonArg(state, i);
|
consumed = SDLTest_CommonArg(state, i);
|
||||||
if (!consumed) {
|
if (!consumed) {
|
||||||
if (SDL_strcmp(argv[i], "--mappings") == 0) {
|
if (SDL_strcmp(argv[i], "--mappings") == 0) {
|
||||||
int map_i;
|
show_mappings = SDL_TRUE;
|
||||||
SDL_Log("Supported mappings:\n");
|
|
||||||
for (map_i = 0; map_i < SDL_GetNumGamepadMappings(); ++map_i) {
|
|
||||||
char *mapping = SDL_GetGamepadMappingForIndex(map_i);
|
|
||||||
if (mapping) {
|
|
||||||
SDL_Log("\t%s\n", mapping);
|
|
||||||
SDL_free(mapping);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SDL_Log("\n");
|
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
} else if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
} else if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
||||||
OpenVirtualGamepad();
|
OpenVirtualGamepad();
|
||||||
|
@ -1944,6 +1936,19 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
SDL_AddGamepadMappingsFromFile("gamecontrollerdb.txt");
|
SDL_AddGamepadMappingsFromFile("gamecontrollerdb.txt");
|
||||||
|
|
||||||
|
if (show_mappings) {
|
||||||
|
int map_i;
|
||||||
|
SDL_Log("Supported mappings:\n");
|
||||||
|
for (map_i = 0; map_i < SDL_GetNumGamepadMappings(); ++map_i) {
|
||||||
|
char *mapping = SDL_GetGamepadMappingForIndex(map_i);
|
||||||
|
if (mapping) {
|
||||||
|
SDL_Log("\t%s\n", mapping);
|
||||||
|
SDL_free(mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_Log("\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a window to display gamepad state */
|
/* Create a window to display gamepad state */
|
||||||
content_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
content_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
if (content_scale == 0.0f) {
|
if (content_scale == 0.0f) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue