🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1341 lines
42 KiB

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