mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
Load gamecontrollerdb.txt for SDL2 joy mappings
This commit is contained in:
parent
6e45f5a66b
commit
db0e643419
2 changed files with 14 additions and 3 deletions
|
@ -117,7 +117,7 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
|
||||||
during gameplay and released otherwise (in menu, videos, console or if
|
during gameplay and released otherwise (in menu, videos, console or if
|
||||||
game is paused).
|
game is paused).
|
||||||
|
|
||||||
**in_sdlbackbutton**: Defines which button is used in the gamepad or
|
* **in_sdlbackbutton**: Defines which button is used in the gamepad or
|
||||||
joystick as the `Esc` key, that is, to be able to access the menu
|
joystick as the `Esc` key, that is, to be able to access the menu
|
||||||
and 'cancel'/'go back' on its options. When set to `0` (the default)
|
and 'cancel'/'go back' on its options. When set to `0` (the default)
|
||||||
the Back/Select/Minus button is used. Set this to `1` to use the
|
the Back/Select/Minus button is used. Set this to `1` to use the
|
||||||
|
|
|
@ -1201,7 +1201,9 @@ Haptic_Feedback(char *name, int effect_volume, int effect_duration,
|
||||||
void
|
void
|
||||||
IN_Init(void)
|
IN_Init(void)
|
||||||
{
|
{
|
||||||
static cvar_t *in_sdlbackbutton;
|
cvar_t *in_sdlbackbutton;
|
||||||
|
int nummappings;
|
||||||
|
char controllerdb[MAX_OSPATH] = {0};
|
||||||
Com_Printf("------- input initialization -------\n");
|
Com_Printf("------- input initialization -------\n");
|
||||||
|
|
||||||
mouse_x = mouse_y = 0;
|
mouse_x = mouse_y = 0;
|
||||||
|
@ -1279,7 +1281,16 @@ IN_Init(void)
|
||||||
{
|
{
|
||||||
Com_Printf ("%i joysticks were found.\n", SDL_NumJoysticks());
|
Com_Printf ("%i joysticks were found.\n", SDL_NumJoysticks());
|
||||||
|
|
||||||
if (SDL_NumJoysticks() > 0) {
|
if (SDL_NumJoysticks() > 0)
|
||||||
|
{
|
||||||
|
for (const char* rawPath = FS_GetNextRawPath(NULL); rawPath != NULL; rawPath = FS_GetNextRawPath(rawPath))
|
||||||
|
{
|
||||||
|
snprintf(controllerdb, MAX_OSPATH, "%s/%s", rawPath, "gamecontrollerdb.txt");
|
||||||
|
nummappings = SDL_GameControllerAddMappingsFromFile(controllerdb);
|
||||||
|
if (nummappings > 0)
|
||||||
|
Com_Printf ("%d mappings loaded from gamecontrollerdb.txt\n", nummappings);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||||
joystick = SDL_JoystickOpen(i);
|
joystick = SDL_JoystickOpen(i);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue