mirror of https://github.com/libsdl-org/SDL
Fixed joystick vendor detection in Linux automatic gamepad mapping
(cherry picked from commit 071d1e29dd
)
This commit is contained in:
parent
36ff6327b0
commit
7db23f4ef1
|
@ -123,10 +123,10 @@ static SDL_atomic_t SDL_next_joystick_instance_id SDL_GUARDED_BY(SDL_joystick_lo
|
|||
static int SDL_joystick_player_count SDL_GUARDED_BY(SDL_joystick_lock) = 0;
|
||||
static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
||||
static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE;
|
||||
static char joystick_magic;
|
||||
char SDL_joystick_magic;
|
||||
|
||||
#define CHECK_JOYSTICK_MAGIC(joystick, retval) \
|
||||
if (!joystick || joystick->magic != &joystick_magic) { \
|
||||
if (!joystick || joystick->magic != &SDL_joystick_magic) { \
|
||||
SDL_InvalidParamError("joystick"); \
|
||||
SDL_UnlockJoysticks(); \
|
||||
return retval; \
|
||||
|
@ -514,7 +514,7 @@ SDL_Joystick *SDL_JoystickOpen(int device_index)
|
|||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
}
|
||||
joystick->magic = &joystick_magic;
|
||||
joystick->magic = &SDL_joystick_magic;
|
||||
joystick->driver = driver;
|
||||
joystick->instance_id = instance_id;
|
||||
joystick->attached = SDL_TRUE;
|
||||
|
@ -723,7 +723,7 @@ int SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
|||
SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_AssertJoysticksLocked();
|
||||
return (joystick && joystick->magic == &joystick_magic);
|
||||
return (joystick && joystick->magic == &SDL_joystick_magic);
|
||||
}
|
||||
|
||||
SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
|
|
|
@ -34,6 +34,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
struct _SDL_JoystickDriver;
|
||||
extern char SDL_joystick_magic;
|
||||
|
||||
/* Initialization and shutdown functions */
|
||||
extern int SDL_JoystickInit(void);
|
||||
|
|
|
@ -1708,6 +1708,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
|
|||
/* We temporarily open the device to check how it's configured. Make
|
||||
a fake SDL_Joystick object to do so. */
|
||||
joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
|
||||
joystick->magic = &SDL_joystick_magic;
|
||||
if (joystick == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
|
|
Loading…
Reference in New Issue