- [Psy-X] attempt to fix broken SDL2 haptics

This commit is contained in:
Ilya Shurumov 2021-03-31 14:19:43 +06:00
parent 1086d3f937
commit ae78de63ca

View File

@ -61,13 +61,23 @@ void PadInitDirect(unsigned char* pad1, unsigned char* pad2)
// immediately open controllers
int numJoysticks = SDL_NumJoysticks();
for(int i = 0; i < SDL_NumHaptics(); i++)
{
const char* hapticName = SDL_HapticName(0);
eprintwarn("Haptic: '%s'!\n", hapticName);
}
for (int i = 0; i < numJoysticks && i < MAX_CONTROLLERS; i++)
{
if (SDL_IsGameController(i))
{
padHandle[i] = SDL_GameControllerOpen(i); //@TODO close joysticks
padHaptic[i] = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(padHandle[i]));
SDL_Joystick* joy = SDL_GameControllerGetJoystick(padHandle[i]);
SDL_JoystickID id = SDL_JoystickGetDeviceInstanceID(i);
padHaptic[i] = SDL_HapticOpen(id);
if(!padHaptic[i])
{