1 #include <proto/exec.h>
3 #include <proto/lowlevel.h>
4 #include <libraries/lowlevel_ext.h>
10 struct Library
*LowLevelBase
;
12 static void printbuttons(ULONG val
)
14 if (val
& JPF_BUTTON_PLAY
) printf("[PLAY/MMB]");
15 if (val
& JPF_BUTTON_REVERSE
) printf("[REVERSE]");
16 if (val
& JPF_BUTTON_FORWARD
) printf("[FORWARD]");
17 if (val
& JPF_BUTTON_GREEN
) printf("[SHUFFLE]");
18 if (val
& JPF_BUTTON_RED
) printf("[SELECT/LMB/FIRE]");
19 if (val
& JPF_BUTTON_BLUE
) printf("[STOP/RMB]");
22 static void printmousedirections(ULONG val
)
24 printf("[%d,%d]", (int)(val
& JP_MHORZ_MASK
), (int)(val
& JP_MVERT_MASK
) >> 8);
27 static void printajoydirections(ULONG val
)
29 printf("[%d, %d]", (int)(val
& JP_XAXIS_MASK
), (int)(val
& JP_YAXIS_MASK
) >> 8);
31 static void printjoydirections(ULONG val
)
33 if (val
& JPF_JOY_UP
) printf("[UP]");
34 if (val
& JPF_JOY_DOWN
) printf("[DOWN]");
35 if (val
& JPF_JOY_LEFT
) printf("[LEFT]");
36 if (val
& JPF_JOY_RIGHT
) printf("[RIGHT]");
39 static void printjoyport(ULONG val
)
43 for(i
= 31; i
>= 0; i
--)
45 printf("%d", (val
& (1 << i
)) ? 1 : 0);
50 if ((val
& JP_TYPE_MASK
) == JP_TYPE_NOTAVAIL
) printf("NOT AVAILABLE");
51 if ((val
& JP_TYPE_MASK
) == JP_TYPE_UNKNOWN
) printf("UNKNOWN");
53 if ((val
& JP_TYPE_MASK
) == JP_TYPE_JOYSTK
)
55 printf("JOYSTICK - ");
56 printjoydirections(val
);
60 if ((val
& JP_TYPE_MASK
) == JP_TYPE_GAMECTLR
)
62 printf("GAME CONTROLLER - ");
63 printjoydirections(val
);
67 if ((val
& JP_TYPE_MASK
) == JP_TYPE_MOUSE
)
70 printmousedirections(val
);
74 if ((val
& JP_TYPE_MASK
) == JP_TYPE_ANALOGUE
)
76 printf("JOYSTICK[ANALOGUE] - ");
77 printajoydirections(val
);
84 int main(int argc
, char **argv
)
88 if (argc
== 2) unit
= atoi(argv
[1]);
90 LowLevelBase
= OpenLibrary("lowlevel.library", 0);
96 while(!CheckSignal(SIGBREAKF_CTRL_C
))
100 new = ReadJoyPort(unit
);
109 CloseLibrary(LowLevelBase
);