SDL_haptic.h 38 KB

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