21 #include "../../SDL_internal.h"
25 #include "../SDL_syshaptic.h"
33 #include "../../core/windows/SDL_xinput.h"
34 #include "../../joystick/windows/SDL_windowsjoystick_c.h"
35 #include "../../thread/SDL_systhread.h"
47 loaded_xinput = (WIN_LoadXInputDLL() == 0);
52 for (
i = 0;
i < XUSER_MAX_COUNT;
i++) {
64 XINPUT_VIBRATION
state;
66 if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) {
78 if (XINPUTSETSTATE(dwUserid, &
state) != ERROR_SUCCESS) {
115 if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) {
144 SDL_RunXInputHaptic(
void *arg)
154 XINPUT_VIBRATION vibration = { 0, 0 };
156 XINPUTSETSTATE(hwdata->
userid, &vibration);
169 XINPUT_VIBRATION vibration = { 0, 0 };
170 XINPUTSETSTATE(
userid, &vibration);
195 haptic->hwdata->bXInputHaptic = 1;
203 return SDL_SetError(
"Couldn't create XInput haptic mutex");
214 return SDL_SetError(
"Couldn't create XInput haptic thread");
223 return SDL_XINPUT_HapticOpenFromUserIndex(
haptic, item->
userid);
242 return SDL_XINPUT_HapticOpenFromUserIndex(
haptic,
joystick->hwdata->userid);
247 SDL_SetError(
"Couldn't find joystick in haptic device list");
263 WIN_UnloadXInputDLL();
278 XINPUT_VIBRATION *vib = &effect->
hweffect->vibration;
281 vib->wLeftMotorSpeed =
data->leftright.large_magnitude * 2;
282 vib->wRightMotorSpeed =
data->leftright.small_magnitude * 2;
284 if (
haptic->hwdata->stopTicks) {
285 XINPUTSETSTATE(
haptic->hwdata->userid, vib);
294 XINPUT_VIBRATION *vib = &effect->
hweffect->vibration;
304 haptic->hwdata->stopTicks = 1;
308 return (XINPUTSETSTATE(
haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
314 XINPUT_VIBRATION vibration = { 0, 0 };
316 haptic->hwdata->stopTicks = 0;
318 return (XINPUTSETSTATE(
haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1;
360 XINPUT_VIBRATION vibration = { 0, 0 };
362 haptic->hwdata->stopTicks = 0;
364 return (XINPUTSETSTATE(
haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1;
369 #include "../../core/windows/SDL_windows.h"
#define SDL_assert(condition)
#define SDL_GetHintBoolean
#define SDL_OutOfMemory()
#define SDL_Unsupported()
The SDL haptic subsystem allows you to control haptic (force feedback) devices.
#define SDL_HAPTIC_INFINITY
Used to play a device an infinite number of times.
#define SDL_HAPTIC_LEFTRIGHT
Left/Right effect supported.
#define SDL_HINT_XINPUT_ENABLED
A variable that lets you disable the detection and use of Xinput gamepad devices.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
SDL_Thread * SDL_CreateThreadInternal(int(*fn)(void *), const char *name, const size_t stacksize, void *data)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
SDL_hapticlist_item * SDL_hapticlist
int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst base
struct SDL_hapticlist_item * next
struct haptic_hweffect * hweffect
static SDL_Haptic * haptic
static SDL_Joystick * joystick
The generic template for any haptic effect.
SDL_HapticLeftRight leftright