Line
Link Here
|
0 |
-- snes9x/unix/unix.cpp |
0 |
++ snes9x/unix/unix.cpp |
Lines 268-273
Link Here
|
268 |
else |
268 |
else |
269 |
S9xUsage (); |
269 |
S9xUsage (); |
270 |
} |
270 |
} |
|
|
271 |
else if (strcasecmp (argv [i], "-joydev3") == 0) |
272 |
{ |
273 |
if (i + 1 < argc) |
274 |
js_device[2] = argv[++i]; |
275 |
else |
276 |
S9xUsage (); |
277 |
} |
278 |
else if (strcasecmp (argv [i], "-joydev4") == 0) |
279 |
{ |
280 |
if (i + 1 < argc) |
281 |
js_device[3] = argv[++i]; |
282 |
else |
283 |
S9xUsage (); |
284 |
} |
271 |
else if (strcasecmp (argv [i], "-joymap1") == 0) |
285 |
else if (strcasecmp (argv [i], "-joymap1") == 0) |
272 |
{ |
286 |
{ |
273 |
if (i + 8 < argc) |
287 |
if (i + 8 < argc) |
Lines 705-758
Link Here
|
705 |
#ifdef JSIOCGVERSION |
719 |
#ifdef JSIOCGVERSION |
706 |
int version; |
720 |
int version; |
707 |
unsigned char axes, buttons; |
721 |
unsigned char axes, buttons; |
|
|
722 |
int i; |
708 |
|
723 |
|
709 |
if ((js_fd [0] = open (js_device [0], O_RDONLY | O_NONBLOCK)) < 0) |
724 |
for (i = 0; i < 4; i++) |
710 |
{ |
725 |
js_fd [i] = open (js_device [i], O_RDONLY | O_NONBLOCK); |
711 |
#ifdef DEBUGGER |
|
|
712 |
perror (js_device [0]); |
713 |
#endif |
714 |
fprintf(stderr, "joystick: No joystick found.\n"); |
715 |
return; |
716 |
} |
717 |
|
726 |
|
718 |
if (ioctl (js_fd [0], JSIOCGVERSION, &version)) |
727 |
for (i = 0; i < 4; i++) |
719 |
{ |
728 |
{ |
720 |
fprintf(stderr, "joystick: You need at least driver version 1.0" |
729 |
if (js_fd [i] >= 0 && ioctl (js_fd [i], JSIOCGVERSION, &version)) |
721 |
" for joystick support.\n"); |
730 |
{ |
722 |
close (js_fd [0]); |
731 |
fprintf(stderr, "joydev%d: You need at least driver version 1.0" |
723 |
return; |
732 |
" for joystick support.\n", i + 1); |
|
|
733 |
close (js_fd [i]); |
734 |
js_fd [i] = -1; |
735 |
} |
724 |
} |
736 |
} |
725 |
js_fd [1] = open (js_device [1], O_RDONLY | O_NONBLOCK); |
|
|
726 |
js_fd [2] = open (js_device [2], O_RDONLY | O_NONBLOCK); |
727 |
js_fd [3] = open (js_device [3], O_RDONLY | O_NONBLOCK); |
728 |
|
737 |
|
729 |
#ifdef JSIOCGNAME |
738 |
for (i = 0; i < 4; i++) |
730 |
char name [130]; |
|
|
731 |
bzero (name, 128); |
732 |
if (ioctl (js_fd [0], JSIOCGNAME(128), name) > 0) |
733 |
{ |
739 |
{ |
734 |
printf ("Using %s (%s) as pad1", name, js_device [0]); |
740 |
if (js_fd[i] < 0) continue; |
735 |
if (js_fd [1] > 0) |
741 |
#ifdef JSIOCGNAME |
|
|
742 |
char name [130]; |
743 |
bzero (name, 128); |
744 |
if (ioctl (js_fd [i], JSIOCGNAME(128), name) > 0) |
736 |
{ |
745 |
{ |
737 |
ioctl (js_fd [1], JSIOCGNAME(128), name); |
746 |
printf ("Using %s (%s) as pad%d", name, js_device [i], i + 1); |
738 |
printf ("and %s (%s) as pad2", name, js_device [1]); |
747 |
} |
739 |
} |
748 |
else |
740 |
} |
|
|
741 |
else |
742 |
#endif |
749 |
#endif |
743 |
{ |
|
|
744 |
ioctl (js_fd [0], JSIOCGAXES, &axes); |
745 |
ioctl (js_fd [0], JSIOCGBUTTONS, &buttons); |
746 |
printf ("Using %d-axis %d-button joystick (%s) as pad1", axes, buttons, js_device [0]); |
747 |
if (js_fd [1] > 0) |
748 |
{ |
750 |
{ |
749 |
ioctl (js_fd [0], JSIOCGAXES, &axes); |
751 |
ioctl (js_fd [i], JSIOCGAXES, &axes); |
750 |
ioctl (js_fd [0], JSIOCGBUTTONS, &buttons); |
752 |
ioctl (js_fd [i], JSIOCGBUTTONS, &buttons); |
751 |
printf (" and %d-axis %d-button (%s) as pad2", axes, buttons, js_device [1]); |
753 |
printf ("Using %d-axis %d-button joystick (%s) as pad%d", axes, buttons, js_device [i], i + 1); |
752 |
} |
754 |
} |
753 |
} |
|
|
754 |
|
755 |
|
755 |
puts ("."); |
756 |
puts ("."); |
|
|
757 |
} |
756 |
#endif |
758 |
#endif |
757 |
} |
759 |
} |
758 |
|
760 |
|
Lines 762-769
Link Here
|
762 |
struct js_event js_ev; |
764 |
struct js_event js_ev; |
763 |
int i; |
765 |
int i; |
764 |
|
766 |
|
765 |
for (i = 0; i < 4 && js_fd [i] >= 0; i++) |
767 |
for (i = 0; i < 4; i++) |
766 |
{ |
768 |
{ |
|
|
769 |
if (js_fd [i] < 0) continue; |
770 |
|
767 |
while (read (js_fd[i], &js_ev, sizeof (struct js_event)) == sizeof (struct js_event) ) |
771 |
while (read (js_fd[i], &js_ev, sizeof (struct js_event)) == sizeof (struct js_event) ) |
768 |
{ |
772 |
{ |
769 |
switch (js_ev.type & ~JS_EVENT_INIT) |
773 |
switch (js_ev.type & ~JS_EVENT_INIT) |