SDL_windowshaptic_c.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "../../SDL_internal.h"
  19. #ifndef SDL_windowshaptic_c_h_
  20. #define SDL_windowshaptic_c_h_
  21. #include "SDL_thread.h"
  22. #include "../SDL_syshaptic.h"
  23. #include "../../core/windows/SDL_directx.h"
  24. #include "../../core/windows/SDL_xinput.h"
  25. /* Set up for C function definitions, even when using C++ */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /*
  30. * Haptic system hardware data.
  31. */
  32. struct haptic_hwdata
  33. {
  34. #if SDL_HAPTIC_DINPUT
  35. LPDIRECTINPUTDEVICE8 device;
  36. #endif
  37. DWORD axes[3]; /* Axes to use. */
  38. SDL_bool is_joystick; /* Device is loaded as joystick. */
  39. Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
  40. Uint8 userid; /* XInput userid index for this joystick */
  41. SDL_Thread *thread;
  42. SDL_mutex *mutex;
  43. Uint32 stopTicks;
  44. SDL_atomic_t stopThread;
  45. };
  46. /*
  47. * Haptic system effect data.
  48. */
  49. #if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
  50. struct haptic_hweffect
  51. {
  52. #if SDL_HAPTIC_DINPUT
  53. DIEFFECT effect;
  54. LPDIRECTINPUTEFFECT ref;
  55. #endif
  56. #if SDL_HAPTIC_XINPUT
  57. XINPUT_VIBRATION vibration;
  58. #endif
  59. };
  60. #endif
  61. /*
  62. * List of available haptic devices.
  63. */
  64. typedef struct SDL_hapticlist_item
  65. {
  66. char *name;
  67. SDL_Haptic *haptic;
  68. #if SDL_HAPTIC_DINPUT
  69. DIDEVICEINSTANCE instance;
  70. DIDEVCAPS capabilities;
  71. #endif
  72. SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */
  73. Uint8 userid; /* XInput userid index for this joystick */
  74. struct SDL_hapticlist_item *next;
  75. } SDL_hapticlist_item;
  76. extern SDL_hapticlist_item *SDL_hapticlist;
  77. extern int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item);
  78. extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item);
  79. /* Ends C function definitions when using C++ */
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif /* SDL_windowshaptic_c_h_ */
  84. /* vi: set ts=4 sw=4 expandtab: */