Added ball, touchpad, and sensor support for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/9542
This commit is contained in:
parent
d231edd2ad
commit
c1ba31118b
12 changed files with 494 additions and 41 deletions
|
@ -1235,6 +1235,25 @@ int SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel)
|
||||
{
|
||||
int retval;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#ifdef SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_SetJoystickVirtualBallInner(joystick, ball, xrel, yrel);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
|
||||
{
|
||||
int retval;
|
||||
|
@ -1273,6 +1292,44 @@ int SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
|
||||
{
|
||||
int retval;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#ifdef SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_SetJoystickVirtualTouchpadInner(joystick, touchpad, finger, state, x, y, pressure);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values)
|
||||
{
|
||||
int retval;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
||||
|
||||
#ifdef SDL_JOYSTICK_VIRTUAL
|
||||
retval = SDL_SendJoystickVirtualSensorDataInner(joystick, type, sensor_timestamp, data, num_values);
|
||||
#else
|
||||
retval = SDL_SetError("SDL not built with virtual-joystick support");
|
||||
#endif
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks to make sure the joystick is valid.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue