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