21#include "../../SDL_internal.h"
25#include "../SDL_syshaptic.h"
34#include "../../core/windows/SDL_xinput.h"
35#include "../../joystick/windows/SDL_windowsjoystick_c.h"
36#include "../../thread/SDL_systhread.h"
48 loaded_xinput = (WIN_LoadXInputDLL() == 0);
53 for (
i = 0;
i < XUSER_MAX_COUNT;
i++) {
65 XINPUT_VIBRATION
state;
67 if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) {
79 if (XINPUTSETSTATE(dwUserid, &
state) != ERROR_SUCCESS) {
116 if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) {
145SDL_RunXInputHaptic(
void *arg)
155 XINPUT_VIBRATION vibration = { 0, 0 };
157 XINPUTSETSTATE(hwdata->
userid, &vibration);
170 XINPUT_VIBRATION vibration = { 0, 0 };
171 XINPUTSETSTATE(
userid, &vibration);
196 haptic->hwdata->bXInputHaptic = 1;
204 return SDL_SetError(
"Couldn't create XInput haptic mutex");
215 return SDL_SetError(
"Couldn't create XInput haptic thread");
224 return SDL_XINPUT_HapticOpenFromUserIndex(
haptic, item->
userid);
230 return (
haptic->hwdata->userid == joystick->hwdata->userid);
243 return SDL_XINPUT_HapticOpenFromUserIndex(
haptic, joystick->hwdata->userid);
248 SDL_SetError(
"Couldn't find joystick in haptic device list");
264 WIN_UnloadXInputDLL();
279 XINPUT_VIBRATION *vib = &effect->
hweffect->vibration;
282 vib->wLeftMotorSpeed =
data->leftright.large_magnitude * 2;
283 vib->wRightMotorSpeed =
data->leftright.small_magnitude * 2;
285 if (
haptic->hwdata->stopTicks) {
286 XINPUTSETSTATE(
haptic->hwdata->userid, vib);
295 XINPUT_VIBRATION *vib = &effect->
hweffect->vibration;
305 haptic->hwdata->stopTicks = 1;
309 return (XINPUTSETSTATE(
haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
315 XINPUT_VIBRATION vibration = { 0, 0 };
317 haptic->hwdata->stopTicks = 0;
319 return (XINPUTSETSTATE(
haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1;
361 XINPUT_VIBRATION vibration = { 0, 0 };
363 haptic->hwdata->stopTicks = 0;
365 return (XINPUTSETSTATE(
haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1;
370#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)
struct SDL_hapticlist_item * next
struct haptic_hweffect * hweffect
static SDL_Haptic * haptic
The generic template for any haptic effect.
SDL_HapticLeftRight leftright