2002-12-21 09:35:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <joystick.h>
|
|
|
|
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
unsigned char j;
|
|
|
|
unsigned char count;
|
|
|
|
unsigned char i;
|
|
|
|
|
2009-01-06 17:44:20 +00:00
|
|
|
#ifdef __NES__
|
|
|
|
extern void *co65_joy;
|
|
|
|
unsigned char Res = joy_install (&co65_joy);
|
|
|
|
#else
|
2002-12-21 09:35:54 +00:00
|
|
|
unsigned char Res = joy_load_driver (joy_stddrv);
|
2009-01-06 17:44:20 +00:00
|
|
|
#endif
|
2002-12-21 09:35:54 +00:00
|
|
|
if (Res != JOY_ERR_OK) {
|
|
|
|
cprintf ("Error in joy_load_driver: %u\r\n", Res);
|
|
|
|
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
clrscr ();
|
|
|
|
count = joy_count ();
|
|
|
|
cprintf ("Driver supports %d joystick(s)", count);
|
|
|
|
while (1) {
|
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
gotoxy (0, i+1);
|
|
|
|
j = joy_read (i);
|
2008-03-16 09:27:20 +00:00
|
|
|
cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
|
2002-12-21 09:35:54 +00:00
|
|
|
i,
|
|
|
|
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_DOWN])? " down " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_LEFT])? " left " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
2008-03-16 09:27:20 +00:00
|
|
|
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
|
2002-12-21 09:35:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|