blib/lib/SDL2/haptic.pm untested

filter: Statementstmt 0.0% 0 / 109 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod n/a totaltotal 0.0% 0 / 122 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package SDL2::haptic 0.01 {
2 use SDL2::Utils;
3 #
4 use SDL2::stdinc;
5 use SDL2::error;
6 use SDL2::joystick;
7  
8 package SDL2::Haptic 0.01 {
9 use SDL2::Utils;
10 our $TYPE = has();
11 };
12 define haptic => [
13 [ SDL_HAPTIC_CONSTANT => ( 1 << 0 ) ],
14 [ SDL_HAPTIC_SINE => ( 1 << 1 ) ],
15 [ SDL_HAPTIC_LEFTRIGHT => ( 1 << 2 ) ],
16 [ SDL_HAPTIC_TRIANGLE => ( 1 << 3 ) ],
17 [ SDL_HAPTIC_SAWTOOTHUP => ( 1 << 4 ) ],
18 [ SDL_HAPTIC_SAWTOOTHDOWN => ( 1 << 5 ) ],
19 [ SDL_HAPTIC_RAMP => ( 1 << 6 ) ],
20 [ SDL_HAPTIC_SPRING => ( 1 << 7 ) ],
21 [ SDL_HAPTIC_DAMPER => ( 1 << 8 ) ],
22 [ SDL_HAPTIC_INERTIA => ( 1 << 9 ) ],
23 [ SDL_HAPTIC_FRICTION => ( 1 << 10 ) ],
24 [ SDL_HAPTIC_CUSTOM => ( 1 << 11 ) ],
25 [ SDL_HAPTIC_GAIN => ( 1 << 12 ) ],
26 [ SDL_HAPTIC_AUTOCENTER => ( 1 << 13 ) ],
27 [ SDL_HAPTIC_STATUS => ( 1 << 14 ) ],
28 [ SDL_HAPTIC_PAUSE => ( 1 << 15 ) ],
29 [ SDL_HAPTIC_POLAR => 0 ],
30 [ SDL_HAPTIC_CARTESIAN => 1 ],
31 [ SDL_HAPTIC_SPHERICAL => 2 ],
32 [ SDL_HAPTIC_STEERING_AXIS => 3 ],
33 [ SDL_HAPTIC_INFINITY => 4294967295 ]
34 ];
35  
36 package SDL2::HapticDirection {
37 use SDL2::Utils;
38 our $TYPE = has
39 type => 'uint8',
40 dir => 'sint32[3]';
41 };
42  
43 package SDL2::HapticConstant {
44 use SDL2::Utils;
45 our $TYPE = has
46  
47 # Header
48 type => 'uint16',
49 direction => 'SDL_HapticDirection',
50  
51 # Replay
52 length => 'uint32',
53 delay => 'uint16',
54  
55 # Trigger
56 button => 'uint16',
57 interval => 'uint16',
58  
59 # Constant
60 level => 'sint16',
61  
62 # Envelope
63 attack_length => 'uint16',
64 attack_level => 'uint16',
65 fade_length => 'uint16',
66 fade_level => 'uint16';
67 };
68  
69 package SDL2::HapticPeriodic {
70 use SDL2::Utils;
71 our $TYPE = has
72  
73 # Header
74 type => 'uint16',
75 direction => 'SDL_HapticDirection',
76  
77 # Replay
78 length => 'uint32',
79 delay => 'uint16',
80  
81 # Trigger
82 button => 'uint16',
83 interval => 'uint16',
84  
85 # Periodic
86 period => 'sint16',
87 magnitude => 'sint16',
88 offset => 'sint16',
89 phase => 'uint16',
90  
91 # Envelope
92 attack_length => 'uint16',
93 attack_level => 'uint16',
94 fade_length => 'uint16',
95 fade_level => 'uint16';
96 };
97  
98 package SDL2::HapticCondition {
99 use SDL2::Utils;
100 our $TYPE = has
101  
102 # Header
103 type => 'uint16',
104 direction => 'SDL_HapticDirection',
105  
106 # Replay
107 length => 'uint32',
108 delay => 'uint16',
109  
110 # Trigger
111 button => 'uint16',
112 interval => 'uint16',
113  
114 # Condition
115 right_sat => 'uint16[3]',
116 left_sat => 'uint16[3]',
117 right_coeff => 'sint16[3]',
118 left_coeff => 'sint16[3]',
119 deadband => 'uint16[3]',
120 center => 'sint16[3]';
121 };
122  
123 package SDL2::HapticRamp {
124 use SDL2::Utils;
125 our $TYPE = has
126  
127 # Header
128 type => 'uint16',
129 direction => 'SDL_HapticDirection',
130  
131 # Replay
132 length => 'uint32',
133 delay => 'uint16',
134  
135 # Trigger
136 button => 'uint16',
137 interval => 'uint16',
138  
139 # Ramp
140 start => 'sint16',
141 end => 'sint16',
142  
143 # Envelope
144 attack_length => 'uint16',
145 attack_level => 'uint16',
146 fade_length => 'uint16',
147 fade_level => 'uint16';
148 };
149  
150 package SDL2::HapticLeftRight {
151 use SDL2::Utils;
152 our $TYPE = has
153  
154 # Header
155 type => 'uint16',
156  
157 # Replay
158 length => 'uint32',
159  
160 # Rumble
161 large_magnitude => 'uint16',
162 small_magnitude => 'uint16';
163 };
164  
165 package SDL2::HapticCustom {
166 use SDL2::Utils;
167 our $TYPE = has
168  
169 # Header
170 type => 'uint16',
171 direction => 'SDL_HapticDirection',
172  
173 # Replay
174 length => 'uint32',
175 delay => 'uint16',
176  
177 # Trigger
178 button => 'uint16',
179 interval => 'uint16',
180  
181 # Custom
182 channels => 'uint8',
183 period => 'uint16',
184 samples => 'uint16',
185 data => 'opaque', # uint16 *
186  
187 # Envelope
188 attack_length => 'uint16',
189 attack_level => 'uint16',
190 fade_length => 'uint16',
191 fade_level => 'uint16';
192 };
193  
194 package SDL2::HapticEffect {
195 use SDL2::Utils;
196 is 'Union';
197 has
198 type => 'uint16',
199 constant => 'SDL_HapticConstant',
200 periodic => 'SDL_HapticPeriodic',
201 condition => 'SDL_HapticCondition',
202 ramp => 'SDL_HapticRamp',
203 leftright => 'SDL_HapticLeftRight',
204 custom => 'SDL_HapticCustom';
205 };
206 attach haptic => {
207 SDL_NumHaptics => [ [], 'int' ],
208 SDL_HapticName => [ ['int'], 'string' ],
209 SDL_HapticOpen => [ ['int'], 'SDL_Haptic' ],
210 SDL_HapticOpened => [ ['int'], 'int' ],
211 SDL_HapticIndex => [ ['SDL_Haptic'], 'int' ],
212 SDL_MouseIsHaptic => [ [], 'int' ],
213 SDL_HapticOpenFromMouse => [ [], 'SDL_Haptic' ],
214 SDL_JoystickIsHaptic => [ ['SDL_Joystick'], 'int' ],
215 SDL_HapticOpenFromJoystick => [ ['SDL_Joystick'], 'SDL_Haptic' ],
216 SDL_HapticClose => [ ['SDL_Haptic'] ],
217 SDL_HapticNumEffects => [ ['SDL_Haptic'], 'int' ],
218 SDL_HapticNumEffectsPlaying => [ ['SDL_Haptic'], 'int' ],
219 SDL_HapticQuery => [ ['SDL_Haptic'], 'int' ],
220 SDL_HapticNumAxes => [ ['SDL_Haptic'], 'int' ],
221 SDL_HapticEffectSupported => [ [ 'SDL_Haptic', 'SDL_HapticEffect' ], 'int' ],
222 SDL_HapticNewEffect => [ [ 'SDL_Haptic', 'SDL_HapticEffect' ], 'int' ],
223 SDL_HapticUpdateEffect => [ [ 'SDL_Haptic', 'int', 'SDL_HapticEffect' ], 'int' ],
224 SDL_HapticRunEffect => [ [ 'SDL_Haptic', 'int', 'uint32' ], 'int' ],
225 SDL_HapticStopEffect => [ [ 'SDL_Haptic', 'int' ], 'int' ],
226 SDL_HapticDestroyEffect => [ [ 'SDL_Haptic', 'int' ] ],
227 SDL_HapticGetEffectStatus => [ [ 'SDL_Haptic', 'int' ], 'int' ],
228 SDL_HapticSetGain => [ [ 'SDL_Haptic', 'int' ], 'int' ],
229 SDL_HapticSetAutocenter => [ [ 'SDL_Haptic', 'int' ], 'int' ],
230 SDL_HapticPause => [ ['SDL_Haptic'], 'int' ],
231 SDL_HapticUnpause => [ ['SDL_Haptic'], 'int' ],
232 SDL_HapticStopAll => [ ['SDL_Haptic'], 'int' ],
233 SDL_HapticRumbleSupported => [ ['SDL_Haptic'], 'int' ],
234 SDL_HapticRumbleInit => [ ['SDL_Haptic'], 'int' ],
235 SDL_HapticRumblePlay => [ [ 'SDL_Haptic', 'float', 'uint32' ], 'int' ],
236 SDL_HapticRumbleStop => [ ['SDL_Haptic'], 'int' ]
237 };
238  
239 =encoding utf-8
240  
241 =head1 NAME
242  
243 SDL2::haptic - SDL Haptic Subsystem Allowing You to Control Haptic (Force
244 Feedback) Devices
245  
246 =head1 SYNOPSIS
247  
248 use SDL2 qw[:haptic];
249  
250 =head1 DESCRIPTION
251  
252 The SDL haptic subsystem allows you to control haptic (force feedback) devices.
253  
254 The basic usage is as follows:
255  
256 =over
257  
258 =item - Initialize the subsystem (C<SDL_INIT_HAPTIC>).
259  
260 =item - Open a haptic device.
261  
262 =over
263  
264 =item - L<< C<SDL_HapticOpen( ... )>|/C<SDL_HapticOpen( ... )> >> to open from index.
265  
266 =item - L<< C<SDL_HapticOpenFromJoystick( ... )>|/C<SDL_HapticOpenFromJoystick( ... )> >> to open from an existing joystick.
267  
268 =back
269  
270 =item - Create an effect (C<SDL_HapticEffect>).
271  
272 =item - Upload the effect with L<< C<SDL_HapticNewEffect( ... )>|/C<SDL_HapticNewEffect( ... )> >>.
273  
274 =item - Run the effect with L<< C<SDL_HapticRunEffect( ... )>|/C<SDL_HapticRunEffect( ... )> >>.
275  
276 =item - (optional) Free the effect with L<< C<SDL_HapticDestroyEffect( ... )>|/C<SDL_HapticDestroyEffect( ... )> >>.
277  
278 =item - Close the haptic device with L<< C<SDL_HapticClose( ... )>|/C<SDL_HapticClose( ... )> >>.
279  
280 =back
281  
282 Simple rumble example:
283  
284 # Open the device
285 my $haptic = SDL_HapticOpen( 0 );
286 $haptic // return -1;
287  
288 # Initialize simple rumble
289 return -1 if SDL_HapticRumbleInit( $haptic ) != 0;
290  
291 # Play effect at 50% strength for 2 seconds
292 return -1 if SDL_HapticRumblePlay( $haptic, 0.5, 2000 ) != 0;
293 SDL_Delay( 2000 );
294  
295 # Clean up
296 SDL_HapticClose( $haptic );
297  
298 Complete example:
299  
300 sub test_haptic ($joystick) {
301 my $effect_id;
302  
303 # Open the device
304 my $haptic = SDL_HapticOpenFromJoystick($joystick);
305 $haptic // return -1; # Most likely joystick isn't haptic
306  
307 # See if it can do sine waves
308 if ( ( SDL_HapticQuery($haptic) & SDL_HAPTIC_SINE ) == 0 ) {
309 SDL_HapticClose($haptic); # No sine effect
310 return -1;
311 }
312  
313 # Create the effect
314 my $effect = SDL2::HapticEffect->new();
315 $effect->type(SDL_HAPTIC_SINE);
316 $effect->periodic->direction->type(SDL_HAPTIC_POLAR); # Polar coordinates
317 $effect->periodic->direction->dir->[0] = 18000; # Force comes from south
318 $effect->periodic->period(1000); # 1000 ms
319 $effect->periodic->magnitude(20000); # 20000/32767 strength
320 $effect->periodic->length(5000); # 5 seconds long
321 $effect->periodic->attack_length(1000); # Takes 1 second to get max strength
322 $effect->periodic->fade_length(1000); # Takes 1 second to fade away
323  
324 # Upload the effect
325 $effect_id = SDL_HapticNewEffect( $haptic, \$effect );
326  
327 # Test the effect
328 SDL_HapticRunEffect( $haptic, $effect_id, 1 );
329 SDL_Delay(5000); # Wait for the effect to finish
330  
331 # We destroy the effect, although closing the device also does this
332 SDL_HapticDestroyEffect( $haptic, $effect_id );
333  
334 # Close the device
335 SDL_HapticClose($haptic);
336 return 0; # Success
337 }
338  
339 =head1 Functions
340  
341 These may be imported by name or with the C<:haptic> tag.
342  
343 =head2 C<SDL_NumHaptics( ... )>
344  
345 Count the number of haptic devices attached to the system.
346  
347 Returns the number of haptic devices detected on the system or a negative error
348 code on failure; call C<SDL_GetError( )> for more information.
349  
350 =head2 C<SDL_HapticName( ... )>
351  
352 Get the implementation dependent name of a haptic device.
353  
354 This can be called before any joysticks are opened. If no name can be found,
355 this function returns C<undef>.
356  
357 Expected parameters include:
358  
359 =over
360  
361 =item C<device_index> - index of the device to query
362  
363 =back
364  
365 Returns the name of the device or C<undef> on failure; call C<SDL_GetError( )>
366 for more information.
367  
368 =head2 C<SDL_HapticOpen( ... )>
369  
370 Open a haptic device for use.
371  
372 The index passed as an argument refers to the N'th haptic device on this
373 system.
374  
375 When opening a haptic device, its gain will be set to maximum and autocenter
376 will be disabled. To modify these values use L<< C<SDL_HapticSetGain( ...
377 )>|/C<SDL_HapticSetGain( ... )> >> and L<< C<SDL_HapticSetAutocenter( ...
378 )>|/C<SDL_HapticSetAutocenter( ... )> >>.
379  
380 Expected parameters include:
381  
382 =over
383  
384 =item C<device_index> - index of the device to open
385  
386 =back
387  
388 Returns the device identifier or C<undef> on failure; call C<SDL_GetError( )>
389 for more information.
390  
391 =head2 C<SDL_HapticOpened( ... )>
392  
393 Check if the haptic device at the designated index has been opened.
394  
395 Expected parameters include:
396  
397 =over
398  
399 =item C<device_index> - the index of the device to query
400  
401 =back
402  
403 Returns C<1> if it has been opened, C<0> if it hasn't or on failure; call
404 C<SDL_GetError( )> for more information.
405  
406 =head2 C<SDL_HapticIndex( ... )>
407  
408 Get the index of a haptic device.
409  
410 Expected parameters include:
411  
412 =over
413  
414 =item C<haptic> - the L<SDL2::Haptic> device to query
415  
416 =back
417  
418 Returns the index of the specified haptic device or a negative error code on
419 failure; call C<SDL_GetError( )> for more information.
420  
421 =head2 C<SDL_MouseIsHaptic( )>
422  
423 Query whether or not the current mouse has haptic capabilities.
424  
425 Returns C<SDL_TRUE> if the mouse is haptic or C<SDL_FALSE> if it isn't.
426  
427 =head2 C<SDL_HapticOpenFromMouse( )>
428  
429 Try to open a haptic device from the current mouse.
430  
431 Returns the haptic device identifier or C<undef> on failure; call
432 C<SDL_GetError( )> for more information.
433  
434 =head2 C<SDL_JoystickIsHaptic( ... )>
435  
436 Query if a joystick has haptic features.
437  
438 Expected parameters include:
439  
440 =over
441  
442 =item C<joystick> - the L<SDL2::Joystick> to test for haptic capabilities
443  
444 =back
445  
446 Returns C<SDL_TRUE> if the joystick is haptic, C<SDL_FALSE> if it isn't, or a
447 negative error code on failure; call C<SDL_GetError( )> for more information.
448  
449 =head2 C<SDL_HapticOpenFromJoystick( ... )>
450  
451 Open a haptic device for use from a joystick device.
452  
453 You must still close the haptic device separately. It will not be closed with
454 the joystick.
455  
456 When opened from a joystick you should first close the haptic device before
457 closing the joystick device. If not, on some implementations the haptic device
458 will also get unallocated and you'll be unable to use force feedback on that
459 device.
460  
461 Expected parameters include:
462  
463 =over
464  
465 =item C<joystick> - the L<SDL2::Joystick> to create a haptic device from
466  
467 =back
468  
469 Returns a valid haptic device identifier on success or C<undef> on failure;
470 call C<SDL_GetError( )> for more information.
471  
472 =head2 C<SDL_HapticClose( ... )>
473  
474 Close a haptic device previously opened with SDL_HapticOpen().
475  
476 Expected parameters include:
477  
478 =over
479  
480 =item C<haptic> - the L<SDL2::Haptic> device to close
481  
482 =back
483  
484 =head2 C<SDL_HapticNumEffects( ... )>
485  
486 Get the number of effects a haptic device can store.
487  
488 On some platforms this isn't fully supported, and therefore is an
489 approximation. Always check to see if your created effect was actually created
490 and do not rely solely on SDL_HapticNumEffects().
491  
492 Expected parameters include:
493  
494 =over
495  
496 =item C<haptic> - the L<SDL2::Haptic> device to query
497  
498 =back
499  
500 Returns the number of effects the haptic device can store or a negative error
501 code on failure; call C<SDL_GetError( )> for more information.
502  
503 =head2 C<SDL_HapticNumEffectsPlaying( ... )>
504  
505 Get the number of effects a haptic device can play at the same time.
506  
507 This is not supported on all platforms, but will always return a value.
508  
509 Expected parameters include:
510  
511 =over
512  
513 =item C<haptic> - the L<SDL2::Haptic> device to query maximum playing effects
514  
515 =back
516  
517 Returns the number of effects the haptic device can play at the same time or a
518 negative error code on failure; call C<SDL_GetError( )> for more information.
519  
520 =head2 C<SDL_HapticQuery( ... )>
521  
522 Get the haptic device's supported features in bitwise manner.
523  
524 Expected parameters include:
525  
526 =over
527  
528 =item C<haptic> - the L<SDL2::Haptic> device to query
529  
530 =back
531  
532 Returns a list of supported haptic features in bitwise manner (OR'd), or C<0>
533 on failure; call C<SDL_GetError( )> for more information.
534  
535 =head2 C<SDL_HapticNumAxes( ... )>
536  
537 Get the number of haptic axes the device has.
538  
539 The number of haptic axes might be useful if working with the
540 L<SDL2::HapticDirection> effect.
541  
542 Expected parameters include:
543  
544 =over
545  
546 =item C<haptic> - the L<SDL2::Haptic> device to query
547  
548 =back
549  
550 Returns the number of axes on success or a negative error code on failure; call
551 C<SDL_GetError( )> for more information.
552  
553 =head2 C<SDL_HapticEffectSupported( ... )>
554  
555 Check to see if an effect is supported by a haptic device.
556  
557 Expected parameters include:
558  
559 =over
560  
561 =item C<haptic> - the L<SDL2::Haptic> device to query
562  
563 =item C<effect> - the desired effect to query
564  
565 =back
566  
567 Returns C<SDL_TRUE> if effect is supported, C<SDL_FALSE> if it isn't, or a
568 negative error code on failure; call C<SDL_GetError( )> for more information.
569  
570 =head2 C<SDL_HapticNewEffect( ... )>
571  
572 Create a new haptic effect on a specified device.
573  
574 Expected parameters include:
575  
576 =over
577  
578 =item C<haptic> - an L<SDL2::Haptic> device to create the effect on
579  
580 =item C<effect> - an L<SDL2::HapticEffect> structure containing the properties of the effect to create
581  
582 =back
583  
584 Returns the ID of the effect on success or a negative error code on failure;
585 call C<SDL_GetError( )> for more information.
586  
587 =head2 C<SDL_HapticUpdateEffect( ... )>
588  
589 Update the properties of an effect.
590  
591 Can be used dynamically, although behavior when dynamically changing direction
592 may be strange. Specifically the effect may re-upload itself and start playing
593 from the start. You also cannot change the type either when running L<<
594 C<SDL_HapticUpdateEffect( ... )>|/C<SDL_HapticUpdateEffect( ... )> >>.
595  
596 Expected parameters include:
597  
598 =over
599  
600 =item C<haptic> - the L<SDL2::Haptic> device that has the effect
601  
602 =item C<effect> - the identifier of the effect to update
603  
604 =item C<data> - an L<SDL2::HapticEffect> structure containing the new effect properties to use
605  
606 =back
607  
608 Returns C<0> on success or a negative error code on failure; call
609 C<SDL_GetError( )> for more information.
610  
611 =head2 C<SDL_HapticRunEffect( ... )>
612  
613 Run the haptic effect on its associated haptic device.
614  
615 To repeat the effect over and over indefinitely, set C<iterations> to
616 C<SDL_HAPTIC_INFINITY>. (Repeats the envelope - attack and fade.) To make one
617 instance of the effect last indefinitely (so the effect does not fade), set the
618 effect's `length` in its structure/union to C<SDL_HAPTIC_INFINITY> instead.
619  
620 Expected parameters include:
621  
622 =over
623  
624 =item C<haptic> - the L<SDL2::Haptic> device to run the effect on
625  
626 =item C<effect> - the ID of the haptic effect to run
627  
628 =item C<iterations> - the number of iterations to run the effect; use C<SDL_HAPTIC_INFINITY> to repeat forever
629  
630 =back
631  
632 Returns C<0> on success or a negative error code on failure; call
633 C<SDL_GetError( )> for more information.
634  
635 =head2 C<SDL_HapticStopEffect( ... )>
636  
637 Stop the haptic effect on its associated haptic device.
638  
639 Expected parameters include:
640  
641 =over
642  
643 =item C<haptic> - the SDL_Haptic device to stop the effect on
644  
645 =item C<effect> - the ID of the haptic effect to stop
646  
647 =back
648  
649 Returns C<0> on success or a negative error code on failure; call
650 C<SDL_GetError( )> for more information.
651  
652 =head2 C<SDL_HapticDestroyEffect( ... )>
653  
654 Destroy a haptic effect on the device.
655  
656 This will stop the effect if it's running. Effects are automatically destroyed
657 when the device is closed.
658  
659 Expected parameters include:
660  
661 =over
662  
663 =item C<haptic> - the L<SDL2::Haptic> device to destroy the effect on
664  
665 =item C<effect> - the ID of the haptic effect to destroy
666  
667 =back
668  
669 =head2 C<SDL_HapticGetEffectStatus( ... )>
670  
671 Get the status of the current effect on the specified haptic device.
672  
673 Device must support the C<SDL_HAPTIC_STATUS> feature.
674  
675 Expected parameters include:
676  
677 =over
678  
679 =item C<haptic> - the L<SDL2::Haptic> device to query for the effect status on
680  
681 =item C<effect> - the ID of the haptic effect to query its status
682  
683 =back
684  
685 Returns C<0> if it isn't playing, C<1> if it is playing, or a negative error
686 code on failure; call C<SDL_GetError( )> for more information.
687  
688 =head2 C<SDL_HapticSetGain( ... )>
689  
690 Set the global gain of the specified haptic device.
691  
692 Device must support the C<SDL_HAPTIC_GAIN> feature.
693  
694 The user may specify the maximum gain by setting the environment variable
695 C<SDL_HAPTIC_GAIN_MAX> which should be between C<0> and C<100>. All calls to
696 L<< C<SDL_HapticSetGain( ... )>|/C<SDL_HapticSetGain( ... )> >> will scale
697 linearly using C<SDL_HAPTIC_GAIN_MAX> as the maximum.
698  
699 Expected parameters include:
700  
701 =over
702  
703 =item C<haptic> - the L<SDL2::Haptic> device to set the gain on
704  
705 =item C<gain> - value to set the gain to, should be between C<0> and C<100>
706  
707 =back
708  
709 Returns C<0> on success or a negative error code on failure; call
710 C<SDL_GetError( )> for more information.
711  
712 =head2 C<SDL_HapticSetAutocenter( ... )>
713  
714 Set the global autocenter of the device.
715  
716 Autocenter should be between 0 and 100. Setting it to 0 will disable
717 autocentering.
718  
719 Device must support the C<SDL_HAPTIC_AUTOCENTER> feature.
720  
721 Expected parameters include:
722  
723 =over
724  
725 =item C<haptic> - the L<SDL2::Haptic> device to set autocentering on
726  
727 =item C<autocenter> - value to set autocenter to (0-100)
728  
729 =back
730  
731 Returns C<0> on success or a negative error code on failure; call
732 C<SDL_GetError( )> for more information.
733  
734 =head2 C<SDL_HapticPause( ... )>
735  
736 Pause a haptic device.
737  
738 Device must support the C<SDL_HAPTIC_PAUSE> feature. Call L<<
739 C<SDL_HapticUnpause( ... )>|/C<SDL_HapticUnpause( ... )> >> to resume playback.
740  
741 Do not modify the effects nor add new ones while the device is paused. That can
742 cause all sorts of weird errors.
743  
744 Expected parameters include:
745  
746 =over
747  
748 =item C<haptic> - the L<SDL2::Haptic> device to pause
749  
750 =back
751  
752 Returns C<0> on success or a negative error code on failure; call
753 C<SDL_GetError( )> for more information.
754  
755 =head2 C<SDL_HapticUnpause( ... )>
756  
757 Unpause a haptic device.
758  
759 Call to unpause after L<< C<SDL_HapticPause( ... )>|/C<SDL_HapticPause( ... )>
760 >>.
761  
762 Expected parameters include:
763  
764 =over
765  
766 =item C<haptic> - the L<SDL2::Haptic> device to unpause
767  
768 =back
769  
770 Returns C<0> on success or a negative error code on failure; call
771 C<SDL_GetError( )> for more information.
772  
773 =head2 C<SDL_HapticStopAll( ... )>
774  
775 Stop all the currently playing effects on a haptic device.
776  
777 Expected parameters include:
778  
779 =over
780  
781 =item C<haptic> - the L<SDL2::Haptic> device to stop
782  
783 =back
784  
785 Returns C<0> on success or a negative error code on failure; call
786 C<SDL_GetError( )> for more information.
787  
788 =head2 C<SDL_HapticRumbleSupported( ... )>
789  
790 Check whether rumble is supported on a haptic device.
791  
792 Expected parameters include:
793  
794 =over
795  
796 =item C<haptic> - haptic device to check for rumble support
797  
798 =back
799  
800 Returns C<SDL_TRUE> if effect is supported, C<SDL_FALSE> if it isn't, or a
801 negative error code on failure; call C<SDL_GetError( )> for more information.
802  
803 =head2 C<SDL_HapticRumbleInit( ... )>
804  
805 Initialize a haptic device for simple rumble playback.
806  
807 Expected parameters include:
808  
809 =over
810  
811 =item C<haptic> - the haptic device to initialize for simple rumble playback
812  
813 =back
814  
815 Returns C<0> on success or a negative error code on failure; call
816 C<SDL_GetError( )> for more information.
817  
818 =head2 C<SDL_HapticRumblePlay( ... )>
819  
820 Run a simple rumble effect on a haptic device.
821  
822 Expected parameters include:
823  
824 =over
825  
826 =item C<haptic> - the haptic device to play the rumble effect on
827  
828 =item C<strength> - strength of the rumble to play as a 0-1 float value
829  
830 =item C<length> - length of the rumble to play in milliseconds
831  
832 =back
833  
834 Returns C<0> on success or a negative error code on failure; call
835 C<SDL_GetError( )> for more information.
836  
837 =head2 C<SDL_HapticRumbleStop( ... )>
838  
839 Stop the simple rumble on a haptic device.
840  
841 Expected parameters include:
842  
843 =over
844  
845 =item C<haptic> - the haptic device to stop the rumble effect on
846  
847 =back
848  
849 Returns C<0> on success or a negative error code on failure; call
850 C<SDL_GetError( )> for more information.
851  
852 =head1 Defined Values and Enumerations
853  
854 These may be imported by name or with the given tag.
855  
856 =head2 Haptic Features
857  
858 Different haptic features a device can have. These values may all be imported
859 with the C<:haptic> tag.
860  
861 =head3 Haptic effects
862  
863 =over
864  
865 =item C<SDL_HAPTIC_CONSTANT> - Constant haptic effect
866  
867 =item C<SDL_HAPTIC_SINE> - Periodic haptic effect that simulates sine waves
868  
869 =item C<SDL_HAPTIC_LEFTRIGHT> - Haptic effect for direct control over high/low frequency motors
870  
871 =item C<SDL_HAPTIC_TRIANGLE> - Periodic haptic effect that simulates triangular waves
872  
873 =item C<SDL_HAPTIC_SAWTOOTHUP> - Periodic haptic effect that simulates saw tooth up waves
874  
875 =item C<SDL_HAPTIC_SAWTOOTHDOWN> - Periodic haptic effect that simulates saw tooth down waves
876  
877 =item C<SDL_HAPTIC_RAMP> - Ramp haptic effect
878  
879 =item C<SDL_HAPTIC_SPRING> - Condition haptic effect that simulates a spring. Effect is based on the axes position
880  
881 =item C<SDL_HAPTIC_DAMPER> - Condition haptic effect that simulates dampening. Effect is based on the axes velocity
882  
883 =item C<SDL_HAPTIC_INERTIA> - Condition haptic effect that simulates inertia. Effect is based on the axes acceleration
884  
885 =item C<SDL_HAPTIC_FRICTION> - Condition haptic effect that simulates friction. Effect is based on the axes movement
886  
887 =item C<SDL_HAPTIC_CUSTOM> - User defined custom haptic effect
888  
889 =back
890  
891 These last few are features the device has, not effects:
892  
893 =over
894  
895 =item C<SDL_HAPTIC_GAIN> - Device supports setting the global gain
896  
897 =item C<SDL_HAPTIC_AUTOCENTER> - Device supports setting autocenter
898  
899 =item C<SDL_HAPTIC_STATUS> - Device supports querying effect status
900  
901 =item C<SDL_HAPTIC_PAUSE> - Devices supports being paused
902  
903 =back
904  
905 =head3 Direction encodings
906  
907 =over
908  
909 =item C<SDL_HAPTIC_POLAR> - Uses polar coordinates for the direction
910  
911 =item C<SDL_HAPTIC_CARTESIAN> - Uses cartesian coordinates for the direction
912  
913 =item C<SDL_HAPTIC_SPHERICAL> - Uses spherical coordinates for the direction
914  
915 =item C<SDL_HAPTIC_STEERING_AXIS> - Use this value to play an effect on the steering wheel axis. This provides better compatibility across platforms and devices as SDL will guess the correct axis
916  
917 =back
918  
919 =head3 Misc defines
920  
921 =over
922  
923 =item C<SDL_HAPTIC_INFINITY> - Used to play a device an infinite number of times
924  
925 =back
926  
927 =head1 LICENSE
928  
929 Copyright (C) Sanko Robinson.
930  
931 This library is free software; you can redistribute it and/or modify it under
932 the terms found in the Artistic License 2. Other copyrights, terms, and
933 conditions may apply to data transmitted through this module.
934  
935 =head1 AUTHOR
936  
937 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
938  
939 =begin stopwords
940  
941 N'th autocentering unpause autocenter
942  
943 =end stopwords
944  
945 =cut
946  
947 };
948 1;