X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=04a098cdaf0af24fc5af18895ec936123f2bb63d;hb=cea8726203188984c5d94dc15934d1e186d18c37;hp=d6cf2b1779082a6a5b9d418273fe95c91add3ca7;hpb=e913fbf7e7caa3234df0de282363ee4d6bb727e1;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index d6cf2b17..04a098cd 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2833,7 +2833,10 @@ void SDLInitJoysticks() static boolean sdl_joystick_subsystem_initialized = FALSE; boolean print_warning = !sdl_joystick_subsystem_initialized; #if defined(TARGET_SDL2) - char *mappings_file = "gamecontrollerdb.txt"; + char *mappings_file_base = getPath2(options.ro_base_directory, + GAMECONTROLLER_BASENAME); + char *mappings_file_user = getPath2(getUserGameDataDir(), + GAMECONTROLLER_BASENAME); int num_mappings; #endif int i; @@ -2855,15 +2858,25 @@ void SDLInitJoysticks() } #if defined(TARGET_SDL2) - num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file); + num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file_base); if (num_mappings != -1) - Error(ERR_INFO, "%d game controller mapping(s) added", num_mappings); + Error(ERR_INFO, "%d game controller base mapping(s) added", num_mappings); else - Error(ERR_WARN, "no game controller mappings found"); + Error(ERR_WARN, "no game controller base mappings found"); + + num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file_user); + + if (num_mappings != -1) + Error(ERR_INFO, "%d game controller user mapping(s) added", num_mappings); + else + Error(ERR_WARN, "no game controller user mappings found"); Error(ERR_INFO, "%d joystick(s) found:", SDL_NumJoysticks()); + checked_free(mappings_file_base); + checked_free(mappings_file_user); + for (i = 0; i < SDL_NumJoysticks(); i++) { const char *name, *type; @@ -2900,8 +2913,8 @@ void SDLInitJoysticks() joystick_nr = -1; } - /* misuse joystick file descriptor variable to store joystick number */ - joystick.fd[i] = joystick_nr; + /* store configured joystick number for each player */ + joystick.nr[i] = joystick_nr; } /* now open all connected joysticks (regardless if configured or not) */