mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 18:07:40 +00:00
Try to dynamically create a default Android game controller mapping based on the buttons and axes on the controller.
Include the controller USB VID/PID in the GUID where possible, as we do on other platforms.
This commit is contained in:
parent
2419d26724
commit
9e651b6915
8 changed files with 404 additions and 81 deletions
|
@ -104,6 +104,23 @@ SDL_NumJoysticks(void)
|
|||
return SDL_SYS_NumJoysticks();
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform any needed fixups for joystick names
|
||||
*/
|
||||
static const char *
|
||||
SDL_FixupJoystickName(const char *name)
|
||||
{
|
||||
if (name) {
|
||||
const char *skip_prefix = "NVIDIA Corporation ";
|
||||
|
||||
if (SDL_strncmp(name, skip_prefix, SDL_strlen(skip_prefix)) == 0) {
|
||||
name += SDL_strlen(skip_prefix);
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the implementation dependent name of a joystick
|
||||
*/
|
||||
|
@ -114,7 +131,7 @@ SDL_JoystickNameForIndex(int device_index)
|
|||
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||
return (NULL);
|
||||
}
|
||||
return (SDL_SYS_JoystickNameForDeviceIndex(device_index));
|
||||
return SDL_FixupJoystickName(SDL_SYS_JoystickNameForDeviceIndex(device_index));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -481,7 +498,7 @@ SDL_JoystickName(SDL_Joystick * joystick)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
return (joystick->name);
|
||||
return SDL_FixupJoystickName(joystick->name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue