sdlhaptic.inc 45 KB

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