ruby2d 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/assets/README.md +20 -7
  3. data/assets/include/SDL2/SDL.h +135 -0
  4. data/assets/include/SDL2/SDL_assert.h +291 -0
  5. data/assets/include/SDL2/SDL_atomic.h +277 -0
  6. data/assets/include/SDL2/SDL_audio.h +826 -0
  7. data/assets/include/SDL2/SDL_bits.h +112 -0
  8. data/assets/include/SDL2/SDL_blendmode.h +120 -0
  9. data/assets/include/SDL2/SDL_clipboard.h +71 -0
  10. data/assets/include/SDL2/SDL_config.h +421 -0
  11. data/assets/include/SDL2/SDL_cpuinfo.h +188 -0
  12. data/assets/include/SDL2/SDL_egl.h +1673 -0
  13. data/assets/include/SDL2/SDL_endian.h +260 -0
  14. data/assets/include/SDL2/SDL_error.h +76 -0
  15. data/assets/include/SDL2/SDL_events.h +788 -0
  16. data/assets/include/SDL2/SDL_filesystem.h +136 -0
  17. data/assets/include/SDL2/SDL_gamecontroller.h +390 -0
  18. data/assets/include/SDL2/SDL_gesture.h +87 -0
  19. data/assets/include/SDL2/SDL_haptic.h +1238 -0
  20. data/assets/include/SDL2/SDL_hints.h +1135 -0
  21. data/assets/include/SDL2/SDL_image.h +161 -0
  22. data/assets/include/SDL2/SDL_joystick.h +408 -0
  23. data/assets/include/SDL2/SDL_keyboard.h +217 -0
  24. data/assets/include/SDL2/SDL_keycode.h +349 -0
  25. data/assets/include/SDL2/SDL_loadso.h +81 -0
  26. data/assets/include/SDL2/SDL_log.h +211 -0
  27. data/assets/include/SDL2/SDL_main.h +168 -0
  28. data/assets/include/SDL2/SDL_messagebox.h +144 -0
  29. data/assets/include/SDL2/SDL_mixer.h +651 -0
  30. data/assets/include/SDL2/SDL_mouse.h +302 -0
  31. data/assets/include/SDL2/SDL_mutex.h +251 -0
  32. data/assets/include/SDL2/SDL_name.h +33 -0
  33. data/assets/include/SDL2/SDL_opengl.h +2183 -0
  34. data/assets/include/SDL2/SDL_opengl_glext.h +11177 -0
  35. data/assets/include/SDL2/SDL_opengles.h +39 -0
  36. data/assets/include/SDL2/SDL_opengles2.h +52 -0
  37. data/assets/include/SDL2/SDL_opengles2_gl2.h +621 -0
  38. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +2050 -0
  39. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +30 -0
  40. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +282 -0
  41. data/assets/include/SDL2/SDL_pixels.h +470 -0
  42. data/assets/include/SDL2/SDL_platform.h +198 -0
  43. data/assets/include/SDL2/SDL_power.h +75 -0
  44. data/assets/include/SDL2/SDL_quit.h +58 -0
  45. data/assets/include/SDL2/SDL_rect.h +148 -0
  46. data/assets/include/SDL2/SDL_render.h +931 -0
  47. data/assets/include/SDL2/SDL_revision.h +2 -0
  48. data/assets/include/SDL2/SDL_rwops.h +254 -0
  49. data/assets/include/SDL2/SDL_scancode.h +413 -0
  50. data/assets/include/SDL2/SDL_sensor.h +251 -0
  51. data/assets/include/SDL2/SDL_shape.h +144 -0
  52. data/assets/include/SDL2/SDL_stdinc.h +607 -0
  53. data/assets/include/SDL2/SDL_surface.h +553 -0
  54. data/assets/include/SDL2/SDL_system.h +279 -0
  55. data/assets/include/SDL2/SDL_syswm.h +324 -0
  56. data/assets/include/SDL2/SDL_test.h +69 -0
  57. data/assets/include/SDL2/SDL_test_assert.h +105 -0
  58. data/assets/include/SDL2/SDL_test_common.h +188 -0
  59. data/assets/include/SDL2/SDL_test_compare.h +69 -0
  60. data/assets/include/SDL2/SDL_test_crc32.h +124 -0
  61. data/assets/include/SDL2/SDL_test_font.h +81 -0
  62. data/assets/include/SDL2/SDL_test_fuzzer.h +384 -0
  63. data/assets/include/SDL2/SDL_test_harness.h +134 -0
  64. data/assets/include/SDL2/SDL_test_images.h +78 -0
  65. data/assets/include/SDL2/SDL_test_log.h +67 -0
  66. data/assets/include/SDL2/SDL_test_md5.h +129 -0
  67. data/assets/include/SDL2/SDL_test_memory.h +63 -0
  68. data/assets/include/SDL2/SDL_test_random.h +115 -0
  69. data/assets/include/SDL2/SDL_thread.h +343 -0
  70. data/assets/include/SDL2/SDL_timer.h +115 -0
  71. data/assets/include/SDL2/SDL_touch.h +86 -0
  72. data/assets/include/SDL2/SDL_ttf.h +294 -0
  73. data/assets/include/SDL2/SDL_types.h +29 -0
  74. data/assets/include/SDL2/SDL_version.h +162 -0
  75. data/assets/include/SDL2/SDL_video.h +1276 -0
  76. data/assets/include/SDL2/SDL_vulkan.h +278 -0
  77. data/assets/include/SDL2/begin_code.h +167 -0
  78. data/assets/include/SDL2/close_code.h +37 -0
  79. data/assets/include/glew.h +23686 -0
  80. data/assets/include/simple2d.h +735 -0
  81. data/assets/ios/MRuby.framework/Headers/mrbconf.h +3 -5
  82. data/assets/ios/MRuby.framework/Headers/mruby.h +35 -32
  83. data/assets/ios/MRuby.framework/Headers/mruby/array.h +1 -0
  84. data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
  85. data/assets/ios/MRuby.framework/Headers/mruby/class.h +14 -11
  86. data/assets/ios/MRuby.framework/Headers/mruby/common.h +5 -0
  87. data/assets/ios/MRuby.framework/Headers/mruby/compile.h +4 -3
  88. data/assets/ios/MRuby.framework/Headers/mruby/debug.h +3 -2
  89. data/assets/ios/MRuby.framework/Headers/mruby/dump.h +2 -2
  90. data/assets/ios/MRuby.framework/Headers/mruby/hash.h +38 -5
  91. data/assets/ios/MRuby.framework/Headers/mruby/irep.h +17 -4
  92. data/assets/ios/MRuby.framework/Headers/mruby/object.h +4 -5
  93. data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +47 -139
  94. data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
  95. data/assets/ios/MRuby.framework/Headers/mruby/proc.h +4 -4
  96. data/assets/ios/MRuby.framework/Headers/mruby/string.h +11 -7
  97. data/assets/ios/MRuby.framework/Headers/mruby/throw.h +4 -4
  98. data/assets/ios/MRuby.framework/Headers/mruby/variable.h +2 -4
  99. data/assets/ios/MRuby.framework/Headers/mruby/version.h +6 -6
  100. data/assets/ios/MRuby.framework/MRuby +0 -0
  101. data/assets/ios/MyApp.xcodeproj/project.pbxproj +24 -18
  102. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  103. data/assets/ios/main.c +1 -1
  104. data/assets/macos/lib/libFLAC.a +0 -0
  105. data/assets/macos/lib/libSDL2.a +0 -0
  106. data/assets/macos/lib/libSDL2_image.a +0 -0
  107. data/assets/macos/lib/libSDL2_mixer.a +0 -0
  108. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  109. data/assets/macos/lib/libfreetype.a +0 -0
  110. data/assets/macos/lib/libjpeg.a +0 -0
  111. data/assets/macos/lib/libmpg123.a +0 -0
  112. data/assets/macos/lib/libogg.a +0 -0
  113. data/assets/macos/lib/libpng16.a +0 -0
  114. data/assets/macos/lib/libsimple2d.a +0 -0
  115. data/assets/macos/lib/libtiff.a +0 -0
  116. data/assets/macos/lib/libvorbis.a +0 -0
  117. data/assets/macos/lib/libvorbisfile.a +0 -0
  118. data/assets/macos/lib/libwebp.a +0 -0
  119. data/assets/mingw/bin/SDL2.dll +0 -0
  120. data/assets/mingw/bin/SDL2_image.dll +0 -0
  121. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  122. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  123. data/assets/mingw/bin/glew32.dll +0 -0
  124. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  125. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  126. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  127. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  128. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  129. data/assets/mingw/bin/libogg-0.dll +0 -0
  130. data/assets/mingw/bin/libopus-0.dll +0 -0
  131. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  132. data/assets/mingw/bin/libpng16-16.dll +0 -0
  133. data/assets/mingw/bin/libtiff-5.dll +0 -0
  134. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  135. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  136. data/assets/mingw/bin/libwebp-7.dll +0 -0
  137. data/assets/mingw/bin/zlib1.dll +0 -0
  138. data/assets/mingw/lib/libSDL2.a +0 -0
  139. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  140. data/assets/mingw/lib/libSDL2_image.a +0 -0
  141. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  142. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  143. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  144. data/assets/mingw/lib/libSDL2_test.a +0 -0
  145. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  146. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  147. data/assets/mingw/lib/libSDL2main.a +0 -0
  148. data/assets/mingw/lib/libglew32.a +0 -0
  149. data/assets/mingw/lib/libglew32.dll.a +0 -0
  150. data/assets/mingw/lib/libsimple2d.a +0 -0
  151. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
  152. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
  153. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
  154. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
  155. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
  156. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
  157. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +4 -0
  158. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +4 -0
  159. data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +7 -0
  160. data/assets/tvos/MRuby.framework/Headers/mrbconf.h +3 -5
  161. data/assets/tvos/MRuby.framework/Headers/mruby.h +35 -32
  162. data/assets/tvos/MRuby.framework/Headers/mruby/array.h +1 -0
  163. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
  164. data/assets/tvos/MRuby.framework/Headers/mruby/class.h +14 -11
  165. data/assets/tvos/MRuby.framework/Headers/mruby/common.h +5 -0
  166. data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +4 -3
  167. data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +3 -2
  168. data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +2 -2
  169. data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +38 -5
  170. data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +17 -4
  171. data/assets/tvos/MRuby.framework/Headers/mruby/object.h +4 -5
  172. data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +47 -139
  173. data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
  174. data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +4 -4
  175. data/assets/tvos/MRuby.framework/Headers/mruby/string.h +11 -7
  176. data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +4 -4
  177. data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +2 -4
  178. data/assets/tvos/MRuby.framework/Headers/mruby/version.h +6 -6
  179. data/assets/tvos/MRuby.framework/MRuby +0 -0
  180. data/assets/tvos/MyApp.xcodeproj/project.pbxproj +25 -19
  181. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  182. data/assets/tvos/main.c +1 -1
  183. data/ext/ruby2d/extconf.rb +59 -50
  184. data/ext/ruby2d/ruby2d.c +0 -1
  185. data/lib/ruby2d.rb +1 -7
  186. data/lib/ruby2d/cli/launch.rb +1 -1
  187. data/lib/ruby2d/font.rb +32 -7
  188. data/lib/ruby2d/version.rb +1 -1
  189. metadata +132 -6
  190. data/assets/opal.js +0 -21637
  191. data/assets/simple2d.js +0 -1379
  192. data/assets/template.html +0 -18
@@ -0,0 +1,87 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL_gesture.h
24
+ *
25
+ * Include file for SDL gesture event handling.
26
+ */
27
+
28
+ #ifndef SDL_gesture_h_
29
+ #define SDL_gesture_h_
30
+
31
+ #include "SDL_stdinc.h"
32
+ #include "SDL_error.h"
33
+ #include "SDL_video.h"
34
+
35
+ #include "SDL_touch.h"
36
+
37
+
38
+ #include "begin_code.h"
39
+ /* Set up for C function definitions, even when using C++ */
40
+ #ifdef __cplusplus
41
+ extern "C" {
42
+ #endif
43
+
44
+ typedef Sint64 SDL_GestureID;
45
+
46
+ /* Function prototypes */
47
+
48
+ /**
49
+ * \brief Begin Recording a gesture on the specified touch, or all touches (-1)
50
+ *
51
+ *
52
+ */
53
+ extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
54
+
55
+
56
+ /**
57
+ * \brief Save all currently loaded Dollar Gesture templates
58
+ *
59
+ *
60
+ */
61
+ extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
62
+
63
+ /**
64
+ * \brief Save a currently loaded Dollar Gesture template
65
+ *
66
+ *
67
+ */
68
+ extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);
69
+
70
+
71
+ /**
72
+ * \brief Load Dollar Gesture templates from a file
73
+ *
74
+ *
75
+ */
76
+ extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
77
+
78
+
79
+ /* Ends C function definitions when using C++ */
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+ #include "close_code.h"
84
+
85
+ #endif /* SDL_gesture_h_ */
86
+
87
+ /* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,1238 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL_haptic.h
24
+ *
25
+ * \brief The SDL haptic subsystem allows you to control haptic (force feedback)
26
+ * devices.
27
+ *
28
+ * The basic usage is as follows:
29
+ * - Initialize the subsystem (::SDL_INIT_HAPTIC).
30
+ * - Open a haptic device.
31
+ * - SDL_HapticOpen() to open from index.
32
+ * - SDL_HapticOpenFromJoystick() to open from an existing joystick.
33
+ * - Create an effect (::SDL_HapticEffect).
34
+ * - Upload the effect with SDL_HapticNewEffect().
35
+ * - Run the effect with SDL_HapticRunEffect().
36
+ * - (optional) Free the effect with SDL_HapticDestroyEffect().
37
+ * - Close the haptic device with SDL_HapticClose().
38
+ *
39
+ * \par Simple rumble example:
40
+ * \code
41
+ * SDL_Haptic *haptic;
42
+ *
43
+ * // Open the device
44
+ * haptic = SDL_HapticOpen( 0 );
45
+ * if (haptic == NULL)
46
+ * return -1;
47
+ *
48
+ * // Initialize simple rumble
49
+ * if (SDL_HapticRumbleInit( haptic ) != 0)
50
+ * return -1;
51
+ *
52
+ * // Play effect at 50% strength for 2 seconds
53
+ * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0)
54
+ * return -1;
55
+ * SDL_Delay( 2000 );
56
+ *
57
+ * // Clean up
58
+ * SDL_HapticClose( haptic );
59
+ * \endcode
60
+ *
61
+ * \par Complete example:
62
+ * \code
63
+ * int test_haptic( SDL_Joystick * joystick ) {
64
+ * SDL_Haptic *haptic;
65
+ * SDL_HapticEffect effect;
66
+ * int effect_id;
67
+ *
68
+ * // Open the device
69
+ * haptic = SDL_HapticOpenFromJoystick( joystick );
70
+ * if (haptic == NULL) return -1; // Most likely joystick isn't haptic
71
+ *
72
+ * // See if it can do sine waves
73
+ * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) {
74
+ * SDL_HapticClose(haptic); // No sine effect
75
+ * return -1;
76
+ * }
77
+ *
78
+ * // Create the effect
79
+ * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
80
+ * effect.type = SDL_HAPTIC_SINE;
81
+ * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
82
+ * effect.periodic.direction.dir[0] = 18000; // Force comes from south
83
+ * effect.periodic.period = 1000; // 1000 ms
84
+ * effect.periodic.magnitude = 20000; // 20000/32767 strength
85
+ * effect.periodic.length = 5000; // 5 seconds long
86
+ * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength
87
+ * effect.periodic.fade_length = 1000; // Takes 1 second to fade away
88
+ *
89
+ * // Upload the effect
90
+ * effect_id = SDL_HapticNewEffect( haptic, &effect );
91
+ *
92
+ * // Test the effect
93
+ * SDL_HapticRunEffect( haptic, effect_id, 1 );
94
+ * SDL_Delay( 5000); // Wait for the effect to finish
95
+ *
96
+ * // We destroy the effect, although closing the device also does this
97
+ * SDL_HapticDestroyEffect( haptic, effect_id );
98
+ *
99
+ * // Close the device
100
+ * SDL_HapticClose(haptic);
101
+ *
102
+ * return 0; // Success
103
+ * }
104
+ * \endcode
105
+ */
106
+
107
+ #ifndef SDL_haptic_h_
108
+ #define SDL_haptic_h_
109
+
110
+ #include "SDL_stdinc.h"
111
+ #include "SDL_error.h"
112
+ #include "SDL_joystick.h"
113
+
114
+ #include "begin_code.h"
115
+ /* Set up for C function definitions, even when using C++ */
116
+ #ifdef __cplusplus
117
+ extern "C" {
118
+ #endif /* __cplusplus */
119
+
120
+ /* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF).
121
+ *
122
+ * At the moment the magnitude variables are mixed between signed/unsigned, and
123
+ * it is also not made clear that ALL of those variables expect a max of 0x7FFF.
124
+ *
125
+ * Some platforms may have higher precision than that (Linux FF, Windows XInput)
126
+ * so we should fix the inconsistency in favor of higher possible precision,
127
+ * adjusting for platforms that use different scales.
128
+ * -flibit
129
+ */
130
+
131
+ /**
132
+ * \typedef SDL_Haptic
133
+ *
134
+ * \brief The haptic structure used to identify an SDL haptic.
135
+ *
136
+ * \sa SDL_HapticOpen
137
+ * \sa SDL_HapticOpenFromJoystick
138
+ * \sa SDL_HapticClose
139
+ */
140
+ struct _SDL_Haptic;
141
+ typedef struct _SDL_Haptic SDL_Haptic;
142
+
143
+
144
+ /**
145
+ * \name Haptic features
146
+ *
147
+ * Different haptic features a device can have.
148
+ */
149
+ /* @{ */
150
+
151
+ /**
152
+ * \name Haptic effects
153
+ */
154
+ /* @{ */
155
+
156
+ /**
157
+ * \brief Constant effect supported.
158
+ *
159
+ * Constant haptic effect.
160
+ *
161
+ * \sa SDL_HapticCondition
162
+ */
163
+ #define SDL_HAPTIC_CONSTANT (1u<<0)
164
+
165
+ /**
166
+ * \brief Sine wave effect supported.
167
+ *
168
+ * Periodic haptic effect that simulates sine waves.
169
+ *
170
+ * \sa SDL_HapticPeriodic
171
+ */
172
+ #define SDL_HAPTIC_SINE (1u<<1)
173
+
174
+ /**
175
+ * \brief Left/Right effect supported.
176
+ *
177
+ * Haptic effect for direct control over high/low frequency motors.
178
+ *
179
+ * \sa SDL_HapticLeftRight
180
+ * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry,
181
+ * we ran out of bits, and this is important for XInput devices.
182
+ */
183
+ #define SDL_HAPTIC_LEFTRIGHT (1u<<2)
184
+
185
+ /* !!! FIXME: put this back when we have more bits in 2.1 */
186
+ /* #define SDL_HAPTIC_SQUARE (1<<2) */
187
+
188
+ /**
189
+ * \brief Triangle wave effect supported.
190
+ *
191
+ * Periodic haptic effect that simulates triangular waves.
192
+ *
193
+ * \sa SDL_HapticPeriodic
194
+ */
195
+ #define SDL_HAPTIC_TRIANGLE (1u<<3)
196
+
197
+ /**
198
+ * \brief Sawtoothup wave effect supported.
199
+ *
200
+ * Periodic haptic effect that simulates saw tooth up waves.
201
+ *
202
+ * \sa SDL_HapticPeriodic
203
+ */
204
+ #define SDL_HAPTIC_SAWTOOTHUP (1u<<4)
205
+
206
+ /**
207
+ * \brief Sawtoothdown wave effect supported.
208
+ *
209
+ * Periodic haptic effect that simulates saw tooth down waves.
210
+ *
211
+ * \sa SDL_HapticPeriodic
212
+ */
213
+ #define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5)
214
+
215
+ /**
216
+ * \brief Ramp effect supported.
217
+ *
218
+ * Ramp haptic effect.
219
+ *
220
+ * \sa SDL_HapticRamp
221
+ */
222
+ #define SDL_HAPTIC_RAMP (1u<<6)
223
+
224
+ /**
225
+ * \brief Spring effect supported - uses axes position.
226
+ *
227
+ * Condition haptic effect that simulates a spring. Effect is based on the
228
+ * axes position.
229
+ *
230
+ * \sa SDL_HapticCondition
231
+ */
232
+ #define SDL_HAPTIC_SPRING (1u<<7)
233
+
234
+ /**
235
+ * \brief Damper effect supported - uses axes velocity.
236
+ *
237
+ * Condition haptic effect that simulates dampening. Effect is based on the
238
+ * axes velocity.
239
+ *
240
+ * \sa SDL_HapticCondition
241
+ */
242
+ #define SDL_HAPTIC_DAMPER (1u<<8)
243
+
244
+ /**
245
+ * \brief Inertia effect supported - uses axes acceleration.
246
+ *
247
+ * Condition haptic effect that simulates inertia. Effect is based on the axes
248
+ * acceleration.
249
+ *
250
+ * \sa SDL_HapticCondition
251
+ */
252
+ #define SDL_HAPTIC_INERTIA (1u<<9)
253
+
254
+ /**
255
+ * \brief Friction effect supported - uses axes movement.
256
+ *
257
+ * Condition haptic effect that simulates friction. Effect is based on the
258
+ * axes movement.
259
+ *
260
+ * \sa SDL_HapticCondition
261
+ */
262
+ #define SDL_HAPTIC_FRICTION (1u<<10)
263
+
264
+ /**
265
+ * \brief Custom effect is supported.
266
+ *
267
+ * User defined custom haptic effect.
268
+ */
269
+ #define SDL_HAPTIC_CUSTOM (1u<<11)
270
+
271
+ /* @} *//* Haptic effects */
272
+
273
+ /* These last few are features the device has, not effects */
274
+
275
+ /**
276
+ * \brief Device can set global gain.
277
+ *
278
+ * Device supports setting the global gain.
279
+ *
280
+ * \sa SDL_HapticSetGain
281
+ */
282
+ #define SDL_HAPTIC_GAIN (1u<<12)
283
+
284
+ /**
285
+ * \brief Device can set autocenter.
286
+ *
287
+ * Device supports setting autocenter.
288
+ *
289
+ * \sa SDL_HapticSetAutocenter
290
+ */
291
+ #define SDL_HAPTIC_AUTOCENTER (1u<<13)
292
+
293
+ /**
294
+ * \brief Device can be queried for effect status.
295
+ *
296
+ * Device supports querying effect status.
297
+ *
298
+ * \sa SDL_HapticGetEffectStatus
299
+ */
300
+ #define SDL_HAPTIC_STATUS (1u<<14)
301
+
302
+ /**
303
+ * \brief Device can be paused.
304
+ *
305
+ * Devices supports being paused.
306
+ *
307
+ * \sa SDL_HapticPause
308
+ * \sa SDL_HapticUnpause
309
+ */
310
+ #define SDL_HAPTIC_PAUSE (1u<<15)
311
+
312
+
313
+ /**
314
+ * \name Direction encodings
315
+ */
316
+ /* @{ */
317
+
318
+ /**
319
+ * \brief Uses polar coordinates for the direction.
320
+ *
321
+ * \sa SDL_HapticDirection
322
+ */
323
+ #define SDL_HAPTIC_POLAR 0
324
+
325
+ /**
326
+ * \brief Uses cartesian coordinates for the direction.
327
+ *
328
+ * \sa SDL_HapticDirection
329
+ */
330
+ #define SDL_HAPTIC_CARTESIAN 1
331
+
332
+ /**
333
+ * \brief Uses spherical coordinates for the direction.
334
+ *
335
+ * \sa SDL_HapticDirection
336
+ */
337
+ #define SDL_HAPTIC_SPHERICAL 2
338
+
339
+ /* @} *//* Direction encodings */
340
+
341
+ /* @} *//* Haptic features */
342
+
343
+ /*
344
+ * Misc defines.
345
+ */
346
+
347
+ /**
348
+ * \brief Used to play a device an infinite number of times.
349
+ *
350
+ * \sa SDL_HapticRunEffect
351
+ */
352
+ #define SDL_HAPTIC_INFINITY 4294967295U
353
+
354
+
355
+ /**
356
+ * \brief Structure that represents a haptic direction.
357
+ *
358
+ * This is the direction where the force comes from,
359
+ * instead of the direction in which the force is exerted.
360
+ *
361
+ * Directions can be specified by:
362
+ * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates.
363
+ * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
364
+ * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
365
+ *
366
+ * Cardinal directions of the haptic device are relative to the positioning
367
+ * of the device. North is considered to be away from the user.
368
+ *
369
+ * The following diagram represents the cardinal directions:
370
+ * \verbatim
371
+ .--.
372
+ |__| .-------.
373
+ |=.| |.-----.|
374
+ |--| || ||
375
+ | | |'-----'|
376
+ |__|~')_____('
377
+ [ COMPUTER ]
378
+
379
+
380
+ North (0,-1)
381
+ ^
382
+ |
383
+ |
384
+ (-1,0) West <----[ HAPTIC ]----> East (1,0)
385
+ |
386
+ |
387
+ v
388
+ South (0,1)
389
+
390
+
391
+ [ USER ]
392
+ \|||/
393
+ (o o)
394
+ ---ooO-(_)-Ooo---
395
+ \endverbatim
396
+ *
397
+ * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a
398
+ * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses
399
+ * the first \c dir parameter. The cardinal directions would be:
400
+ * - North: 0 (0 degrees)
401
+ * - East: 9000 (90 degrees)
402
+ * - South: 18000 (180 degrees)
403
+ * - West: 27000 (270 degrees)
404
+ *
405
+ * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions
406
+ * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses
407
+ * the first three \c dir parameters. The cardinal directions would be:
408
+ * - North: 0,-1, 0
409
+ * - East: 1, 0, 0
410
+ * - South: 0, 1, 0
411
+ * - West: -1, 0, 0
412
+ *
413
+ * The Z axis represents the height of the effect if supported, otherwise
414
+ * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you
415
+ * can use any multiple you want, only the direction matters.
416
+ *
417
+ * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations.
418
+ * The first two \c dir parameters are used. The \c dir parameters are as
419
+ * follows (all values are in hundredths of degrees):
420
+ * - Degrees from (1, 0) rotated towards (0, 1).
421
+ * - Degrees towards (0, 0, 1) (device needs at least 3 axes).
422
+ *
423
+ *
424
+ * Example of force coming from the south with all encodings (force coming
425
+ * from the south means the user will have to pull the stick to counteract):
426
+ * \code
427
+ * SDL_HapticDirection direction;
428
+ *
429
+ * // Cartesian directions
430
+ * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding.
431
+ * direction.dir[0] = 0; // X position
432
+ * direction.dir[1] = 1; // Y position
433
+ * // Assuming the device has 2 axes, we don't need to specify third parameter.
434
+ *
435
+ * // Polar directions
436
+ * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
437
+ * direction.dir[0] = 18000; // Polar only uses first parameter
438
+ *
439
+ * // Spherical coordinates
440
+ * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding
441
+ * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters.
442
+ * \endcode
443
+ *
444
+ * \sa SDL_HAPTIC_POLAR
445
+ * \sa SDL_HAPTIC_CARTESIAN
446
+ * \sa SDL_HAPTIC_SPHERICAL
447
+ * \sa SDL_HapticEffect
448
+ * \sa SDL_HapticNumAxes
449
+ */
450
+ typedef struct SDL_HapticDirection
451
+ {
452
+ Uint8 type; /**< The type of encoding. */
453
+ Sint32 dir[3]; /**< The encoded direction. */
454
+ } SDL_HapticDirection;
455
+
456
+
457
+ /**
458
+ * \brief A structure containing a template for a Constant effect.
459
+ *
460
+ * This struct is exclusively for the ::SDL_HAPTIC_CONSTANT effect.
461
+ *
462
+ * A constant effect applies a constant force in the specified direction
463
+ * to the joystick.
464
+ *
465
+ * \sa SDL_HAPTIC_CONSTANT
466
+ * \sa SDL_HapticEffect
467
+ */
468
+ typedef struct SDL_HapticConstant
469
+ {
470
+ /* Header */
471
+ Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */
472
+ SDL_HapticDirection direction; /**< Direction of the effect. */
473
+
474
+ /* Replay */
475
+ Uint32 length; /**< Duration of the effect. */
476
+ Uint16 delay; /**< Delay before starting the effect. */
477
+
478
+ /* Trigger */
479
+ Uint16 button; /**< Button that triggers the effect. */
480
+ Uint16 interval; /**< How soon it can be triggered again after button. */
481
+
482
+ /* Constant */
483
+ Sint16 level; /**< Strength of the constant effect. */
484
+
485
+ /* Envelope */
486
+ Uint16 attack_length; /**< Duration of the attack. */
487
+ Uint16 attack_level; /**< Level at the start of the attack. */
488
+ Uint16 fade_length; /**< Duration of the fade. */
489
+ Uint16 fade_level; /**< Level at the end of the fade. */
490
+ } SDL_HapticConstant;
491
+
492
+ /**
493
+ * \brief A structure containing a template for a Periodic effect.
494
+ *
495
+ * The struct handles the following effects:
496
+ * - ::SDL_HAPTIC_SINE
497
+ * - ::SDL_HAPTIC_LEFTRIGHT
498
+ * - ::SDL_HAPTIC_TRIANGLE
499
+ * - ::SDL_HAPTIC_SAWTOOTHUP
500
+ * - ::SDL_HAPTIC_SAWTOOTHDOWN
501
+ *
502
+ * A periodic effect consists in a wave-shaped effect that repeats itself
503
+ * over time. The type determines the shape of the wave and the parameters
504
+ * determine the dimensions of the wave.
505
+ *
506
+ * Phase is given by hundredth of a degree meaning that giving the phase a value
507
+ * of 9000 will displace it 25% of its period. Here are sample values:
508
+ * - 0: No phase displacement.
509
+ * - 9000: Displaced 25% of its period.
510
+ * - 18000: Displaced 50% of its period.
511
+ * - 27000: Displaced 75% of its period.
512
+ * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred.
513
+ *
514
+ * Examples:
515
+ * \verbatim
516
+ SDL_HAPTIC_SINE
517
+ __ __ __ __
518
+ / \ / \ / \ /
519
+ / \__/ \__/ \__/
520
+
521
+ SDL_HAPTIC_SQUARE
522
+ __ __ __ __ __
523
+ | | | | | | | | | |
524
+ | |__| |__| |__| |__| |
525
+
526
+ SDL_HAPTIC_TRIANGLE
527
+ /\ /\ /\ /\ /\
528
+ / \ / \ / \ / \ /
529
+ / \/ \/ \/ \/
530
+
531
+ SDL_HAPTIC_SAWTOOTHUP
532
+ /| /| /| /| /| /| /|
533
+ / | / | / | / | / | / | / |
534
+ / |/ |/ |/ |/ |/ |/ |
535
+
536
+ SDL_HAPTIC_SAWTOOTHDOWN
537
+ \ |\ |\ |\ |\ |\ |\ |
538
+ \ | \ | \ | \ | \ | \ | \ |
539
+ \| \| \| \| \| \| \|
540
+ \endverbatim
541
+ *
542
+ * \sa SDL_HAPTIC_SINE
543
+ * \sa SDL_HAPTIC_LEFTRIGHT
544
+ * \sa SDL_HAPTIC_TRIANGLE
545
+ * \sa SDL_HAPTIC_SAWTOOTHUP
546
+ * \sa SDL_HAPTIC_SAWTOOTHDOWN
547
+ * \sa SDL_HapticEffect
548
+ */
549
+ typedef struct SDL_HapticPeriodic
550
+ {
551
+ /* Header */
552
+ Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT,
553
+ ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or
554
+ ::SDL_HAPTIC_SAWTOOTHDOWN */
555
+ SDL_HapticDirection direction; /**< Direction of the effect. */
556
+
557
+ /* Replay */
558
+ Uint32 length; /**< Duration of the effect. */
559
+ Uint16 delay; /**< Delay before starting the effect. */
560
+
561
+ /* Trigger */
562
+ Uint16 button; /**< Button that triggers the effect. */
563
+ Uint16 interval; /**< How soon it can be triggered again after button. */
564
+
565
+ /* Periodic */
566
+ Uint16 period; /**< Period of the wave. */
567
+ Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */
568
+ Sint16 offset; /**< Mean value of the wave. */
569
+ Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */
570
+
571
+ /* Envelope */
572
+ Uint16 attack_length; /**< Duration of the attack. */
573
+ Uint16 attack_level; /**< Level at the start of the attack. */
574
+ Uint16 fade_length; /**< Duration of the fade. */
575
+ Uint16 fade_level; /**< Level at the end of the fade. */
576
+ } SDL_HapticPeriodic;
577
+
578
+ /**
579
+ * \brief A structure containing a template for a Condition effect.
580
+ *
581
+ * The struct handles the following effects:
582
+ * - ::SDL_HAPTIC_SPRING: Effect based on axes position.
583
+ * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity.
584
+ * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
585
+ * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement.
586
+ *
587
+ * Direction is handled by condition internals instead of a direction member.
588
+ * The condition effect specific members have three parameters. The first
589
+ * refers to the X axis, the second refers to the Y axis and the third
590
+ * refers to the Z axis. The right terms refer to the positive side of the
591
+ * axis and the left terms refer to the negative side of the axis. Please
592
+ * refer to the ::SDL_HapticDirection diagram for which side is positive and
593
+ * which is negative.
594
+ *
595
+ * \sa SDL_HapticDirection
596
+ * \sa SDL_HAPTIC_SPRING
597
+ * \sa SDL_HAPTIC_DAMPER
598
+ * \sa SDL_HAPTIC_INERTIA
599
+ * \sa SDL_HAPTIC_FRICTION
600
+ * \sa SDL_HapticEffect
601
+ */
602
+ typedef struct SDL_HapticCondition
603
+ {
604
+ /* Header */
605
+ Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER,
606
+ ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */
607
+ SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */
608
+
609
+ /* Replay */
610
+ Uint32 length; /**< Duration of the effect. */
611
+ Uint16 delay; /**< Delay before starting the effect. */
612
+
613
+ /* Trigger */
614
+ Uint16 button; /**< Button that triggers the effect. */
615
+ Uint16 interval; /**< How soon it can be triggered again after button. */
616
+
617
+ /* Condition */
618
+ Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */
619
+ Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */
620
+ Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */
621
+ Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */
622
+ Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */
623
+ Sint16 center[3]; /**< Position of the dead zone. */
624
+ } SDL_HapticCondition;
625
+
626
+ /**
627
+ * \brief A structure containing a template for a Ramp effect.
628
+ *
629
+ * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect.
630
+ *
631
+ * The ramp effect starts at start strength and ends at end strength.
632
+ * It augments in linear fashion. If you use attack and fade with a ramp
633
+ * the effects get added to the ramp effect making the effect become
634
+ * quadratic instead of linear.
635
+ *
636
+ * \sa SDL_HAPTIC_RAMP
637
+ * \sa SDL_HapticEffect
638
+ */
639
+ typedef struct SDL_HapticRamp
640
+ {
641
+ /* Header */
642
+ Uint16 type; /**< ::SDL_HAPTIC_RAMP */
643
+ SDL_HapticDirection direction; /**< Direction of the effect. */
644
+
645
+ /* Replay */
646
+ Uint32 length; /**< Duration of the effect. */
647
+ Uint16 delay; /**< Delay before starting the effect. */
648
+
649
+ /* Trigger */
650
+ Uint16 button; /**< Button that triggers the effect. */
651
+ Uint16 interval; /**< How soon it can be triggered again after button. */
652
+
653
+ /* Ramp */
654
+ Sint16 start; /**< Beginning strength level. */
655
+ Sint16 end; /**< Ending strength level. */
656
+
657
+ /* Envelope */
658
+ Uint16 attack_length; /**< Duration of the attack. */
659
+ Uint16 attack_level; /**< Level at the start of the attack. */
660
+ Uint16 fade_length; /**< Duration of the fade. */
661
+ Uint16 fade_level; /**< Level at the end of the fade. */
662
+ } SDL_HapticRamp;
663
+
664
+ /**
665
+ * \brief A structure containing a template for a Left/Right effect.
666
+ *
667
+ * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect.
668
+ *
669
+ * The Left/Right effect is used to explicitly control the large and small
670
+ * motors, commonly found in modern game controllers. The small (right) motor
671
+ * is high frequency, and the large (left) motor is low frequency.
672
+ *
673
+ * \sa SDL_HAPTIC_LEFTRIGHT
674
+ * \sa SDL_HapticEffect
675
+ */
676
+ typedef struct SDL_HapticLeftRight
677
+ {
678
+ /* Header */
679
+ Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */
680
+
681
+ /* Replay */
682
+ Uint32 length; /**< Duration of the effect in milliseconds. */
683
+
684
+ /* Rumble */
685
+ Uint16 large_magnitude; /**< Control of the large controller motor. */
686
+ Uint16 small_magnitude; /**< Control of the small controller motor. */
687
+ } SDL_HapticLeftRight;
688
+
689
+ /**
690
+ * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect.
691
+ *
692
+ * This struct is exclusively for the ::SDL_HAPTIC_CUSTOM effect.
693
+ *
694
+ * A custom force feedback effect is much like a periodic effect, where the
695
+ * application can define its exact shape. You will have to allocate the
696
+ * data yourself. Data should consist of channels * samples Uint16 samples.
697
+ *
698
+ * If channels is one, the effect is rotated using the defined direction.
699
+ * Otherwise it uses the samples in data for the different axes.
700
+ *
701
+ * \sa SDL_HAPTIC_CUSTOM
702
+ * \sa SDL_HapticEffect
703
+ */
704
+ typedef struct SDL_HapticCustom
705
+ {
706
+ /* Header */
707
+ Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */
708
+ SDL_HapticDirection direction; /**< Direction of the effect. */
709
+
710
+ /* Replay */
711
+ Uint32 length; /**< Duration of the effect. */
712
+ Uint16 delay; /**< Delay before starting the effect. */
713
+
714
+ /* Trigger */
715
+ Uint16 button; /**< Button that triggers the effect. */
716
+ Uint16 interval; /**< How soon it can be triggered again after button. */
717
+
718
+ /* Custom */
719
+ Uint8 channels; /**< Axes to use, minimum of one. */
720
+ Uint16 period; /**< Sample periods. */
721
+ Uint16 samples; /**< Amount of samples. */
722
+ Uint16 *data; /**< Should contain channels*samples items. */
723
+
724
+ /* Envelope */
725
+ Uint16 attack_length; /**< Duration of the attack. */
726
+ Uint16 attack_level; /**< Level at the start of the attack. */
727
+ Uint16 fade_length; /**< Duration of the fade. */
728
+ Uint16 fade_level; /**< Level at the end of the fade. */
729
+ } SDL_HapticCustom;
730
+
731
+ /**
732
+ * \brief The generic template for any haptic effect.
733
+ *
734
+ * All values max at 32767 (0x7FFF). Signed values also can be negative.
735
+ * Time values unless specified otherwise are in milliseconds.
736
+ *
737
+ * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767
738
+ * value. Neither delay, interval, attack_length nor fade_length support
739
+ * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.
740
+ *
741
+ * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of
742
+ * ::SDL_HAPTIC_INFINITY.
743
+ *
744
+ * Button triggers may not be supported on all devices, it is advised to not
745
+ * use them if possible. Buttons start at index 1 instead of index 0 like
746
+ * the joystick.
747
+ *
748
+ * If both attack_length and fade_level are 0, the envelope is not used,
749
+ * otherwise both values are used.
750
+ *
751
+ * Common parts:
752
+ * \code
753
+ * // Replay - All effects have this
754
+ * Uint32 length; // Duration of effect (ms).
755
+ * Uint16 delay; // Delay before starting effect.
756
+ *
757
+ * // Trigger - All effects have this
758
+ * Uint16 button; // Button that triggers effect.
759
+ * Uint16 interval; // How soon before effect can be triggered again.
760
+ *
761
+ * // Envelope - All effects except condition effects have this
762
+ * Uint16 attack_length; // Duration of the attack (ms).
763
+ * Uint16 attack_level; // Level at the start of the attack.
764
+ * Uint16 fade_length; // Duration of the fade out (ms).
765
+ * Uint16 fade_level; // Level at the end of the fade.
766
+ * \endcode
767
+ *
768
+ *
769
+ * Here we have an example of a constant effect evolution in time:
770
+ * \verbatim
771
+ Strength
772
+ ^
773
+ |
774
+ | effect level --> _________________
775
+ | / \
776
+ | / \
777
+ | / \
778
+ | / \
779
+ | attack_level --> | \
780
+ | | | <--- fade_level
781
+ |
782
+ +--------------------------------------------------> Time
783
+ [--] [---]
784
+ attack_length fade_length
785
+
786
+ [------------------][-----------------------]
787
+ delay length
788
+ \endverbatim
789
+ *
790
+ * Note either the attack_level or the fade_level may be above the actual
791
+ * effect level.
792
+ *
793
+ * \sa SDL_HapticConstant
794
+ * \sa SDL_HapticPeriodic
795
+ * \sa SDL_HapticCondition
796
+ * \sa SDL_HapticRamp
797
+ * \sa SDL_HapticLeftRight
798
+ * \sa SDL_HapticCustom
799
+ */
800
+ typedef union SDL_HapticEffect
801
+ {
802
+ /* Common for all force feedback effects */
803
+ Uint16 type; /**< Effect type. */
804
+ SDL_HapticConstant constant; /**< Constant effect. */
805
+ SDL_HapticPeriodic periodic; /**< Periodic effect. */
806
+ SDL_HapticCondition condition; /**< Condition effect. */
807
+ SDL_HapticRamp ramp; /**< Ramp effect. */
808
+ SDL_HapticLeftRight leftright; /**< Left/Right effect. */
809
+ SDL_HapticCustom custom; /**< Custom effect. */
810
+ } SDL_HapticEffect;
811
+
812
+
813
+ /* Function prototypes */
814
+ /**
815
+ * \brief Count the number of haptic devices attached to the system.
816
+ *
817
+ * \return Number of haptic devices detected on the system.
818
+ */
819
+ extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
820
+
821
+ /**
822
+ * \brief Get the implementation dependent name of a haptic device.
823
+ *
824
+ * This can be called before any joysticks are opened.
825
+ * If no name can be found, this function returns NULL.
826
+ *
827
+ * \param device_index Index of the device to get its name.
828
+ * \return Name of the device or NULL on error.
829
+ *
830
+ * \sa SDL_NumHaptics
831
+ */
832
+ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
833
+
834
+ /**
835
+ * \brief Opens a haptic device for use.
836
+ *
837
+ * The index passed as an argument refers to the N'th haptic device on this
838
+ * system.
839
+ *
840
+ * When opening a haptic device, its gain will be set to maximum and
841
+ * autocenter will be disabled. To modify these values use
842
+ * SDL_HapticSetGain() and SDL_HapticSetAutocenter().
843
+ *
844
+ * \param device_index Index of the device to open.
845
+ * \return Device identifier or NULL on error.
846
+ *
847
+ * \sa SDL_HapticIndex
848
+ * \sa SDL_HapticOpenFromMouse
849
+ * \sa SDL_HapticOpenFromJoystick
850
+ * \sa SDL_HapticClose
851
+ * \sa SDL_HapticSetGain
852
+ * \sa SDL_HapticSetAutocenter
853
+ * \sa SDL_HapticPause
854
+ * \sa SDL_HapticStopAll
855
+ */
856
+ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
857
+
858
+ /**
859
+ * \brief Checks if the haptic device at index has been opened.
860
+ *
861
+ * \param device_index Index to check to see if it has been opened.
862
+ * \return 1 if it has been opened or 0 if it hasn't.
863
+ *
864
+ * \sa SDL_HapticOpen
865
+ * \sa SDL_HapticIndex
866
+ */
867
+ extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
868
+
869
+ /**
870
+ * \brief Gets the index of a haptic device.
871
+ *
872
+ * \param haptic Haptic device to get the index of.
873
+ * \return The index of the haptic device or -1 on error.
874
+ *
875
+ * \sa SDL_HapticOpen
876
+ * \sa SDL_HapticOpened
877
+ */
878
+ extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
879
+
880
+ /**
881
+ * \brief Gets whether or not the current mouse has haptic capabilities.
882
+ *
883
+ * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't.
884
+ *
885
+ * \sa SDL_HapticOpenFromMouse
886
+ */
887
+ extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
888
+
889
+ /**
890
+ * \brief Tries to open a haptic device from the current mouse.
891
+ *
892
+ * \return The haptic device identifier or NULL on error.
893
+ *
894
+ * \sa SDL_MouseIsHaptic
895
+ * \sa SDL_HapticOpen
896
+ */
897
+ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void);
898
+
899
+ /**
900
+ * \brief Checks to see if a joystick has haptic features.
901
+ *
902
+ * \param joystick Joystick to test for haptic capabilities.
903
+ * \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't
904
+ * or -1 if an error occurred.
905
+ *
906
+ * \sa SDL_HapticOpenFromJoystick
907
+ */
908
+ extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
909
+
910
+ /**
911
+ * \brief Opens a haptic device for use from a joystick device.
912
+ *
913
+ * You must still close the haptic device separately. It will not be closed
914
+ * with the joystick.
915
+ *
916
+ * When opening from a joystick you should first close the haptic device before
917
+ * closing the joystick device. If not, on some implementations the haptic
918
+ * device will also get unallocated and you'll be unable to use force feedback
919
+ * on that device.
920
+ *
921
+ * \param joystick Joystick to create a haptic device from.
922
+ * \return A valid haptic device identifier on success or NULL on error.
923
+ *
924
+ * \sa SDL_HapticOpen
925
+ * \sa SDL_HapticClose
926
+ */
927
+ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *
928
+ joystick);
929
+
930
+ /**
931
+ * \brief Closes a haptic device previously opened with SDL_HapticOpen().
932
+ *
933
+ * \param haptic Haptic device to close.
934
+ */
935
+ extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
936
+
937
+ /**
938
+ * \brief Returns the number of effects a haptic device can store.
939
+ *
940
+ * On some platforms this isn't fully supported, and therefore is an
941
+ * approximation. Always check to see if your created effect was actually
942
+ * created and do not rely solely on SDL_HapticNumEffects().
943
+ *
944
+ * \param haptic The haptic device to query effect max.
945
+ * \return The number of effects the haptic device can store or
946
+ * -1 on error.
947
+ *
948
+ * \sa SDL_HapticNumEffectsPlaying
949
+ * \sa SDL_HapticQuery
950
+ */
951
+ extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
952
+
953
+ /**
954
+ * \brief Returns the number of effects a haptic device can play at the same
955
+ * time.
956
+ *
957
+ * This is not supported on all platforms, but will always return a value.
958
+ * Added here for the sake of completeness.
959
+ *
960
+ * \param haptic The haptic device to query maximum playing effects.
961
+ * \return The number of effects the haptic device can play at the same time
962
+ * or -1 on error.
963
+ *
964
+ * \sa SDL_HapticNumEffects
965
+ * \sa SDL_HapticQuery
966
+ */
967
+ extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
968
+
969
+ /**
970
+ * \brief Gets the haptic device's supported features in bitwise manner.
971
+ *
972
+ * Example:
973
+ * \code
974
+ * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) {
975
+ * printf("We have constant haptic effect!\n");
976
+ * }
977
+ * \endcode
978
+ *
979
+ * \param haptic The haptic device to query.
980
+ * \return Haptic features in bitwise manner (OR'd).
981
+ *
982
+ * \sa SDL_HapticNumEffects
983
+ * \sa SDL_HapticEffectSupported
984
+ */
985
+ extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
986
+
987
+
988
+ /**
989
+ * \brief Gets the number of haptic axes the device has.
990
+ *
991
+ * \sa SDL_HapticDirection
992
+ */
993
+ extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
994
+
995
+ /**
996
+ * \brief Checks to see if effect is supported by haptic.
997
+ *
998
+ * \param haptic Haptic device to check on.
999
+ * \param effect Effect to check to see if it is supported.
1000
+ * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
1001
+ *
1002
+ * \sa SDL_HapticQuery
1003
+ * \sa SDL_HapticNewEffect
1004
+ */
1005
+ extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic,
1006
+ SDL_HapticEffect *
1007
+ effect);
1008
+
1009
+ /**
1010
+ * \brief Creates a new haptic effect on the device.
1011
+ *
1012
+ * \param haptic Haptic device to create the effect on.
1013
+ * \param effect Properties of the effect to create.
1014
+ * \return The identifier of the effect on success or -1 on error.
1015
+ *
1016
+ * \sa SDL_HapticUpdateEffect
1017
+ * \sa SDL_HapticRunEffect
1018
+ * \sa SDL_HapticDestroyEffect
1019
+ */
1020
+ extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic,
1021
+ SDL_HapticEffect * effect);
1022
+
1023
+ /**
1024
+ * \brief Updates the properties of an effect.
1025
+ *
1026
+ * Can be used dynamically, although behavior when dynamically changing
1027
+ * direction may be strange. Specifically the effect may reupload itself
1028
+ * and start playing from the start. You cannot change the type either when
1029
+ * running SDL_HapticUpdateEffect().
1030
+ *
1031
+ * \param haptic Haptic device that has the effect.
1032
+ * \param effect Identifier of the effect to update.
1033
+ * \param data New effect properties to use.
1034
+ * \return 0 on success or -1 on error.
1035
+ *
1036
+ * \sa SDL_HapticNewEffect
1037
+ * \sa SDL_HapticRunEffect
1038
+ * \sa SDL_HapticDestroyEffect
1039
+ */
1040
+ extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic,
1041
+ int effect,
1042
+ SDL_HapticEffect * data);
1043
+
1044
+ /**
1045
+ * \brief Runs the haptic effect on its associated haptic device.
1046
+ *
1047
+ * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over
1048
+ * repeating the envelope (attack and fade) every time. If you only want the
1049
+ * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length
1050
+ * parameter.
1051
+ *
1052
+ * \param haptic Haptic device to run the effect on.
1053
+ * \param effect Identifier of the haptic effect to run.
1054
+ * \param iterations Number of iterations to run the effect. Use
1055
+ * ::SDL_HAPTIC_INFINITY for infinity.
1056
+ * \return 0 on success or -1 on error.
1057
+ *
1058
+ * \sa SDL_HapticStopEffect
1059
+ * \sa SDL_HapticDestroyEffect
1060
+ * \sa SDL_HapticGetEffectStatus
1061
+ */
1062
+ extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic,
1063
+ int effect,
1064
+ Uint32 iterations);
1065
+
1066
+ /**
1067
+ * \brief Stops the haptic effect on its associated haptic device.
1068
+ *
1069
+ * \param haptic Haptic device to stop the effect on.
1070
+ * \param effect Identifier of the effect to stop.
1071
+ * \return 0 on success or -1 on error.
1072
+ *
1073
+ * \sa SDL_HapticRunEffect
1074
+ * \sa SDL_HapticDestroyEffect
1075
+ */
1076
+ extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
1077
+ int effect);
1078
+
1079
+ /**
1080
+ * \brief Destroys a haptic effect on the device.
1081
+ *
1082
+ * This will stop the effect if it's running. Effects are automatically
1083
+ * destroyed when the device is closed.
1084
+ *
1085
+ * \param haptic Device to destroy the effect on.
1086
+ * \param effect Identifier of the effect to destroy.
1087
+ *
1088
+ * \sa SDL_HapticNewEffect
1089
+ */
1090
+ extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
1091
+ int effect);
1092
+
1093
+ /**
1094
+ * \brief Gets the status of the current effect on the haptic device.
1095
+ *
1096
+ * Device must support the ::SDL_HAPTIC_STATUS feature.
1097
+ *
1098
+ * \param haptic Haptic device to query the effect status on.
1099
+ * \param effect Identifier of the effect to query its status.
1100
+ * \return 0 if it isn't playing, 1 if it is playing or -1 on error.
1101
+ *
1102
+ * \sa SDL_HapticRunEffect
1103
+ * \sa SDL_HapticStopEffect
1104
+ */
1105
+ extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic,
1106
+ int effect);
1107
+
1108
+ /**
1109
+ * \brief Sets the global gain of the device.
1110
+ *
1111
+ * Device must support the ::SDL_HAPTIC_GAIN feature.
1112
+ *
1113
+ * The user may specify the maximum gain by setting the environment variable
1114
+ * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to
1115
+ * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the
1116
+ * maximum.
1117
+ *
1118
+ * \param haptic Haptic device to set the gain on.
1119
+ * \param gain Value to set the gain to, should be between 0 and 100.
1120
+ * \return 0 on success or -1 on error.
1121
+ *
1122
+ * \sa SDL_HapticQuery
1123
+ */
1124
+ extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
1125
+
1126
+ /**
1127
+ * \brief Sets the global autocenter of the device.
1128
+ *
1129
+ * Autocenter should be between 0 and 100. Setting it to 0 will disable
1130
+ * autocentering.
1131
+ *
1132
+ * Device must support the ::SDL_HAPTIC_AUTOCENTER feature.
1133
+ *
1134
+ * \param haptic Haptic device to set autocentering on.
1135
+ * \param autocenter Value to set autocenter to, 0 disables autocentering.
1136
+ * \return 0 on success or -1 on error.
1137
+ *
1138
+ * \sa SDL_HapticQuery
1139
+ */
1140
+ extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
1141
+ int autocenter);
1142
+
1143
+ /**
1144
+ * \brief Pauses a haptic device.
1145
+ *
1146
+ * Device must support the ::SDL_HAPTIC_PAUSE feature. Call
1147
+ * SDL_HapticUnpause() to resume playback.
1148
+ *
1149
+ * Do not modify the effects nor add new ones while the device is paused.
1150
+ * That can cause all sorts of weird errors.
1151
+ *
1152
+ * \param haptic Haptic device to pause.
1153
+ * \return 0 on success or -1 on error.
1154
+ *
1155
+ * \sa SDL_HapticUnpause
1156
+ */
1157
+ extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
1158
+
1159
+ /**
1160
+ * \brief Unpauses a haptic device.
1161
+ *
1162
+ * Call to unpause after SDL_HapticPause().
1163
+ *
1164
+ * \param haptic Haptic device to unpause.
1165
+ * \return 0 on success or -1 on error.
1166
+ *
1167
+ * \sa SDL_HapticPause
1168
+ */
1169
+ extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
1170
+
1171
+ /**
1172
+ * \brief Stops all the currently playing effects on a haptic device.
1173
+ *
1174
+ * \param haptic Haptic device to stop.
1175
+ * \return 0 on success or -1 on error.
1176
+ */
1177
+ extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
1178
+
1179
+ /**
1180
+ * \brief Checks to see if rumble is supported on a haptic device.
1181
+ *
1182
+ * \param haptic Haptic device to check to see if it supports rumble.
1183
+ * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
1184
+ *
1185
+ * \sa SDL_HapticRumbleInit
1186
+ * \sa SDL_HapticRumblePlay
1187
+ * \sa SDL_HapticRumbleStop
1188
+ */
1189
+ extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic);
1190
+
1191
+ /**
1192
+ * \brief Initializes the haptic device for simple rumble playback.
1193
+ *
1194
+ * \param haptic Haptic device to initialize for simple rumble playback.
1195
+ * \return 0 on success or -1 on error.
1196
+ *
1197
+ * \sa SDL_HapticOpen
1198
+ * \sa SDL_HapticRumbleSupported
1199
+ * \sa SDL_HapticRumblePlay
1200
+ * \sa SDL_HapticRumbleStop
1201
+ */
1202
+ extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
1203
+
1204
+ /**
1205
+ * \brief Runs simple rumble on a haptic device
1206
+ *
1207
+ * \param haptic Haptic device to play rumble effect on.
1208
+ * \param strength Strength of the rumble to play as a 0-1 float value.
1209
+ * \param length Length of the rumble to play in milliseconds.
1210
+ * \return 0 on success or -1 on error.
1211
+ *
1212
+ * \sa SDL_HapticRumbleSupported
1213
+ * \sa SDL_HapticRumbleInit
1214
+ * \sa SDL_HapticRumbleStop
1215
+ */
1216
+ extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length );
1217
+
1218
+ /**
1219
+ * \brief Stops the simple rumble on a haptic device.
1220
+ *
1221
+ * \param haptic Haptic to stop the rumble on.
1222
+ * \return 0 on success or -1 on error.
1223
+ *
1224
+ * \sa SDL_HapticRumbleSupported
1225
+ * \sa SDL_HapticRumbleInit
1226
+ * \sa SDL_HapticRumblePlay
1227
+ */
1228
+ extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic);
1229
+
1230
+ /* Ends C function definitions when using C++ */
1231
+ #ifdef __cplusplus
1232
+ }
1233
+ #endif
1234
+ #include "close_code.h"
1235
+
1236
+ #endif /* SDL_haptic_h_ */
1237
+
1238
+ /* vi: set ts=4 sw=4 expandtab: */