mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
parent
b23983c0b8
commit
2d1009e815
3 changed files with 22 additions and 14 deletions
|
@ -178,14 +178,31 @@ void BUTTONGLYPHS_keyboard_set_active(bool active)
|
|||
keyboard_is_active = active;
|
||||
}
|
||||
|
||||
void BUTTONGLYPHS_update_layout(Uint16 vendor, Uint16 product)
|
||||
void BUTTONGLYPHS_update_layout(SDL_GameController *c)
|
||||
{
|
||||
Uint16 vendor = SDL_GameControllerGetVendor(c);
|
||||
Uint16 product = SDL_GameControllerGetProduct(c);
|
||||
|
||||
if (vendor == 0x054c)
|
||||
{
|
||||
layout = LAYOUT_PLAYSTATION;
|
||||
}
|
||||
else if (vendor == 0x28de)
|
||||
{
|
||||
/* Steam Virtual Gamepads can hypothetically tell us that the physical
|
||||
* device is a PlayStation controller, so try to catch that scenario */
|
||||
const char *mapping = SDL_GameControllerMapping(c);
|
||||
if (SDL_strstr(mapping, "type:") != NULL)
|
||||
{
|
||||
SDL_GameControllerType gct = SDL_GameControllerGetType(c);
|
||||
if ( gct == SDL_CONTROLLER_TYPE_PS3 ||
|
||||
gct == SDL_CONTROLLER_TYPE_PS4 ||
|
||||
gct == SDL_CONTROLLER_TYPE_PS5 )
|
||||
{
|
||||
layout = LAYOUT_PLAYSTATION;
|
||||
return;
|
||||
}
|
||||
}
|
||||
layout = LAYOUT_DECK;
|
||||
}
|
||||
else if (vendor == 0x057e)
|
||||
|
|
|
@ -17,7 +17,7 @@ bool BUTTONGLYPHS_keyboard_is_available(void);
|
|||
bool BUTTONGLYPHS_keyboard_is_active(void);
|
||||
void BUTTONGLYPHS_keyboard_set_active(bool active);
|
||||
|
||||
void BUTTONGLYPHS_update_layout(Uint16 vendor, Uint16 product);
|
||||
void BUTTONGLYPHS_update_layout(SDL_GameController *c);
|
||||
|
||||
const char* BUTTONGLYPHS_get_wasd_text(void);
|
||||
const char* BUTTONGLYPHS_get_button(ActionSet actionset, Action action, int binding);
|
||||
|
|
|
@ -280,10 +280,7 @@ void KeyPoll::Poll(void)
|
|||
BUTTONGLYPHS_keyboard_set_active(false);
|
||||
|
||||
controller = controllers[evt.cbutton.which];
|
||||
BUTTONGLYPHS_update_layout(
|
||||
SDL_GameControllerGetVendor(controller),
|
||||
SDL_GameControllerGetProduct(controller)
|
||||
);
|
||||
BUTTONGLYPHS_update_layout(controller);
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
||||
|
@ -319,10 +316,7 @@ void KeyPoll::Poll(void)
|
|||
BUTTONGLYPHS_keyboard_set_active(false);
|
||||
|
||||
controller = controllers[evt.caxis.which];
|
||||
BUTTONGLYPHS_update_layout(
|
||||
SDL_GameControllerGetVendor(controller),
|
||||
SDL_GameControllerGetProduct(controller)
|
||||
);
|
||||
BUTTONGLYPHS_update_layout(controller);
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
|
@ -335,10 +329,7 @@ void KeyPoll::Poll(void)
|
|||
);
|
||||
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))] = controller;
|
||||
BUTTONGLYPHS_keyboard_set_active(false);
|
||||
BUTTONGLYPHS_update_layout(
|
||||
SDL_GameControllerGetVendor(controller),
|
||||
SDL_GameControllerGetProduct(controller)
|
||||
);
|
||||
BUTTONGLYPHS_update_layout(controller);
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
|
|
Loading…
Reference in a new issue