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
|
$NetBSD: patch-aa,v 1.8 2004/07/13 20:51:58 kristerw Exp $
--- src/joystick/bsd/SDL_sysjoystick.c.orig 2004-02-18 18:22:01.000000000 +0100
+++ src/joystick/bsd/SDL_sysjoystick.c 2004-07-13 22:43:44.000000000 +0200
@@ -60,7 +60,7 @@
#include <sys/joystick.h>
#endif
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(HAVE_MACHINE_JOYSTICK) || defined(__OpenBSD__)
#include <machine/joystick.h>
#endif
@@ -238,6 +238,7 @@
struct hid_data *hdata;
struct report *rep;
int fd;
+ int i;
fd = open(path, O_RDONLY);
if (fd == -1) {
@@ -302,6 +303,8 @@
joy->nbuttons = 0;
joy->nhats = 0;
joy->nballs = 0;
+ for (i=0; i<JOYAXE_count; i++)
+ hw->axis_map[i] = -1;
while (hid_get_item(hdata, &hitem) > 0) {
char *sp;
@@ -328,8 +331,7 @@
unsigned usage = HID_USAGE(hitem.usage);
int joyaxe = usage_to_joyaxe(usage);
if (joyaxe >= 0) {
- hw->axis_map[joyaxe] = joy->naxes;
- joy->naxes++;
+ hw->axis_map[joyaxe] = 1;
} else if (usage == HUG_HAT_SWITCH) {
joy->nhats++;
}
@@ -347,6 +349,9 @@
}
}
hid_end_parse(hdata);
+ for (i=0; i<JOYAXE_count; i++)
+ if (hw->axis_map[i] > 0)
+ hw->axis_map[i] = joy->naxes++;
usbend:
/* The poll blocks the event thread. */
@@ -369,7 +374,7 @@
int nbutton, naxe = -1;
Sint32 v;
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(HAVE_MACHINE_JOYSTICK) || defined(__OpenBSD__)
struct joystick gameport;
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
@@ -456,7 +461,8 @@
} else if (usage == HUG_HAT_SWITCH) {
v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
&hitem);
- SDL_PrivateJoystickHat(joy, 0, hatval_to_sdl(v));
+ SDL_PrivateJoystickHat(joy, 0,
+ hatval_to_sdl(v)-hitem.logical_minimum);
}
break;
}
@@ -529,9 +535,9 @@
#endif
#else
# ifdef USBHID_NEW
- len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
-# else
len = hid_report_size(rd, repinfo[repind].kind, r->rid);
+# else
+ len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
# endif
#endif
|