49
49
#include <linux/input.h>
50
50
#include <linux/joystick.h>
52
54
char *axis_names[ABS_MAX + 1] = {
53
55
"X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder",
54
56
"Wheel", "Gas", "Brake", "?", "?", "?", "?", "?",
74
76
unsigned char buttons = 2;
75
77
int version = 0x000800;
76
78
char name[NAME_LENGTH] = "Unknown";
77
uint16_t btnmap[KEY_MAX - BTN_MISC + 1];
78
uint8_t axmap[ABS_MAX + 1];
79
uint16_t btnmap[BTNMAP_SIZE];
80
uint8_t axmap[AXMAP_SIZE];
80
83
if (argc < 2 || argc > 3 || !strcmp("--help", argv[1])) {
99
102
ioctl(fd, JSIOCGAXES, &axes);
100
103
ioctl(fd, JSIOCGBUTTONS, &buttons);
101
104
ioctl(fd, JSIOCGNAME(NAME_LENGTH), name);
102
ioctl(fd, JSIOCGAXMAP, axmap);
103
ioctl(fd, JSIOCGBTNMAP, btnmap);
107
getbtnmap(fd, btnmap);
106
109
printf("Driver version is %d.%d.%d.\n",
107
110
version >> 16, (version >> 8) & 0xff, version & 0xff);
109
printf("Joystick (%s) has %d axes (", name, axes);
110
for (i = 0; i < axes; i++)
111
printf("%s%s", i > 0 ? ", " : "", axis_names[axmap[i]]);
112
/* Determine whether the button map is usable. */
113
for (i = 0; btnmapok && i < buttons; i++) {
114
if (btnmap[i] < BTN_MISC || btnmap[i] > KEY_MAX) {
120
/* btnmap out of range for names. Don't print any. */
121
puts("jstest is not fully compatible with your kernel. Unable to retrieve button map!");
122
printf("Joystick (%s) has %d axes ", name, axes);
123
printf("and %d buttons.\n", buttons);
125
printf("Joystick (%s) has %d axes (", name, axes);
126
for (i = 0; i < axes; i++)
127
printf("%s%s", i > 0 ? ", " : "", axis_names[axmap[i]]);
114
printf("and %d buttons (", buttons);
115
for (i = 0; i < buttons; i++)
116
printf("%s%s", i > 0 ? ", " : "", button_names[btnmap[i] - BTN_MISC]);
130
printf("and %d buttons (", buttons);
131
for (i = 0; i < buttons; i++) {
132
printf("%s%s", i > 0 ? ", " : "", button_names[btnmap[i] - BTN_MISC]);
119
137
printf("Testing ... (interrupt to exit)\n");