sdlhaptic.bmx 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. ' Copyright (c) 2015-2022 Bruce A Henderson
  2. '
  3. ' This software is provided 'as-is', without any express or implied
  4. ' warranty. In no event will the authors be held liable for any damages
  5. ' arising from the use of this software.
  6. '
  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. '
  11. ' 1. The origin of this software must not be misrepresented; you must not
  12. ' claim that you wrote the original software. If you use this software
  13. ' in a product, an acknowledgment in the product documentation would be
  14. ' appreciated but is not required.
  15. '
  16. ' 2. Altered source versions must be plainly marked as such, and must not be
  17. ' misrepresented as being the original software.
  18. '
  19. ' 3. This notice may not be removed or altered from any source
  20. ' distribution.
  21. '
  22. SuperStrict
  23. Rem
  24. bbdoc: Control of haptic (force feedback) devices.
  25. End Rem
  26. Module SDL.SDLHaptic
  27. Import SDL.SDLJoystick
  28. Import "common.bmx"
  29. Rem
  30. bbdoc: A haptic device.
  31. End Rem
  32. Type TSDLHaptic
  33. Field hapticPtr:Byte Ptr
  34. Function _create:TSDLHaptic(hapticPtr:Byte Ptr)
  35. If hapticPtr Then
  36. Local this:TSDLHaptic = New TSDLHaptic
  37. this.hapticPtr = hapticPtr
  38. Return this
  39. End If
  40. End Function
  41. Rem
  42. bbdoc: Opens a haptic device for use.
  43. about: The device passed as an argument refers to the N'th haptic device on this system.
  44. When opening a haptic device, its gain will be set to maximum and autocenter will be disabled.
  45. To modify these values use SetGain() and SetAutocenter().
  46. End Rem
  47. Function Open:TSDLHaptic(device:Int)
  48. Return _create(SDL_HapticOpen(device))
  49. End Function
  50. Rem
  51. bbdoc: Opens a haptic device for use from a joystick device.
  52. returns:Aa valid haptic device on success or NULL on failure.
  53. about: You must still close the haptic device separately. It will not be closed with the joystick.
  54. When opened from a joystick you should first close the haptic device before closing the joystick device.
  55. If not, on some implementations the haptic device will also get unallocated and you'll be unable to use force feedback on that device.
  56. End Rem
  57. Function OpenFromJoystick:TSDLHaptic(joystick:TSDLJoystick)
  58. Return _create(SDL_HapticOpenFromJoystick(joystick.joystickPtr))
  59. End Function
  60. Rem
  61. bbdoc: Gets whether or not the current mouse has haptic capabilities.
  62. End Rem
  63. Function MouseIsHaptic:Int()
  64. Return SDL_MouseIsHaptic()
  65. End Function
  66. Rem
  67. bbdoc: Opens a haptic device from the current mouse.
  68. returns: The haptic device or NULL on failure.
  69. End Rem
  70. Function OpenFromMouse:TSDLHaptic()
  71. Return _create(SDL_HapticOpenFromMouse())
  72. End Function
  73. Rem
  74. bbdoc: Counts the number of haptic devices attached to the system.
  75. End Rem
  76. Function NumHaptics:Int()
  77. Return SDL_NumHaptics()
  78. End Function
  79. Rem
  80. bbdoc: Gets the haptic device's supported features in bitwise manner.
  81. returns: A list of supported haptic features in bitwise manner (OR'd), or 0 on failure.
  82. End Rem
  83. Method Query:UInt()
  84. Return SDL_HapticQuery(hapticPtr)
  85. End Method
  86. Rem
  87. bbdoc: Gets the implementation dependent name of the haptic device.
  88. End Rem
  89. Function Name:String(device:Int)
  90. Return String.FromUTF8String(SDL_HapticName(device))
  91. End Function
  92. Rem
  93. bbdoc: Gets the index of the haptic device.
  94. End Rem
  95. Method Index:Int()
  96. Return SDL_HapticIndex(hapticPtr)
  97. End Method
  98. Rem
  99. bbdoc: Checks if the haptic device at the designated index has been opened.
  100. returns: Returns True if it has been opened, False if it hasn't or on failure.
  101. End Rem
  102. Function Opened:Int(device:Int)
  103. Return SDL_HapticOpened(device)
  104. End Function
  105. Rem
  106. bbdoc: Pauses the haptic device.
  107. returns: 0 on success or a negative error code on failure.
  108. End Rem
  109. Method Pause:Int()
  110. Return SDL_HapticPause(hapticPtr)
  111. End Method
  112. Rem
  113. bbdoc: Unpauses the haptic device.
  114. about: 0 on success or a negative error code on failure.
  115. End Rem
  116. Method Unpause:Int()
  117. Return SDL_HapticUnpause(hapticPtr)
  118. End Method
  119. Rem
  120. bbdoc: Stops all the currently playing effects on the haptic device.
  121. returns: 0 on success or a negative error code on failure.
  122. End Rem
  123. Method StopAll:Int()
  124. Return SDL_HapticStopAll(hapticPtr)
  125. End Method
  126. Rem
  127. bbdoc: Gets the number of haptic axes the device has.
  128. about: The number of haptic axes might be useful if working with the #Direction effect.
  129. End Rem
  130. Method NumAxes:Int()
  131. Return SDL_HapticNumAxes(hapticPtr)
  132. End Method
  133. Rem
  134. bbdoc: Checks to see if an effect is supported by a haptic device.
  135. about: True if effect is supported, False if it isn't, or a negative error code on failure.
  136. End Rem
  137. Method EffectSupported:Int(effect:TSDLHapticEffect)
  138. Return SDL_HapticEffectSupported(hapticPtr, effect.effectPtr)
  139. End Method
  140. Rem
  141. bbdoc: Gets the number of effects a haptic device can store.
  142. about: On some platforms this isn't fully supported, and therefore is an approximation.
  143. Always check to see if your created effect was actually created and do not rely solely on #NumEffects().
  144. End Rem
  145. Method NumEffects:Int()
  146. Return SDL_HapticNumEffects(hapticPtr)
  147. End Method
  148. Rem
  149. bbdoc: Gets the number of effects a haptic device can play at the same time.
  150. about: This is not supported on all platforms, but will always return a value. Added here for the sake of completeness.
  151. End Rem
  152. Method NumEffectsPlaying:Int()
  153. Return SDL_HapticNumEffectsPlaying(hapticPtr)
  154. End Method
  155. Rem
  156. bbdoc: Creates a new haptic effect on the device.
  157. returns: The ID of the effect on success or a negative error code on failure.
  158. End Rem
  159. Method NewEffect:Int(effect:TSDLHapticEffect)
  160. Return SDL_HapticNewEffect(hapticPtr, effect.effectPtr)
  161. End Method
  162. Rem
  163. bbdoc: Runs the effect on the device.
  164. returns: 0 on success or a negative error code on failure.
  165. about: If iterations are SDL_HAPTIC_INFINITY, it'll run the effect over and over repeating the envelope (attack and fade) every time.
  166. If you only want the effect to last forever, set SDL_HAPTIC_INFINITY in the effect's length parameter.
  167. End Rem
  168. Method RunEffect:Int(effect:Int, iterations:UInt)
  169. Return SDL_HapticRunEffect(hapticPtr, effect, iterations)
  170. End Method
  171. Rem
  172. bbdoc: Stops the haptic effect on the device.
  173. returns: 0 on success or a negative error code on failure.
  174. End Rem
  175. Method StopEffect:Int(effect:Int)
  176. Return SDL_HapticStopEffect(hapticPtr, effect)
  177. End Method
  178. Rem
  179. bbdoc: Gets the status of the current effect on the haptic device.
  180. returns: 0 if it isn't playing, 1 if it is playing, or a negative error code on failure.
  181. about: Device must support the #SDL_HAPTIC_STATUS feature.
  182. End Rem
  183. Method EffectStatus:Int(effect:Int)
  184. Return SDL_HapticGetEffectStatus(hapticPtr, effect)
  185. End Method
  186. Rem
  187. bbdoc: Destroys the haptic effect on the device.
  188. about: This will stop the effect if it's running. Effects are automatically destroyed when the device is closed.
  189. End Rem
  190. Method DestroyEffect(effect:Int)
  191. SDL_HapticDestroyEffect(hapticPtr, effect)
  192. End Method
  193. Rem
  194. bbdoc: Initializes the haptic device for simple rumble playback.
  195. returns: 0 on success or a negative error code on failure.
  196. End Rem
  197. Method RumbleInit:Int()
  198. Return SDL_HapticRumbleInit(hapticPtr)
  199. End Method
  200. Rem
  201. bbdoc: Runs a simple rumble effect on a haptic device.
  202. End Rem
  203. Method RumblePlay:Int(strength:Float, length:UInt)
  204. Return SDL_HapticRumblePlay(hapticPtr, strength, length)
  205. End Method
  206. Rem
  207. bbdoc: Stops the simple rumble on the haptic device.
  208. returns: 0 on success or a negative error code on failure.
  209. End Rem
  210. Method RumbleStop:Int()
  211. Return SDL_HapticRumbleStop(hapticPtr)
  212. End Method
  213. Rem
  214. bbdoc: Checks whether rumble is supported on the haptic device.
  215. End Rem
  216. Method RumbleSupported:Int()
  217. Return SDL_HapticRumbleSupported(hapticPtr)
  218. End Method
  219. Rem
  220. bbdoc: Sets the global autocenter of the haptic device.
  221. returns: 0 on success or a negative error code on failure.
  222. End Rem
  223. Method SetAutocenter:Int(value:Int)
  224. Return SDL_HapticSetAutocenter(hapticPtr, value)
  225. End Method
  226. Rem
  227. bbdoc: Sets the global gain of the haptic device.
  228. End Rem
  229. Method SetGain:Int(value:Int)
  230. Return SDL_HapticSetGain(hapticPtr, value)
  231. End Method
  232. Rem
  233. bbdoc: Closes the haptic device.
  234. End Rem
  235. Method Close()
  236. If hapticPtr Then
  237. SDL_HapticClose(hapticPtr)
  238. hapticPtr = Null
  239. End If
  240. End Method
  241. Method Delete()
  242. If hapticPtr Then
  243. Close()
  244. End If
  245. End Method
  246. End Type
  247. Rem
  248. bbdoc: The direction where the force comes from, instead of the direction in which the force is exerted.
  249. about: Cardinal directions of the haptic device are relative to the positioning of the device. North is
  250. considered to be away from the user. South is toward the user, east is right, and west is left of the user.
  251. End Rem
  252. Type TSDLHapticDirection
  253. Field dirPtr:Byte Ptr
  254. Function _create:TSDLHapticDirection(dirPtr:Byte Ptr)
  255. If dirPtr Then
  256. Local this:TSDLHapticDirection = New TSDLHapticDirection
  257. this.dirPtr = dirPtr
  258. Return this
  259. End If
  260. End Function
  261. Rem
  262. bbdoc: Sets the type of encoding.
  263. about: One of #SDL_HAPTIC_POLAR, #SDL_HAPTIC_CARTESIAN or #SDL_HAPTIC_SPHERICAL.
  264. End Rem
  265. Method SetType(value:Int)
  266. bmx_sdl_haptic_SDLHapticDirection_SetType(dirPtr, value)
  267. End Method
  268. Rem
  269. bbdoc:
  270. End Rem
  271. Method SetDir(x:Short, y:Short = 0, z:Short = 0)
  272. bmx_sdl_haptic_SDLHapticDirection_SetDir(dirPtr, x, y, z)
  273. End Method
  274. End Type
  275. Rem
  276. bbdoc: A generic template for any haptic effect.
  277. End Rem
  278. Type TSDLHapticEffect
  279. Field effectPtr:Byte Ptr
  280. Rem
  281. bbdoc: Frees the effect.
  282. End Rem
  283. Method Free()
  284. If effectPtr Then
  285. bmx_sdl_haptic_SDLHapticEffect_free(effectPtr)
  286. effectPtr = Null
  287. End If
  288. End Method
  289. Method Delete()
  290. Free()
  291. End Method
  292. End Type
  293. Rem
  294. bbdoc: A constant effect applies a constant force to the joystick in the specified direction.
  295. End Rem
  296. Type TSDLHapticConstant Extends TSDLHapticEffect
  297. Rem
  298. bbdoc: Creates a new instance of the effect.
  299. End Rem
  300. Method New()
  301. effectPtr = bmx_sdl_haptic_SDLHapticConstant_new()
  302. End Method
  303. Rem
  304. bbdoc: Returns the duration of effect (ms).
  305. End Rem
  306. Method GetLength:UInt()
  307. Return bmx_sdl_haptic_SDLHapticConstant_GetLength(effectPtr)
  308. End Method
  309. Rem
  310. bbdoc: Returns the delay before starting effect.
  311. End Rem
  312. Method GetDelay:Short()
  313. Return bmx_sdl_haptic_SDLHapticConstant_GetDelay(effectPtr)
  314. End Method
  315. Rem
  316. bbdoc: Returns the button that triggers effect.
  317. End Rem
  318. Method GetButton:Short()
  319. Return bmx_sdl_haptic_SDLHapticConstant_GetButton(effectPtr)
  320. End Method
  321. Rem
  322. bbdoc: Returns how soon before effect can be triggered again.
  323. End Rem
  324. Method GetInterval:Short()
  325. Return bmx_sdl_haptic_SDLHapticConstant_GetInterval(effectPtr)
  326. End Method
  327. Rem
  328. bbdoc: Returns the duration of the attack (ms).
  329. End Rem
  330. Method GetAttackLength:Short()
  331. Return bmx_sdl_haptic_SDLHapticConstant_GetAttackLength(effectPtr)
  332. End Method
  333. Rem
  334. bbdoc: Returns the level at the start of the attack.
  335. End Rem
  336. Method GetAttackLevel:Short()
  337. Return bmx_sdl_haptic_SDLHapticConstant_GetAttackLevel(effectPtr)
  338. End Method
  339. Rem
  340. bbdoc: Returns the duration of the fade out (ms).
  341. End Rem
  342. Method GetFadeLength:Short()
  343. Return bmx_sdl_haptic_SDLHapticConstant_GetFadeLength(effectPtr)
  344. End Method
  345. Rem
  346. bbdoc: Returns the level at the end of the fade.
  347. End Rem
  348. Method GetFadeLevel:Short()
  349. Return bmx_sdl_haptic_SDLHapticConstant_GetFadeLevel(effectPtr)
  350. End Method
  351. Rem
  352. bbdoc: Returns the effect direction.
  353. about: This instance is owned by the effect, and any changes will apply only to this effect.
  354. End Rem
  355. Method Direction:TSDLHapticDirection()
  356. Return TSDLHapticDirection._create(bmx_sdl_haptic_SDLHapticConstant_Direction(effectPtr))
  357. End Method
  358. Rem
  359. bbdoc: Sets the duration of the effect.
  360. about: You can pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
  361. End Rem
  362. Method SetLength(value:UInt)
  363. bmx_sdl_haptic_SDLHapticConstant_SetLength(effectPtr, value)
  364. End Method
  365. Rem
  366. bbdoc: Sets the delay before starting the effect.
  367. End Rem
  368. Method SetDelay(value:Short)
  369. bmx_sdl_haptic_SDLHapticConstant_SetDelay(effectPtr, value)
  370. End Method
  371. Rem
  372. bbdoc: Sets the button that triggers the effect.
  373. End Rem
  374. Method SetButton(value:Short)
  375. bmx_sdl_haptic_SDLHapticConstant_SetButton(effectPtr, value)
  376. End Method
  377. Rem
  378. bbdoc: Sets how soon it can be triggered again after button.
  379. End Rem
  380. Method SetInterval(value:Short)
  381. bmx_sdl_haptic_SDLHapticConstant_SetInterval(effectPtr, value)
  382. End Method
  383. Rem
  384. bbdoc: Sets the strength of the constant effect.
  385. End Rem
  386. Method SetLevel(value:Int)
  387. bmx_sdl_haptic_SDLHapticConstant_SetLevel(effectPtr, value)
  388. End Method
  389. Rem
  390. bbdoc: Sets the duration of the attack.
  391. End Rem
  392. Method SetAttackLength(value:Short)
  393. bmx_sdl_haptic_SDLHapticConstant_SetAttackLength(effectPtr, value)
  394. End Method
  395. Rem
  396. bbdoc: Sets the level at the start of the attack.
  397. End Rem
  398. Method SetAttackLevel(value:Short)
  399. bmx_sdl_haptic_SDLHapticConstant_SetAttackLevel(effectPtr, value)
  400. End Method
  401. Rem
  402. bbdoc: Sets the duration of the fade.
  403. End Rem
  404. Method SetFadeLength(value:Short)
  405. bmx_sdl_haptic_SDLHapticConstant_SetFadeLength(effectPtr, value)
  406. End Method
  407. Rem
  408. bbdoc: Sets the level at the end of the fade.
  409. End Rem
  410. Method SetFadeLevel(value:Short)
  411. bmx_sdl_haptic_SDLHapticConstant_SetFadeLevel(effectPtr, value)
  412. End Method
  413. End Type
  414. Rem
  415. bbdoc: A wave-shaped effect that repeats itself over time.
  416. about: The type determines the shape of the wave and the other parameters determine the dimensions of the wave.
  417. End Rem
  418. Type TSDLHapticPeriodic Extends TSDLHapticEffect
  419. Rem
  420. bbdoc: Creates a new instance of the effect.
  421. about: @waveType one of #SDL_HAPTIC_SINE, #SDL_HAPTIC_LEFTRIGHT, #SDL_HAPTIC_TRIANGLE, #SDL_HAPTIC_SAWTOOTHUP or #SDL_HAPTIC_SAWTOOTHDOWN.
  422. End Rem
  423. Method New(waveType:Int)
  424. effectPtr = bmx_sdl_haptic_SDLHapticPeriodic_new(waveType)
  425. End Method
  426. Rem
  427. bbdoc: Returns the duration of effect (ms).
  428. End Rem
  429. Method GetLength:UInt()
  430. Return bmx_sdl_haptic_SDLHapticPeriodic_GetLength(effectPtr)
  431. End Method
  432. Rem
  433. bbdoc: Returns the delay before starting effect.
  434. End Rem
  435. Method GetDelay:Short()
  436. Return bmx_sdl_haptic_SDLHapticPeriodic_GetDelay(effectPtr)
  437. End Method
  438. Rem
  439. bbdoc: Returns the button that triggers effect.
  440. End Rem
  441. Method GetButton:Short()
  442. Return bmx_sdl_haptic_SDLHapticPeriodic_GetButton(effectPtr)
  443. End Method
  444. Rem
  445. bbdoc: Returns how soon before effect can be triggered again.
  446. End Rem
  447. Method GetInterval:Short()
  448. Return bmx_sdl_haptic_SDLHapticPeriodic_GetInterval(effectPtr)
  449. End Method
  450. Rem
  451. bbdoc: Returns the duration of the attack (ms).
  452. End Rem
  453. Method GetAttackLength:Short()
  454. Return bmx_sdl_haptic_SDLHapticPeriodic_GetAttackLength(effectPtr)
  455. End Method
  456. Rem
  457. bbdoc: Returns the level at the start of the attack.
  458. End Rem
  459. Method GetAttackLevel:Short()
  460. Return bmx_sdl_haptic_SDLHapticPeriodic_GetAttackLevel(effectPtr)
  461. End Method
  462. Rem
  463. bbdoc: Returns the duration of the fade out (ms).
  464. End Rem
  465. Method GetFadeLength:Short()
  466. Return bmx_sdl_haptic_SDLHapticPeriodic_GetFadeLength(effectPtr)
  467. End Method
  468. Rem
  469. bbdoc: Returns the level at the end of the fade.
  470. End Rem
  471. Method GetFadeLevel:Short()
  472. Return bmx_sdl_haptic_SDLHapticPeriodic_GetFadeLevel(effectPtr)
  473. End Method
  474. Rem
  475. bbdoc: Returns the effect direction.
  476. about: This instance is owned by the effect, and any changes will apply only to this effect.
  477. End Rem
  478. Method Direction:TSDLHapticDirection()
  479. Return TSDLHapticDirection._create(bmx_sdl_haptic_SDLHapticPeriodic_Direction(effectPtr))
  480. End Method
  481. Rem
  482. bbdoc: Sets the duration of the effect.
  483. about: You can pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
  484. End Rem
  485. Method SetLength(value:UInt)
  486. bmx_sdl_haptic_SDLHapticPeriodic_SetLength(effectPtr, value)
  487. End Method
  488. Rem
  489. bbdoc: Sets the delay before starting the effect.
  490. End Rem
  491. Method SetDelay(value:Short)
  492. bmx_sdl_haptic_SDLHapticPeriodic_SetDelay(effectPtr, value)
  493. End Method
  494. Rem
  495. bbdoc: Sets the button that triggers the effect.
  496. End Rem
  497. Method SetButton(value:Short)
  498. bmx_sdl_haptic_SDLHapticPeriodic_SetButton(effectPtr, value)
  499. End Method
  500. Rem
  501. bbdoc: Sets how soon it can be triggered again after button.
  502. End Rem
  503. Method SetInterval(value:Short)
  504. bmx_sdl_haptic_SDLHapticPeriodic_SetInterval(effectPtr, value)
  505. End Method
  506. Rem
  507. bbdoc: Sets the period of the wave.
  508. End Rem
  509. Method SetPeriod(value:Short)
  510. bmx_sdl_haptic_SDLHapticPeriodic_SetPeriod(effectPtr, value)
  511. End Method
  512. Rem
  513. bbdoc: Sets the peak value
  514. about: Ff negative, equivalent to 180 degrees extra phase shift
  515. End Rem
  516. Method SetMagnitude(value:Int)
  517. bmx_sdl_haptic_SDLHapticPeriodic_SetMagnitude(effectPtr, value)
  518. End Method
  519. Rem
  520. bbdoc: Sets the mean value of the wave.
  521. End Rem
  522. Method SetOffset(value:Int)
  523. bmx_sdl_haptic_SDLHapticPeriodic_SetOffset(effectPtr, value)
  524. End Method
  525. Rem
  526. bbdoc: Sets the positive phase shift given by hundredth of a degree.
  527. about: Phase is given by hundredths of a degree, meaning that giving the phase a value of 9000
  528. will displace it 25% of its period. Here are sample values:
  529. <p>0 - No phase displacement</p>
  530. <p>9000 - Displaced 25% of its period</p>
  531. <p>18000 - Displaced 50% of its period</p>
  532. <p>27000 - Displaced 75% of its period</p>
  533. <p>36000 - Displaced 100% of its period, same as 0, but 0 is preferred</p>
  534. End Rem
  535. Method SetPhase(value:Short)
  536. bmx_sdl_haptic_SDLHapticPeriodic_SetPhase(effectPtr, value)
  537. End Method
  538. Rem
  539. bbdoc: Sets the duration of the attack.
  540. End Rem
  541. Method SetAttackLength(value:Short)
  542. bmx_sdl_haptic_SDLHapticPeriodic_SetAttackLength(effectPtr, value)
  543. End Method
  544. Rem
  545. bbdoc: Sets the level at the start of the attack.
  546. End Rem
  547. Method SetAttackLevel(value:Short)
  548. bmx_sdl_haptic_SDLHapticPeriodic_SetAttackLevel(effectPtr, value)
  549. End Method
  550. Rem
  551. bbdoc: Sets the duration of the fade.
  552. End Rem
  553. Method SetFadeLength(value:Short)
  554. bmx_sdl_haptic_SDLHapticPeriodic_SetFadeLength(effectPtr, value)
  555. End Method
  556. Rem
  557. bbdoc: Sets the level at the end of the fade.
  558. End Rem
  559. Method SetFadeLevel(value:Short)
  560. bmx_sdl_haptic_SDLHapticPeriodic_SetFadeLevel(effectPtr, value)
  561. End Method
  562. End Type
  563. Rem
  564. bbdoc: A template for a condition effect.
  565. End Rem
  566. Type TSDLHapticCondition Extends TSDLHapticEffect
  567. Rem
  568. bbdoc: Creates a new instance of the effect.
  569. about: @effectType one of #SDL_HAPTIC_SPRING, #SDL_HAPTIC_DAMPER, #SDL_HAPTIC_INERTIA, #SDL_HAPTIC_FRICTION
  570. End Rem
  571. Method New(effectType:Int)
  572. effectPtr = bmx_sdl_haptic_SDLHapticCondition_new(effectType)
  573. End Method
  574. Rem
  575. bbdoc: Returns the duration of effect (ms).
  576. End Rem
  577. Method GetLength:UInt()
  578. Return bmx_sdl_haptic_SDLHapticCondition_GetLength(effectPtr)
  579. End Method
  580. Rem
  581. bbdoc: Returns the delay before starting effect.
  582. End Rem
  583. Method GetDelay:Short()
  584. Return bmx_sdl_haptic_SDLHapticCondition_GetDelay(effectPtr)
  585. End Method
  586. Rem
  587. bbdoc: Returns the button that triggers effect.
  588. End Rem
  589. Method GetButton:Short()
  590. Return bmx_sdl_haptic_SDLHapticCondition_GetButton(effectPtr)
  591. End Method
  592. Rem
  593. bbdoc: Returns how soon before effect can be triggered again.
  594. End Rem
  595. Method GetInterval:Short()
  596. Return bmx_sdl_haptic_SDLHapticCondition_GetInterval(effectPtr)
  597. End Method
  598. Rem
  599. bbdoc: Returns the effect direction.
  600. about: This instance is owned by the effect, and any changes will apply only to this effect.
  601. End Rem
  602. Method Direction:TSDLHapticDirection()
  603. Return TSDLHapticDirection._create(bmx_sdl_haptic_SDLHapticCondition_Direction(effectPtr))
  604. End Method
  605. Rem
  606. bbdoc: Sets the duration of the effect.
  607. about: You can pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
  608. End Rem
  609. Method SetLength(value:UInt)
  610. bmx_sdl_haptic_SDLHapticCondition_SetLength(effectPtr, value)
  611. End Method
  612. Rem
  613. bbdoc: Sets the delay before starting the effect.
  614. End Rem
  615. Method SetDelay(value:Short)
  616. bmx_sdl_haptic_SDLHapticCondition_SetDelay(effectPtr, value)
  617. End Method
  618. Rem
  619. bbdoc: Sets the button that triggers the effect.
  620. End Rem
  621. Method SetButton(value:Short)
  622. bmx_sdl_haptic_SDLHapticCondition_SetButton(effectPtr, value)
  623. End Method
  624. Rem
  625. bbdoc: Sets how soon it can be triggered again after button.
  626. End Rem
  627. Method SetInterval(value:Short)
  628. bmx_sdl_haptic_SDLHapticCondition_SetInterval(effectPtr, value)
  629. End Method
  630. Rem
  631. bbdoc: Sets level when joystick is to the positive side.
  632. about: max = $FFFF
  633. End Rem
  634. Method SetRightSat(x:Short, y:Short = 0, z:Short = 0)
  635. bmx_sdl_haptic_SDLHapticCondition_SetRightSat(effectPtr, x, y, z)
  636. End Method
  637. Rem
  638. bbdoc: Sets level when joystick is to the negative side.
  639. about: max = $FFFF
  640. End Rem
  641. Method SetLeftSat(x:Short, y:Short = 0, z:Short = 0)
  642. bmx_sdl_haptic_SDLHapticCondition_SetLeftSat(effectPtr, x, y, z)
  643. End Method
  644. Rem
  645. bbdoc: Sets how fast to increase the force towards the positive side.
  646. End Rem
  647. Method SetRightCoeff(x:Int, y:Int = 0, z:Int = 0)
  648. bmx_sdl_haptic_SDLHapticCondition_SetRightCoeff(effectPtr, x, y, z)
  649. End Method
  650. Rem
  651. bbdoc: Sets how fast to increase the force towards the negative side.
  652. End Rem
  653. Method SetLeftCoeff(x:Int, y:Int = 0, z:Int = 0)
  654. bmx_sdl_haptic_SDLHapticCondition_SetLeftCoeff(effectPtr, x, y, z)
  655. End Method
  656. Rem
  657. bbdoc: Sets the size of the dead zone.
  658. about: max = $FFFF: whole axis-range when 0-centered
  659. End Rem
  660. Method SetDeadband(x:Short, y:Short = 0, z:Short = 0)
  661. bmx_sdl_haptic_SDLHapticCondition_SetDeadband(effectPtr, x, y, z)
  662. End Method
  663. Rem
  664. bbdoc: Sets the position of the dead zone.
  665. End Rem
  666. Method SetCenter(x:Int, y:Int = 0, z:Int = 0)
  667. bmx_sdl_haptic_SDLHapticCondition_SetCenter(effectPtr, x, y, z)
  668. End Method
  669. End Type
  670. Rem
  671. bbdoc: A template for a ramp effect.
  672. about: The ramp effect starts at start strength and ends at end strength.
  673. It augments in linear fashion. If you use attack and fade with a ramp the effects get added to the ramp effect
  674. making the effect become quadratic instead of linear.
  675. End Rem
  676. Type TSDLHapticRamp Extends TSDLHapticEffect
  677. Rem
  678. bbdoc: Creates a new instance of the effect.
  679. End Rem
  680. Method New()
  681. effectPtr = bmx_sdl_haptic_SDLHapticRamp_new()
  682. End Method
  683. Rem
  684. bbdoc: Returns the duration of effect (ms).
  685. End Rem
  686. Method GetLength:UInt()
  687. Return bmx_sdl_haptic_SDLHapticRamp_GetLength(effectPtr)
  688. End Method
  689. Rem
  690. bbdoc: Returns the delay before starting effect.
  691. End Rem
  692. Method GetDelay:Short()
  693. Return bmx_sdl_haptic_SDLHapticRamp_GetDelay(effectPtr)
  694. End Method
  695. Rem
  696. bbdoc: Returns the button that triggers effect.
  697. End Rem
  698. Method GetButton:Short()
  699. Return bmx_sdl_haptic_SDLHapticRamp_GetButton(effectPtr)
  700. End Method
  701. Rem
  702. bbdoc: Returns how soon before effect can be triggered again.
  703. End Rem
  704. Method GetInterval:Short()
  705. Return bmx_sdl_haptic_SDLHapticRamp_GetInterval(effectPtr)
  706. End Method
  707. Rem
  708. bbdoc: Returns the duration of the attack (ms).
  709. End Rem
  710. Method GetAttackLength:Short()
  711. Return bmx_sdl_haptic_SDLHapticRamp_GetAttackLength(effectPtr)
  712. End Method
  713. Rem
  714. bbdoc: Returns the level at the start of the attack.
  715. End Rem
  716. Method GetAttackLevel:Short()
  717. Return bmx_sdl_haptic_SDLHapticRamp_GetAttackLevel(effectPtr)
  718. End Method
  719. Rem
  720. bbdoc: Returns the duration of the fade out (ms).
  721. End Rem
  722. Method GetFadeLength:Short()
  723. Return bmx_sdl_haptic_SDLHapticRamp_GetFadeLength(effectPtr)
  724. End Method
  725. Rem
  726. bbdoc: Returns the level at the end of the fade.
  727. End Rem
  728. Method GetFadeLevel:Short()
  729. Return bmx_sdl_haptic_SDLHapticRamp_GetFadeLevel(effectPtr)
  730. End Method
  731. Rem
  732. bbdoc: Returns the effect direction.
  733. about: This instance is owned by the effect, and any changes will apply only to this effect.
  734. End Rem
  735. Method Direction:TSDLHapticDirection()
  736. Return TSDLHapticDirection._create(bmx_sdl_haptic_SDLHapticRamp_Direction(effectPtr))
  737. End Method
  738. Rem
  739. bbdoc: Sets the duration of the effect.
  740. about: This effect does not support a duration of SDL_HAPTIC_INFINITY.
  741. End Rem
  742. Method SetLength(value:UInt)
  743. bmx_sdl_haptic_SDLHapticRamp_SetLength(effectPtr, value)
  744. End Method
  745. Rem
  746. bbdoc: Sets the delay before starting the effect.
  747. End Rem
  748. Method SetDelay(value:Short)
  749. bmx_sdl_haptic_SDLHapticRamp_SetDelay(effectPtr, value)
  750. End Method
  751. Rem
  752. bbdoc: Sets the button that triggers the effect.
  753. End Rem
  754. Method SetButton(value:Short)
  755. bmx_sdl_haptic_SDLHapticRamp_SetButton(effectPtr, value)
  756. End Method
  757. Rem
  758. bbdoc: Sets how soon it can be triggered again after button.
  759. End Rem
  760. Method SetInterval(value:Short)
  761. bmx_sdl_haptic_SDLHapticRamp_SetInterval(effectPtr, value)
  762. End Method
  763. Rem
  764. bbdoc: Sets the beginning strength level.
  765. End Rem
  766. Method SetStart(value:Int)
  767. bmx_sdl_haptic_SDLHapticRamp_SetStart(effectPtr, value)
  768. End Method
  769. Rem
  770. bbdoc: Sets the ending strength level.
  771. End Rem
  772. Method SetEnd(value:Int)
  773. bmx_sdl_haptic_SDLHapticRamp_SetEnd(effectPtr, value)
  774. End Method
  775. Rem
  776. bbdoc: Sets the duration of the attack.
  777. End Rem
  778. Method SetAttackLength(value:Short)
  779. bmx_sdl_haptic_SDLHapticRamp_SetAttackLength(effectPtr, value)
  780. End Method
  781. Rem
  782. bbdoc: Sets the level at the start of the attack.
  783. End Rem
  784. Method SetAttackLevel(value:Short)
  785. bmx_sdl_haptic_SDLHapticRamp_SetAttackLevel(effectPtr, value)
  786. End Method
  787. Rem
  788. bbdoc: Sets the duration of the fade.
  789. End Rem
  790. Method SetFadeLength(value:Short)
  791. bmx_sdl_haptic_SDLHapticRamp_SetFadeLength(effectPtr, value)
  792. End Method
  793. Rem
  794. bbdoc: Sets the level at the end of the fade.
  795. End Rem
  796. Method SetFadeLevel(value:Short)
  797. bmx_sdl_haptic_SDLHapticRamp_SetFadeLevel(effectPtr, value)
  798. End Method
  799. End Type
  800. Rem
  801. bbdoc: Controls the large and small motors, commonly found in modern game controllers.
  802. about: One motor is high frequency, the other is low frequency.
  803. End Rem
  804. Type TSDLHapticLeftRight Extends TSDLHapticEffect
  805. Rem
  806. bbdoc: Creates a new instance of the effect.
  807. End Rem
  808. Method New()
  809. effectPtr = bmx_sdl_haptic_SDLHapticLeftRight_new()
  810. End Method
  811. Rem
  812. bbdoc: Sets the duration of the effect.
  813. End Rem
  814. Method SetLength(value:UInt)
  815. bmx_sdl_haptic_SDLHapticLeftRight_SetLength(effectPtr, value)
  816. End Method
  817. Rem
  818. bbdoc: Sets the control of the large controller motor.
  819. End Rem
  820. Method SetLargeMagnitude(value:Short)
  821. bmx_sdl_haptic_SDLHapticLeftRight_SetLargeMagnitude(effectPtr, value)
  822. End Method
  823. Rem
  824. bbdoc: Sets the control of the small controller motor.
  825. End Rem
  826. Method SetSmallMagnitude(value:Short)
  827. bmx_sdl_haptic_SDLHapticLeftRight_SetSmallMagnitude(effectPtr, value)
  828. End Method
  829. End Type
  830. Rem
  831. bbdoc: A custom force feedback effect.
  832. about: The effect is much like a periodic effect, where the application can define its exact shape.
  833. You will have to allocate the data yourself. data should consist of channels * samples Short samples.
  834. If channels is 1, the effect is rotated using the defined direction. Otherwise it uses the samples in data for the different axes.
  835. End Rem
  836. Type TSDLHapticCustom Extends TSDLHapticEffect
  837. Rem
  838. bbdoc: Creates a new instance of the effect.
  839. End Rem
  840. Method New()
  841. effectPtr = bmx_sdl_haptic_SDLHapticCustom_new()
  842. End Method
  843. Rem
  844. bbdoc: Returns the duration of effect (ms).
  845. End Rem
  846. Method GetLength:UInt()
  847. Return bmx_sdl_haptic_SDLHapticCustom_GetLength(effectPtr)
  848. End Method
  849. Rem
  850. bbdoc: Returns the delay before starting effect.
  851. End Rem
  852. Method GetDelay:Short()
  853. Return bmx_sdl_haptic_SDLHapticCustom_GetDelay(effectPtr)
  854. End Method
  855. Rem
  856. bbdoc: Returns the button that triggers effect.
  857. End Rem
  858. Method GetButton:Short()
  859. Return bmx_sdl_haptic_SDLHapticCustom_GetButton(effectPtr)
  860. End Method
  861. Rem
  862. bbdoc: Returns how soon before effect can be triggered again.
  863. End Rem
  864. Method GetInterval:Short()
  865. Return bmx_sdl_haptic_SDLHapticCustom_GetInterval(effectPtr)
  866. End Method
  867. Rem
  868. bbdoc: Returns the duration of the attack (ms).
  869. End Rem
  870. Method GetAttackLength:Short()
  871. Return bmx_sdl_haptic_SDLHapticCustom_GetAttackLength(effectPtr)
  872. End Method
  873. Rem
  874. bbdoc: Returns the level at the start of the attack.
  875. End Rem
  876. Method GetAttackLevel:Short()
  877. Return bmx_sdl_haptic_SDLHapticCustom_GetAttackLevel(effectPtr)
  878. End Method
  879. Rem
  880. bbdoc: Returns the duration of the fade out (ms).
  881. End Rem
  882. Method GetFadeLength:Short()
  883. Return bmx_sdl_haptic_SDLHapticCustom_GetFadeLength(effectPtr)
  884. End Method
  885. Rem
  886. bbdoc: Returns the level at the end of the fade.
  887. End Rem
  888. Method GetFadeLevel:Short()
  889. Return bmx_sdl_haptic_SDLHapticCustom_GetFadeLevel(effectPtr)
  890. End Method
  891. Rem
  892. bbdoc: Returns the effect direction.
  893. about: This instance is owned by the effect, and any changes will apply only to this effect.
  894. End Rem
  895. Method Direction:TSDLHapticDirection()
  896. Return TSDLHapticDirection._create(bmx_sdl_haptic_SDLHapticCustom_Direction(effectPtr))
  897. End Method
  898. Rem
  899. bbdoc: Sets the duration of the effect.
  900. about: You can pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
  901. End Rem
  902. Method SetLength(value:UInt)
  903. bmx_sdl_haptic_SDLHapticCustom_SetLength(effectPtr, value)
  904. End Method
  905. Rem
  906. bbdoc: Sets the delay before starting the effect.
  907. End Rem
  908. Method SetDelay(value:Short)
  909. bmx_sdl_haptic_SDLHapticCustom_SetDelay(effectPtr, value)
  910. End Method
  911. Rem
  912. bbdoc: Sets the button that triggers the effect.
  913. End Rem
  914. Method SetButton(value:Short)
  915. bmx_sdl_haptic_SDLHapticCustom_SetButton(effectPtr, value)
  916. End Method
  917. Rem
  918. bbdoc: Sets how soon it can be triggered again after button.
  919. End Rem
  920. Method SetInterval(value:Short)
  921. bmx_sdl_haptic_SDLHapticCustom_SetInterval(effectPtr, value)
  922. End Method
  923. Rem
  924. bbdoc: Sets the axes to use, minimum of 1.
  925. about: If channels is 1, the effect is rotated using the defined direction. Otherwise it uses the samples in data for the different axes.
  926. End Rem
  927. Method SetChannels(value:Byte)
  928. bmx_sdl_haptic_SDLHapticCustom_SetChannels(effectPtr, value)
  929. End Method
  930. Rem
  931. bbdoc: Sets the sample periods.
  932. End Rem
  933. Method SetPeriod(value:Byte)
  934. bmx_sdl_haptic_SDLHapticCustom_SetChannels(effectPtr, value)
  935. End Method
  936. Rem
  937. bbdoc: Sets the samples data.
  938. End Rem
  939. Method SetData(data:Short[])
  940. bmx_sdl_haptic_SDLHapticCustom_SetData(effectPtr, data, data.length)
  941. End Method
  942. Rem
  943. bbdoc: Sets the duration of the attack.
  944. End Rem
  945. Method SetAttackLength(value:Short)
  946. bmx_sdl_haptic_SDLHapticCustom_SetAttackLength(effectPtr, value)
  947. End Method
  948. Rem
  949. bbdoc: Sets the level at the start of the attack.
  950. End Rem
  951. Method SetAttackLevel(value:Short)
  952. bmx_sdl_haptic_SDLHapticCustom_SetAttackLevel(effectPtr, value)
  953. End Method
  954. Rem
  955. bbdoc: Sets the duration of the fade.
  956. End Rem
  957. Method SetFadeLength(value:Short)
  958. bmx_sdl_haptic_SDLHapticCustom_SetFadeLength(effectPtr, value)
  959. End Method
  960. Rem
  961. bbdoc: Sets the level at the end of the fade.
  962. End Rem
  963. Method SetFadeLevel(value:Short)
  964. bmx_sdl_haptic_SDLHapticCustom_SetFadeLevel(effectPtr, value)
  965. End Method
  966. End Type
  967. SDL_InitSubSystem(SDL_INIT_HAPTIC)