This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
forked from meleu/jstest-sdl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjstest-sdl.c
638 lines (536 loc) · 22.6 KB
/
jstest-sdl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/* jstest-sdl.c
***************
* This is a fork of the Ingo Ruhnke sdl2-jstest.
* I renamed it to jstest-sdl.
*
* TODO: - implement the --single-event option.
* - clean the code
*
* Changelog:
************
* 2016-07-18: Added the --listsimple option.
*
* 2016-07-16: Just adapting the original code to my coding style. There is
* no new feature implemented.
*
*
* github repository: https://github.com/meleu/jstest-sdl
* original repository: https://github.com/Grumbel/sdl-jstest
*/
// ORIGINAL DISCLAIMER
///////////////////////////////////////////////////////////////////////////////
// sdl-jstest - Joystick Test Program for SDL
// Copyright (C) 2014 Ingo Ruhnke <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
#include <SDL.h>
#include <assert.h>
#include <curses.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
/* constants *****************************************************************/
#define VERSION "0.2.1-meleu"
#define HELP_MESSAGE "\
List available joysticks or test a joystick.\n\
This programm uses SDL2 for doing its test instead of using the raw\n\
/dev/input/jsX interface\n\
\n\
Options:\n\
-h, --help Print this help\n\
--version Print version number and exit\n\
-l, --list Search for available joysticks and list\n\
their properties\n\
-ls, --listsimple Search for available joysticks and list\n\
their index and name\n\
-t, --test JOYNUM Display a graphical representation of\n\
the current joystick state\n\
-g, --gamecontroller IDX Test GameController\n\
-e, --event JOYNUM Display the events that are recieved from\n\
the joystick\n\
-r, --rumble JOYNUM Test rumble effects on gamepad JOYNUM\n\n"
/* functions *****************************************************************/
void simple_list_joysticks() {
int num_joysticks = SDL_NumJoysticks();
if (num_joysticks < 0)
printf("No joysticks were found\n");
else
for(int i = 0; i < num_joysticks; i++)
printf("%d:%s\n", i, SDL_JoystickNameForIndex(i));
}
void print_bar(int pos, int len) {
addch('[');
for(int i = 0; i < len; ++i) {
if (i == pos)
addch('#');
else
addch(' ');
}
addch(']');
}
int str2int(const char* str, int* val) {
char* endptr;
errno = 0; /* To distinguish success/failure after call */
*val = strtol(str, &endptr, 10);
/* Check for various possible errors */
if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
|| (errno != 0 && *val == 0)) {
return 0;
}
if (endptr == str) {
return 0;
}
return 1;
}
void print_joystick_info(int joy_idx, SDL_Joystick* joy, SDL_GameController* gamepad) {
SDL_JoystickGUID guid = SDL_JoystickGetGUID(joy);
char guid_str[1024];
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
printf("Joystick Name: '%s'\n", SDL_JoystickName(joy));
printf("Joystick GUID: %s\n", guid_str);
printf("Joystick Number: %2d\n", joy_idx);
printf("Number of Axes: %2d\n", SDL_JoystickNumAxes(joy));
printf("Number of Buttons: %2d\n", SDL_JoystickNumButtons(joy));
printf("Number of Hats: %2d\n", SDL_JoystickNumHats(joy));
printf("Number of Balls: %2d\n", SDL_JoystickNumBalls(joy));
printf("GameController:\n");
if (!gamepad) {
printf(" not a gamepad\n");
} else {
printf(" Name: '%s'\n", SDL_GameControllerName(gamepad));
printf(" Mapping: '%s'\n", SDL_GameControllerMappingForGUID(guid));
}
printf("\n");
}
void print_help(const char* prg) {
printf("Usage: %s [OPTION]\n", prg);
printf(HELP_MESSAGE);
printf("Examples:\n");
printf(" %s --list\n", prg);
printf(" %s --test 1\n", prg);
}
void list_joysticks() {
int num_joysticks = SDL_NumJoysticks();
if (num_joysticks == 0) {
printf("No joysticks were found\n");
} else {
printf("Found %d joystick(s)\n\n", num_joysticks);
for(int joy_idx = 0; joy_idx < num_joysticks; ++joy_idx) {
SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
if (!joy) {
fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
} else {
SDL_GameController* gamepad = SDL_GameControllerOpen(joy_idx);
print_joystick_info(joy_idx, joy, gamepad);
if (gamepad) {
SDL_GameControllerClose(gamepad);
}
SDL_JoystickClose(joy);
}
}
}
}
void test_joystick(int joy_idx) {
SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
if (!joy) {
fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
} else {
initscr();
//cbreak();
//noecho();
//nonl();
curs_set(0);
int num_axes = SDL_JoystickNumAxes(joy);
int num_buttons = SDL_JoystickNumButtons(joy);
int num_hats = SDL_JoystickNumHats(joy);
int num_balls = SDL_JoystickNumBalls(joy);
Sint16* axes = calloc(num_axes, sizeof(Sint16));
Uint8* buttons = calloc(num_buttons, sizeof(Uint8));
Uint8* hats = calloc(num_hats, sizeof(Uint8));
Uint8* balls = calloc(num_balls, 2*sizeof(Sint16));
int quit = 0;
SDL_Event event;
while(!quit) {
SDL_Delay(10);
bool something_new = false;
while (SDL_PollEvent(&event)) {
something_new = true;
switch(event.type) {
case SDL_JOYAXISMOTION:
assert(event.jaxis.axis < num_axes);
axes[event.jaxis.axis] = event.jaxis.value;
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
assert(event.jbutton.button < num_buttons);
buttons[event.jbutton.button] = event.jbutton.state;
break;
case SDL_JOYHATMOTION:
assert(event.jhat.hat < num_hats);
hats[event.jhat.hat] = event.jhat.value;
break;
case SDL_JOYBALLMOTION:
assert(event.jball.ball < num_balls);
balls[2*event.jball.ball + 0] = event.jball.xrel;
balls[2*event.jball.ball + 1] = event.jball.yrel;
break;
case SDL_QUIT:
quit = 1;
printf("Recieved interrupt, exiting\n");
break;
default:
fprintf(stderr, "Error: Unhandled event type: %d\n", event.type);
}
}
if (something_new) {
//clear();
move(0,0);
printw("Joystick Name: '%s'\n", SDL_JoystickName(joy));
printw("Joystick Number: %d\n", joy_idx);
printw("\n");
printw("Axes %2d:\n", num_axes);
for(int i = 0; i < num_axes; ++i) {
int len = COLS - 20;
printw(" %2d: %6d ", i, axes[i]);
print_bar((axes[i] + 32767) * (len-1) / 65534, len);
addch('\n');
}
printw("\n");
if (num_buttons == 193) { // workaround for OpenSimHardware OSH PB Controller
printw("Buttons %2d:\n", 12);
for(int i = 0; i < 12; ++i) {
printw(" %2d: %d %s\n", i, buttons[i], buttons[i] ? "[#]":"[ ]");
}
}
else {
printw("Buttons %2d:\n", num_buttons);
for(int i = 0; i < num_buttons; ++i) {
printw(" %2d: %d %s\n", i, buttons[i], buttons[i] ? "[#]":"[ ]");
}
}
printw("\n");
printw("Hats %2d:\n", num_hats);
for(int i = 0; i < num_hats; ++i) {
printw(" %2d: value: %d\n", i, hats[i]);
printw(" +-----+ up: %c\n"
" |%c %c %c| down: %c\n"
" |%c %c %c| left: %c\n"
" |%c %c %c| right: %c\n"
" +-----+\n",
(hats[i] & SDL_HAT_UP)?'1':'0',
((hats[i] & SDL_HAT_UP) && (hats[i] & SDL_HAT_LEFT)) ? 'O' : ' ',
((hats[i] & SDL_HAT_UP) && !(hats[i] & (SDL_HAT_LEFT | SDL_HAT_RIGHT))) ? 'O' : ' ',
((hats[i] & SDL_HAT_UP) && (hats[i] & SDL_HAT_RIGHT)) ? 'O' : ' ',
(hats[i] & SDL_HAT_DOWN)?'1':'0',
(!(hats[i] & (SDL_HAT_UP | SDL_HAT_DOWN)) && (hats[i] & SDL_HAT_LEFT)) ? 'O' : ' ',
(!(hats[i] & (SDL_HAT_UP | SDL_HAT_DOWN)) && !(hats[i] & (SDL_HAT_LEFT | SDL_HAT_RIGHT))) ? 'O' : ' ',
(!(hats[i] & (SDL_HAT_UP | SDL_HAT_DOWN)) && (hats[i] & SDL_HAT_RIGHT)) ? 'O' : ' ',
(hats[i] & SDL_HAT_LEFT)?'1':'0',
((hats[i] & SDL_HAT_DOWN) && (hats[i] & SDL_HAT_LEFT)) ? 'O' : ' ',
((hats[i] & SDL_HAT_DOWN) && !(hats[i] & (SDL_HAT_LEFT | SDL_HAT_RIGHT))) ? 'O' : ' ',
((hats[i] & SDL_HAT_DOWN) && (hats[i] & SDL_HAT_RIGHT)) ? 'O' : ' ',
(hats[i] & SDL_HAT_RIGHT)?'1':'0');
}
printw("\n");
printw("Balls %2d: ", num_balls);
for(int i = 0; i < num_balls; ++i) {
printw(" %2d: %6d %6d\n", i, balls[2*i+0], balls[2*i+1]);
}
printw("\n");
printw("\n");
printw("Press Ctrl-c to exit\n");
refresh();
}
} // while
free(balls);
free(hats);
free(buttons);
free(axes);
endwin();
}
}
void test_gamecontroller_events(SDL_GameController* gamepad) {
assert(gamepad);
printf("Entering gamecontroller test loop, press Ctrl-c to exit\n");
int quit = 0;
SDL_Event event;
while(!quit && SDL_WaitEvent(&event)) {
switch(event.type) {
case SDL_JOYAXISMOTION:
//printf("SDL_JOYAXISMOTION: joystick: %d axis: %d value: %d\n",
// event.jaxis.which, event.jaxis.axis, event.jaxis.value);
break;
case SDL_JOYBUTTONDOWN:
//printf("SDL_JOYBUTTONDOWN: joystick: %d button: %d state: %d\n",
// event.jbutton.which, event.jbutton.button, event.jbutton.state);
break;
case SDL_JOYBUTTONUP:
//printf("SDL_JOYBUTTONUP: joystick: %d button: %d state: %d\n",
// event.jbutton.which, event.jbutton.button, event.jbutton.state);
break;
case SDL_JOYHATMOTION:
//printf("SDL_JOYHATMOTION: joystick: %d hat: %d value: %d\n",
// event.jhat.which, event.jhat.hat, event.jhat.value);
break;
case SDL_JOYBALLMOTION:
//printf("SDL_JOYBALLMOTION: joystick: %d ball: %d x: %d y: %d\n",
// event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
break;
case SDL_JOYDEVICEADDED:
//printf("SDL_JOYDEVICEADDED which:%d\n", event.jdevice.which);
break;
case SDL_JOYDEVICEREMOVED:
//printf("SDL_JOYDEVICEREMOVED which:%d\n", event.jdevice.which);
break;
case SDL_CONTROLLERAXISMOTION:
printf("SDL_CONTROLLERAXISMOTION controller: %d axis: %-12s value: %d\n",
event.caxis.which,
SDL_GameControllerGetStringForAxis(event.caxis.axis),
event.caxis.value);
break;
case SDL_CONTROLLERBUTTONDOWN:
printf("SDL_CONTROLLERBUTTONDOWN controller: %d button: %s state: %d\n",
event.cbutton.which,
SDL_GameControllerGetStringForButton(event.cbutton.button),
event.cbutton.state);
break;
case SDL_CONTROLLERBUTTONUP:
printf("SDL_CONTROLLERBUTTONUP controller: %d button: %s state: %d\n",
event.cbutton.which,
SDL_GameControllerGetStringForButton(event.cbutton.button),
event.cbutton.state);
break;
case SDL_CONTROLLERDEVICEADDED:
printf("SDL_CONTROLLERDEVICEADDED which:%d\n", event.cdevice.which);
break;
case SDL_CONTROLLERDEVICEREMOVED:
printf("SDL_CONTROLLERDEVICEREMOVED which:%d\n", event.cdevice.which);
break;
case SDL_CONTROLLERDEVICEREMAPPED:
printf("SDL_CONTROLLERDEVICEREMAPPED which:%d\n", event.cdevice.which);
break;
case SDL_QUIT:
quit = 1;
printf("Recieved interrupt, exiting\n");
break;
default:
fprintf(stderr, "Error: Unhandled event type: %#x\n", event.type);
break;
}
}
}
void test_gamecontroller_state(SDL_GameController* gamepad) {
assert(gamepad);
printf("Entering gamecontroller test loop, press Ctrl-c to exit\n");
int quit = 0;
SDL_Event event;
while(!quit && SDL_WaitEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
quit = 1;
printf("Recieved interrupt, exiting\n");
break;
}
for(int btn = 0; btn < SDL_CONTROLLER_BUTTON_MAX; ++btn) {
printf("%s:%d ",
SDL_GameControllerGetStringForButton(btn),
SDL_GameControllerGetButton(gamepad, btn));
}
for(int axis = 0; axis < SDL_CONTROLLER_AXIS_MAX; ++axis) {
printf("%s:%6d ",
SDL_GameControllerGetStringForAxis(axis),
SDL_GameControllerGetAxis(gamepad, axis));
}
printf("\n");
}
}
void test_gamecontroller(int gamecontroller_idx) {
SDL_GameController* gamepad = SDL_GameControllerOpen(gamecontroller_idx);
if (!gamepad) {
printf("error: not a gamecontroller\n");
} else {
//test_gamecontroller_events(gamepad);
test_gamecontroller_state(gamepad);
SDL_GameControllerClose(gamepad);
}
}
void event_joystick(int joy_idx) {
SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
if (!joy) {
fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
} else {
print_joystick_info(joy_idx, joy, NULL);
printf("Entering joystick test loop, press Ctrl-c to exit\n");
int quit = 0;
SDL_Event event;
while(!quit && SDL_WaitEvent(&event)) {
switch(event.type) {
case SDL_JOYAXISMOTION:
printf("SDL_JOYAXISMOTION: joystick: %d axis: %d value: %d\n",
event.jaxis.which, event.jaxis.axis, event.jaxis.value);
break;
case SDL_JOYBUTTONDOWN:
printf("SDL_JOYBUTTONDOWN: joystick: %d button: %d state: %d\n",
event.jbutton.which, event.jbutton.button, event.jbutton.state);
break;
case SDL_JOYBUTTONUP:
printf("SDL_JOYBUTTONUP: joystick: %d button: %d state: %d\n",
event.jbutton.which, event.jbutton.button, event.jbutton.state);
break;
case SDL_JOYHATMOTION:
printf("SDL_JOYHATMOTION: joystick: %d hat: %d value: %d\n",
event.jhat.which, event.jhat.hat, event.jhat.value);
break;
case SDL_JOYBALLMOTION:
printf("SDL_JOYBALLMOTION: joystick: %d ball: %d x: %d y: %d\n",
event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
break;
case SDL_JOYDEVICEADDED:
printf("SDL_JOYDEVICEADDED which:%d\n", event.jdevice.which);
break;
case SDL_JOYDEVICEREMOVED:
printf("SDL_JOYDEVICEREMOVED which:%d\n", event.jdevice.which);
break;
case SDL_CONTROLLERBUTTONDOWN:
printf("SDL_CONTROLLERBUTTONDOWN\n");
break;
case SDL_CONTROLLERBUTTONUP:
printf("SDL_CONTROLLERBUTTONUP\n");
break;
case SDL_CONTROLLERDEVICEADDED:
printf("SDL_CONTROLLERDEVICEADDED which:%d\n", event.cdevice.which);
break;
case SDL_CONTROLLERDEVICEREMOVED:
printf("SDL_CONTROLLERDEVICEREMOVED which:%d\n", event.cdevice.which);
break;
case SDL_CONTROLLERDEVICEREMAPPED:
printf("SDL_CONTROLLERDEVICEREMAPPED which:%d\n", event.cdevice.which);
break;
case SDL_QUIT:
quit = 1;
printf("Recieved interrupt, exiting\n");
break;
default:
fprintf(stderr, "Error: Unhandled event type: %d\n", event.type);
break;
}
}
SDL_JoystickClose(joy);
}
}
void test_rumble(int joy_idx) {
SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
if (!joy) {
fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
} else {
SDL_Haptic* haptic = SDL_HapticOpenFromJoystick(joy);
if (!haptic) {
fprintf(stderr, "Unable to open haptic on joystick %d\n", joy_idx);
fprintf(stderr, "SDL_Error: %s\n", SDL_GetError());
} else {
if (!SDL_HapticRumbleSupported(haptic)) {
fprintf(stderr, "rumble not supported on joystick %d\n", joy_idx);
} else {
if (SDL_HapticRumbleInit(haptic) != 0) {
fprintf(stderr, "failed to init rumble\n");
} else {
SDL_HapticRumblePlay(haptic, 1.0, 3000);
SDL_Delay(3000);
}
}
SDL_HapticClose(haptic);
}
SDL_JoystickClose(joy);
}
}
/* main() ********************************************************************/
int main(int argc, char** argv) {
if (argc == 1) {
print_help(argv[0]);
exit(1);
}
// SDL2 will only report events when the window has focus, so set
// this hint as we don't have a window
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
// FIXME: We don't need video, but without it SDL will fail to work in SDL_WaitEvent()
if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
} else {
atexit(SDL_Quit);
if (argc == 2 && (strcmp(argv[1], "--help") == 0 ||
strcmp(argv[1], "-h") == 0)) {
print_help(argv[0]);
}
else if (argc == 2 && (strcmp(argv[1], "--version") == 0)) {
puts(VERSION);
exit(EXIT_SUCCESS);
}
else if (argc == 2 && (strcmp(argv[1], "--list") == 0 ||
(strcmp(argv[1], "-l") == 0))) {
list_joysticks();
}
else if (argc == 2 && (strcmp(argv[1], "--listsimple") == 0 ||
(strcmp(argv[1], "-ls") == 0))) {
simple_list_joysticks();
}
else if (argc == 3 && (strcmp(argv[1], "--gamecontroller") == 0 ||
strcmp(argv[1], "-g") == 0)) {
int idx;
if (!str2int(argv[2], &idx)) {
fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
exit(1);
} else {
test_gamecontroller(idx);
}
}
else if (argc == 3 && (strcmp(argv[1], "--test") == 0 ||
strcmp(argv[1], "-t") == 0)) {
int joy_idx;
if (!str2int(argv[2], &joy_idx)) {
fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
exit(1);
} else {
test_joystick(joy_idx);
}
}
else if (argc == 3 && (strcmp(argv[1], "--event") == 0 ||
strcmp(argv[1], "-e") == 0)) {
int joy_idx;
if (!str2int(argv[2], &joy_idx)) {
fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
exit(1);
}
event_joystick(joy_idx);
}
else if (argc == 3 && (strcmp(argv[1], "--rumble") == 0 ||
strcmp(argv[1], "-r") == 0)) {
int idx;
if (!str2int(argv[2], &idx)) {
fprintf(stderr, "Error: JOYSTICKNUM argument must be a number, but was '%s'\n", argv[2]);
exit(1);
} else {
test_rumble(idx);
}
} else {
fprintf(stderr, "%s: unknown arguments\n", argv[0]);
fprintf(stderr, "Try '%s --help' for more informations\n", argv[0]);
}
}
}
/* EOF */