openbor
openbor copied to clipboard
SDL_GameControllerRumbe / SDL_JoystickRumble support
Is your feature request related to a problem? Please describe. no
Describe the solution you'd like Replace or add support new SDL API : SDL_JoystickRumble
Describe alternatives you've considered In sdl/control.c : (propose idea but not sur if correct, i just make a little test on my machine with Xbox360 controller (joystick and not haptic) )
// port seem wrong in this function
void control_rumble(int port, int ratio, int msec) { #if SDL if (joystick[port-1] != NULL && joystick_haptic[port-1] == NULL) { SDL_JoystickRumble(joystick[port-1], 0xFFFF, 0xFFFF, msec); } else if (joystick[port-1] != NULL && joystick_haptic[port-1] != NULL) { if(SDL_HapticRumblePlay(joystick_haptic[port-1], ratio, msec) != 0) { //printf( "Warning: Unable to play rumble! %s\n", SDL_GetError() ); } } #endif }
Additional context
For last version in control.c
void control_rumble(int deviceID, int ratio, int msec) { if (msec == 0) return;
if (devices[deviceID].haptic)
{
if (SDL_HapticRumblePlay(devices[deviceID].haptic, ratio, msec) != 0)
{
printf("Warning: Unable to play rumble! %s\n", SDL_GetError());
}
}
if (devices[deviceID].deviceType == DEVICE_TYPE_CONTROLLER)
{
SDL_GameControllerRumble(devices[deviceID].controller, (Uint16)(ratio*65535),(Uint16)(ratio*65535), msec);
}
if (devices[deviceID].deviceType == DEVICE_TYPE_JOYSTICK)
{
SDL_JoystickRumble(devices[deviceID].joystick, (Uint16)(ratio*65535),(Uint16)(ratio*65535), msec);
}
}