Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
688 lines (564 loc) · 13.6 KB

SDL_haptic.c

File metadata and controls

688 lines (564 loc) · 13.6 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
SDL - Simple DirectMedia Layer
Copyright (C) 2008 Edgar Simo
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_syshaptic.h"
Jul 2, 2008
Jul 2, 2008
25
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
Jul 10, 2008
Jul 10, 2008
28
Uint8 SDL_numhaptics = 0;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
SDL_Haptic **SDL_haptics = NULL;
/*
* Initializes the Haptic devices.
*/
int
SDL_HapticInit(void)
{
int arraylen;
int status;
SDL_numhaptics = 0;
status = SDL_SYS_HapticInit();
if (status >= 0) {
arraylen = (status + 1) * sizeof(*SDL_haptics);
SDL_haptics = (SDL_Haptic **) SDL_malloc(arraylen);
Jul 10, 2008
Jul 10, 2008
46
if (SDL_haptics == NULL) { /* Out of memory. */
47
SDL_numhaptics = 0;
Jul 10, 2008
Jul 10, 2008
48
49
}
else {
50
51
52
53
54
55
56
57
58
59
SDL_memset(SDL_haptics, 0, arraylen);
SDL_numhaptics = status;
}
status = 0;
}
return status;
}
Jul 8, 2008
Jul 8, 2008
60
61
62
63
/*
* Checks to see if the haptic device is valid
*/
static int
Jul 31, 2008
Jul 31, 2008
64
ValidHaptic(SDL_Haptic * haptic)
Jul 8, 2008
Jul 8, 2008
65
{
Jul 31, 2008
Jul 31, 2008
66
int i;
Jul 8, 2008
Jul 8, 2008
67
int valid;
Jul 31, 2008
Jul 31, 2008
68
69
70
71
72
73
74
valid = 0;
for (i=0; i<SDL_numhaptics; i++) {
if (SDL_haptics[i] == haptic) {
valid = 1;
break;
}
Jul 8, 2008
Jul 8, 2008
75
}
Jul 31, 2008
Jul 31, 2008
76
Jul 8, 2008
Jul 8, 2008
77
78
79
80
return valid;
}
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Returns the number of available devices.
*/
int
SDL_NumHaptics(void)
{
return SDL_numhaptics;
}
/*
* Gets the name of a Haptic device by index.
*/
const char *
SDL_HapticName(int device_index)
{
if ((device_index < 0) || (device_index >= SDL_numhaptics)) {
Jul 10, 2008
Jul 10, 2008
98
SDL_SetError("Haptic: There are %d haptic devices available", SDL_numhaptics);
99
100
101
102
103
104
105
return NULL;
}
return SDL_SYS_HapticName(device_index);
}
/*
Jun 1, 2008
Jun 1, 2008
106
* Opens a Haptic device.
107
108
109
110
111
112
113
114
*/
SDL_Haptic *
SDL_HapticOpen(int device_index)
{
int i;
SDL_Haptic *haptic;
if ((device_index < 0) || (device_index >= SDL_numhaptics)) {
Jul 10, 2008
Jul 10, 2008
115
SDL_SetError("Haptic: There are %d haptic devices available", SDL_numhaptics);
116
117
118
119
return NULL;
}
/* If the haptic is already open, return it */
Jun 30, 2008
Jun 30, 2008
120
for (i=0; SDL_haptics[i]; i++) {
121
122
123
124
125
126
127
if (device_index == SDL_haptics[i]->index) {
haptic = SDL_haptics[i];
++haptic->ref_count;
return haptic;
}
}
Jun 30, 2008
Jun 30, 2008
128
/* Create the haptic device */
129
haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
Jun 30, 2008
Jun 30, 2008
130
131
132
if (haptic == NULL) {
SDL_OutOfMemory();
return NULL;
Jun 30, 2008
Jun 30, 2008
134
135
136
137
138
139
140
/* Initialize the haptic device */
SDL_memset(haptic, 0, (sizeof *haptic));
haptic->index = device_index;
if (SDL_SYS_HapticOpen(haptic) < 0) {
SDL_free(haptic);
return NULL;
Jun 30, 2008
Jun 30, 2008
142
Jul 8, 2008
Jul 8, 2008
143
144
145
146
147
148
/* Disable autocenter and set gain to max. */
if (haptic->supported & SDL_HAPTIC_GAIN)
SDL_HapticSetGain(haptic,100);
if (haptic->supported & SDL_HAPTIC_AUTOCENTER)
SDL_HapticSetAutocenter(haptic,0);
Jun 30, 2008
Jun 30, 2008
149
150
/* Add haptic to list */
++haptic->ref_count;
Jul 2, 2008
Jul 2, 2008
151
for (i=0; SDL_haptics[i]; i++)
Jun 30, 2008
Jun 30, 2008
152
153
154
/* Skip to next haptic */ ;
SDL_haptics[i] = haptic;
155
156
return haptic;
}
Jun 1, 2008
Jun 1, 2008
157
158
Jul 8, 2008
Jul 8, 2008
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* Returns 1 if the device has been opened.
*/
int
SDL_HapticOpened(int device_index)
{
int i, opened;
opened = 0;
for (i=0; SDL_haptics[i]; i++) {
if (SDL_haptics[i]->index == (Uint8) device_index) {
opened = 1;
break;
}
}
return opened;
}
Jul 8, 2008
Jul 8, 2008
178
179
180
181
182
183
/*
* Returns the index to a haptic device.
*/
int
SDL_HapticIndex(SDL_Haptic * haptic)
{
Jul 31, 2008
Jul 31, 2008
184
if (!ValidHaptic(haptic)) {
Jul 8, 2008
Jul 8, 2008
185
186
187
188
189
190
191
return -1;
}
return haptic->index;
}
Jul 10, 2008
Jul 10, 2008
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
* Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't.
*/
int
SDL_MouseIsHaptic(void)
{
if (SDL_SYS_HapticMouse() < 0)
return SDL_FALSE;
return SDL_TRUE;
}
/*
* Returns the haptic device if mouse is haptic or NULL elsewise.
*/
SDL_Haptic *
SDL_HapticOpenFromMouse(void)
{
int device_index;
device_index = SDL_SYS_HapticMouse();
if (device_index < 0) {
Jul 10, 2008
Jul 10, 2008
215
SDL_SetError("Haptic: Mouse isn't a haptic device.");
Jul 10, 2008
Jul 10, 2008
216
217
218
219
220
221
222
return NULL;
}
return SDL_HapticOpen(device_index);
}
Jul 2, 2008
Jul 2, 2008
223
224
225
226
227
228
229
230
/*
* Returns SDL_TRUE if joystick has haptic features.
*/
int
SDL_JoystickIsHaptic(SDL_Joystick * joystick)
{
int ret;
Jul 2, 2008
Jul 2, 2008
231
/* Must be a valid joystick */
Jul 2, 2008
Jul 2, 2008
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
if (!SDL_PrivateJoystickValid(&joystick)) {
return -1;
}
ret = SDL_SYS_JoystickIsHaptic(joystick);
if (ret > 0) return SDL_TRUE;
else if (ret == 0) return SDL_FALSE;
else return -1;
}
/*
* Opens a haptic device from a joystick.
*/
SDL_Haptic *
SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
{
Jul 2, 2008
Jul 2, 2008
250
251
252
253
int i;
SDL_Haptic *haptic;
/* Must be a valid joystick */
Jul 2, 2008
Jul 2, 2008
254
if (!SDL_PrivateJoystickValid(&joystick)) {
Jul 2, 2008
Jul 2, 2008
255
256
257
258
259
260
261
262
263
264
return NULL;
}
/* Joystick must be haptic */
if (SDL_SYS_JoystickIsHaptic(joystick) <= 0) {
return NULL;
}
/* Check to see if joystick's haptic is already open */
for (i=0; SDL_haptics[i]; i++) {
Jul 2, 2008
Jul 2, 2008
265
if (SDL_SYS_JoystickSameHaptic(SDL_haptics[i],joystick)) {
Jul 2, 2008
Jul 2, 2008
266
267
268
269
270
271
272
273
274
275
276
haptic = SDL_haptics[i];
++haptic->ref_count;
return haptic;
}
}
/* Create the haptic device */
haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
if (haptic == NULL) {
SDL_OutOfMemory();
return NULL;
Jul 2, 2008
Jul 2, 2008
277
}
Jul 2, 2008
Jul 2, 2008
278
279
/* Initialize the haptic device */
Jul 17, 2008
Jul 17, 2008
280
SDL_memset(haptic, 0, sizeof(SDL_Haptic));
Jul 2, 2008
Jul 2, 2008
281
282
283
284
285
286
287
288
289
290
291
292
if (SDL_SYS_HapticOpenFromJoystick(haptic,joystick) < 0) {
SDL_free(haptic);
return NULL;
}
/* Add haptic to list */
++haptic->ref_count;
for (i=0; SDL_haptics[i]; i++)
/* Skip to next haptic */ ;
SDL_haptics[i] = haptic;
return haptic;
Jul 2, 2008
Jul 2, 2008
293
294
295
}
Jun 1, 2008
Jun 1, 2008
296
297
298
299
300
301
/*
* Closes a SDL_Haptic device.
*/
void
SDL_HapticClose(SDL_Haptic * haptic)
{
Jun 23, 2008
Jun 23, 2008
302
303
304
int i;
/* Must be valid */
Jul 31, 2008
Jul 31, 2008
305
if (!ValidHaptic(haptic)) {
Jun 23, 2008
Jun 23, 2008
306
307
308
309
310
311
312
313
return;
}
/* Check if it's still in use */
if (--haptic->ref_count < 0) {
return;
}
Jul 1, 2008
Jul 1, 2008
314
315
316
317
318
319
/* Close it, properly removing effects if needed */
for (i=0; i<haptic->neffects; i++) {
if (haptic->effects[i].hweffect != NULL) {
SDL_HapticDestroyEffect(haptic,i);
}
}
Jun 23, 2008
Jun 23, 2008
320
321
322
323
324
SDL_SYS_HapticClose(haptic);
/* Remove from the list */
for (i = 0; SDL_haptics[i]; ++i) {
if (haptic == SDL_haptics[i]) {
Jul 31, 2008
Jul 31, 2008
325
SDL_haptics[i] = NULL;
Jun 23, 2008
Jun 23, 2008
326
327
328
329
330
331
332
333
SDL_memcpy(&SDL_haptics[i], &SDL_haptics[i + 1],
(SDL_numhaptics - i) * sizeof(haptic));
break;
}
}
/* Free */
SDL_free(haptic);
Jun 1, 2008
Jun 1, 2008
334
335
336
337
338
}
/*
* Cleans up after the subsystem.
*/
Jun 1, 2008
Jun 1, 2008
339
340
341
342
343
344
345
346
void
SDL_HapticQuit(void)
{
SDL_SYS_HapticQuit();
if (SDL_haptics != NULL) {
SDL_free(SDL_haptics);
SDL_haptics = NULL;
}
Jul 10, 2008
Jul 10, 2008
347
SDL_numhaptics = 0;
Jun 1, 2008
Jun 1, 2008
348
}
Jun 30, 2008
Jun 30, 2008
349
Jun 30, 2008
Jun 30, 2008
350
351
352
353
354
355
/*
* Returns the number of effects a haptic device has.
*/
int
SDL_HapticNumEffects(SDL_Haptic * haptic)
{
Jul 31, 2008
Jul 31, 2008
356
if (!ValidHaptic(haptic)) {
Jun 30, 2008
Jun 30, 2008
357
358
359
360
361
362
return -1;
}
return haptic->neffects;
}
Jul 10, 2008
Jul 10, 2008
363
364
365
366
367
368
369
/*
* Returns the number of effects a haptic device can play.
*/
int
SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
{
Jul 31, 2008
Jul 31, 2008
370
if (!ValidHaptic(haptic)) {
Jul 10, 2008
Jul 10, 2008
371
372
373
374
375
376
377
return -1;
}
return haptic->nplaying;
}
Jun 30, 2008
Jun 30, 2008
378
379
380
381
/*
* Returns supported effects by the device.
*/
unsigned int
Jul 6, 2008
Jul 6, 2008
382
SDL_HapticQuery(SDL_Haptic * haptic)
Jun 30, 2008
Jun 30, 2008
383
{
Jul 31, 2008
Jul 31, 2008
384
if (!ValidHaptic(haptic)) {
Jun 30, 2008
Jun 30, 2008
385
386
387
388
389
390
return -1;
}
return haptic->supported;
}
Jul 17, 2008
Jul 17, 2008
391
392
393
394
395
396
397
/*
* Returns the number of axis on the device.
*/
int
SDL_HapticNumAxes(SDL_Haptic * haptic)
{
Jul 31, 2008
Jul 31, 2008
398
if (!ValidHaptic(haptic)) {
Jul 17, 2008
Jul 17, 2008
399
400
401
402
403
404
return -1;
}
return haptic->naxes;
}
Jul 1, 2008
Jul 1, 2008
405
406
407
/*
* Checks to see if the device can support the effect.
*/
Jun 30, 2008
Jun 30, 2008
408
409
410
int
SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
{
Jul 31, 2008
Jul 31, 2008
411
if (!ValidHaptic(haptic)) {
Jun 30, 2008
Jun 30, 2008
412
413
414
415
416
417
418
return -1;
}
if ((haptic->supported & effect->type) != 0)
return SDL_TRUE;
return SDL_FALSE;
}
Jun 30, 2008
Jun 30, 2008
419
420
421
422
423
424
425
426
427
428
/*
* Creates a new haptic effect.
*/
int
SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
{
int i;
/* Check for device validity. */
Jul 31, 2008
Jul 31, 2008
429
if (!ValidHaptic(haptic)) {
Jun 30, 2008
Jun 30, 2008
430
431
432
return -1;
}
Jul 1, 2008
Jul 1, 2008
433
434
/* Check to see if effect is supported */
if (SDL_HapticEffectSupported(haptic,effect)==SDL_FALSE) {
Jul 10, 2008
Jul 10, 2008
435
SDL_SetError("Haptic: Effect not supported by haptic device.");
Jul 1, 2008
Jul 1, 2008
436
437
438
return -1;
}
Jun 30, 2008
Jun 30, 2008
439
440
441
442
443
/* See if there's a free slot */
for (i=0; i<haptic->neffects; i++) {
if (haptic->effects[i].hweffect == NULL) {
/* Now let the backend create the real effect */
Jul 1, 2008
Jul 1, 2008
444
if (SDL_SYS_HapticNewEffect(haptic,&haptic->effects[i],effect) != 0) {
Jun 30, 2008
Jun 30, 2008
445
446
return -1; /* Backend failed to create effect */
}
Jul 18, 2008
Jul 18, 2008
447
448
SDL_memcpy(&haptic->effects[i].effect, effect, sizeof(SDL_HapticEffect));
Jun 30, 2008
Jun 30, 2008
449
450
451
452
return i;
}
}
Jul 10, 2008
Jul 10, 2008
453
SDL_SetError("Haptic: Device has no free space left.");
Jun 30, 2008
Jun 30, 2008
454
455
456
return -1;
}
Jul 1, 2008
Jul 1, 2008
457
458
459
460
461
462
463
/*
* Checks to see if an effect is valid.
*/
static int
ValidEffect(SDL_Haptic * haptic, int effect)
{
if ((effect < 0) || (effect >= haptic->neffects)) {
Jul 10, 2008
Jul 10, 2008
464
SDL_SetError("Haptic: Invalid effect identifier.");
Jul 1, 2008
Jul 1, 2008
465
466
467
468
469
return 0;
}
return 1;
}
Jul 1, 2008
Jul 1, 2008
470
471
472
473
474
475
/*
* Updates an effect.
*/
int
SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data)
{
Jul 31, 2008
Jul 31, 2008
476
if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
Jul 1, 2008
Jul 1, 2008
477
478
479
return -1;
}
Jul 18, 2008
Jul 18, 2008
480
481
482
483
484
485
/* Can't change type dynamically. */
if (data->type != haptic->effects[effect].effect.type) {
SDL_SetError("Haptic: Updating effect type is illegal.");
return -1;
}
Jul 1, 2008
Jul 1, 2008
486
487
488
489
490
/* Updates the effect */
if (SDL_SYS_HapticUpdateEffect(haptic,&haptic->effects[effect],data) < 0) {
return -1;
}
Jul 18, 2008
Jul 18, 2008
491
SDL_memcpy(&haptic->effects[effect].effect, data, sizeof(SDL_HapticEffect));
Jul 1, 2008
Jul 1, 2008
492
493
494
495
return 0;
}
Jun 30, 2008
Jun 30, 2008
496
497
498
499
/*
* Runs the haptic effect on the device.
*/
int
Jul 15, 2008
Jul 15, 2008
500
SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations)
Jun 30, 2008
Jun 30, 2008
501
{
Jul 31, 2008
Jul 31, 2008
502
if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
Jun 30, 2008
Jun 30, 2008
503
504
return -1;
}
Jun 30, 2008
Jun 30, 2008
505
506
/* Run the effect */
Jul 10, 2008
Jul 10, 2008
507
if (SDL_SYS_HapticRunEffect(haptic,&haptic->effects[effect], iterations) < 0) {
Jun 30, 2008
Jun 30, 2008
508
509
510
511
return -1;
}
return 0;
Jun 30, 2008
Jun 30, 2008
512
513
}
Jul 1, 2008
Jul 1, 2008
514
515
516
517
518
519
/*
* Stops the haptic effect on the device.
*/
int
SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
{
Jul 31, 2008
Jul 31, 2008
520
if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
Jul 1, 2008
Jul 1, 2008
521
522
523
524
525
526
527
528
529
530
531
return -1;
}
/* Stop the effect */
if (SDL_SYS_HapticStopEffect(haptic,&haptic->effects[effect]) < 0) {
return -1;
}
return 0;
}
Jun 30, 2008
Jun 30, 2008
532
533
534
535
536
537
/*
* Gets rid of a haptic effect.
*/
void
SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
{
Jul 31, 2008
Jul 31, 2008
538
if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
Jun 30, 2008
Jun 30, 2008
539
540
return;
}
Jun 30, 2008
Jun 30, 2008
541
542
543
544
545
546
547
/* Not allocated */
if (haptic->effects[effect].hweffect == NULL) {
return;
}
SDL_SYS_HapticDestroyEffect(haptic, &haptic->effects[effect]);
Jun 30, 2008
Jun 30, 2008
548
549
}
Jul 3, 2008
Jul 3, 2008
550
551
552
553
554
555
/*
* Gets the status of a haptic effect.
*/
int
SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
{
Jul 31, 2008
Jul 31, 2008
556
if (!ValidHaptic(haptic) || !ValidEffect(haptic,effect)) {
Jul 3, 2008
Jul 3, 2008
557
558
559
560
return -1;
}
if ((haptic->supported & SDL_HAPTIC_STATUS) == 0) {
Jul 10, 2008
Jul 10, 2008
561
SDL_SetError("Haptic: Device does not support status queries.");
Jul 3, 2008
Jul 3, 2008
562
563
564
565
566
567
return -1;
}
return SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]);
}
Jul 1, 2008
Jul 1, 2008
568
569
570
571
572
573
/*
* Sets the global gain of the device.
*/
int
SDL_HapticSetGain(SDL_Haptic * haptic, int gain )
{
Jul 8, 2008
Jul 8, 2008
574
575
576
const char *env;
int real_gain, max_gain;
Jul 31, 2008
Jul 31, 2008
577
if (!ValidHaptic(haptic)) {
Jul 1, 2008
Jul 1, 2008
578
579
580
return -1;
}
Jul 1, 2008
Jul 1, 2008
581
if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) {
Jul 10, 2008
Jul 10, 2008
582
SDL_SetError("Haptic: Device does not support setting gain.");
Jul 1, 2008
Jul 1, 2008
583
584
585
return -1;
}
Jul 1, 2008
Jul 1, 2008
586
if ((gain < 0) || (gain > 100)) {
Jul 10, 2008
Jul 10, 2008
587
SDL_SetError("Haptic: Gain must be between 0 and 100.");
Jul 1, 2008
Jul 1, 2008
588
589
590
return -1;
}
Jul 8, 2008
Jul 8, 2008
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
/* We use the envvar to get the maximum gain. */
env = SDL_getenv("SDL_HAPTIC_GAIN_MAX");
if (env != NULL) {
max_gain = SDL_atoi(env);
/* Check for sanity. */
if (max_gain < 0) max_gain = 0;
else if (max_gain > 100) max_gain = 100;
/* We'll scale it linearly with SDL_HAPTIC_GAIN_MAX */
real_gain = (gain * max_gain) / 100;
}
else {
real_gain = gain;
}
if (SDL_SYS_HapticSetGain(haptic,real_gain) < 0) {
Jul 1, 2008
Jul 1, 2008
608
609
610
611
612
613
return -1;
}
return 0;
}
Jul 1, 2008
Jul 1, 2008
614
615
616
617
618
619
/*
* Makes the device autocenter, 0 disables.
*/
int
SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter )
{
Jul 31, 2008
Jul 31, 2008
620
if (!ValidHaptic(haptic)) {
Jul 1, 2008
Jul 1, 2008
621
622
623
624
return -1;
}
if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) {
Jul 10, 2008
Jul 10, 2008
625
SDL_SetError("Haptic: Device does not support setting autocenter.");
Jul 1, 2008
Jul 1, 2008
626
627
628
629
return -1;
}
if ((autocenter < 0) || (autocenter > 100)) {
Jul 10, 2008
Jul 10, 2008
630
SDL_SetError("Haptic: Autocenter must be between 0 and 100.");
Jul 1, 2008
Jul 1, 2008
631
632
633
634
635
636
637
638
639
640
return -1;
}
if (SDL_SYS_HapticSetAutocenter(haptic,autocenter) < 0) {
return -1;
}
return 0;
}
Aug 24, 2008
Aug 24, 2008
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
/*
* Pauses the haptic device.
*/
int
SDL_HapticPause(SDL_Haptic * haptic)
{
if (!ValidHaptic(haptic)) {
return -1;
}
if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
SDL_SetError("Haptic: Device does not support setting pausing.");
return -1;
}
return SDL_SYS_HapticPause(haptic);
}
/*
* Unpauses the haptic device.
*/
int
SDL_HapticUnpause(SDL_Haptic * haptic)
{
if (!ValidHaptic(haptic)) {
return -1;
}
if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
return 0; /* Not going to be paused, so we pretend it's unpaused. */
}
return SDL_SYS_HapticUnpause(haptic);
}
Jun 30, 2008
Jun 30, 2008
675
Aug 24, 2008
Aug 24, 2008
676
677
678
679
680
681
682
683
684
685
686
687
/*
* Stops all the currently playing effects.
*/
int
SDL_HapticStopAll(SDL_Haptic * haptic)
{
if (!ValidHaptic(haptic)) {
return -1;
}
return SDL_SYS_HapticStopAll(haptic);
}