f24f259c114f32a25ebed760d8197a981f70fbfa
2 * Copyright 2002 Red Hat Inc., Durham, North Carolina.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * Rickard E. (Rik) Faith <faith@redhat.com>
36 * This code implements a low-level device driver for a non-keyboard,
37 * non-mouse USB device (e.g., a joystick or gamepad). */
39 #ifdef HAVE_DMX_CONFIG_H
40 #include <dmx-config.h>
43 #include "usb-private.h"
45 /*****************************************************************************/
46 /* Define some macros to make it easier to move this file to another
47 * part of the Xserver tree. All calls to the dmx* layer are #defined
48 * here for the .c file. The .h file will also have to be edited. */
49 #include "dmxinputinit.h"
50 #include "usb-other.h"
52 #define GETPRIV myPrivate *priv \
53 = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
55 #define LOG0(f) dmxLog(dmxDebug,f)
56 #define LOG1(f,a) dmxLog(dmxDebug,f,a)
57 #define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
58 #define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
59 #define FATAL0(f) dmxLog(dmxFatal,f)
60 #define FATAL1(f,a) dmxLog(dmxFatal,f,a)
61 #define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
62 #define MOTIONPROC dmxMotionProcPtr
63 #define ENQUEUEPROC dmxEnqueueProcPtr
64 #define CHECKPROC dmxCheckSpecialProcPtr
65 #define BLOCK DMXBlockType
67 /* End of interface definitions. */
68 /*****************************************************************************/
70 /** Read the USB device using #usbRead. */
72 othUSBRead(DevicePtr pDev
,
74 ENQUEUEPROC enqueue
, CHECKPROC checkspecial
, BLOCK block
)
76 usbRead(pDev
, motion
, enqueue
, 0xffff, block
);
79 /** Initialize \a pDev using #usbInit. */
81 othUSBInit(DevicePtr pDev
)
83 usbInit(pDev
, usbOther
);
86 /** Turn \a pDev on (i.e., take input from \a pDev). */
88 othUSBOn(DevicePtr pDev
)
97 /** Fill the \a info structure with information needed to initialize \a
100 othUSBGetInfo(DevicePtr pDev
, DMXLocalInitInfoPtr info
)
104 static KeySym keyboard_mapping
= NoSymbol
;
107 #define test_bit(bit) (priv->mask[(bit)/8] & (1 << ((bit)%8)))
109 /* Some USB mice devices return key
110 * events from their pair'd
113 info
->keySyms
.minKeyCode
= 8;
114 info
->keySyms
.maxKeyCode
= 8;
115 info
->keySyms
.mapWidth
= 1;
116 info
->keySyms
.map
= &keyboard_mapping
;
118 for (i
= 0; i
< EV_MAX
; i
++) {
125 info
->valuatorClass
= 1;
126 if (info
->numRelAxes
+ info
->numAbsAxes
> DMX_MAX_AXES
- 1) {
127 info
->numRelAxes
= DMX_MAX_AXES
- info
->numAbsAxes
- 1;
128 dmxLog(dmxWarning
, "Can only use %d relative axes\n",
132 info
->numRelAxes
= priv
->numRel
;
140 info
->valuatorClass
= 1;
141 if (info
->numRelAxes
+ info
->numAbsAxes
> DMX_MAX_AXES
- 1) {
142 info
->numAbsAxes
= DMX_MAX_AXES
- info
->numRelAxes
- 1;
143 dmxLog(dmxWarning
, "Can only use %d absolute axes\n",
147 info
->numAbsAxes
= priv
->numAbs
;
148 for (j
= 0; j
< info
->numAbsAxes
; j
++) {
149 ioctl(priv
->fd
, EVIOCGABS(j
), absolute
);
150 info
->minval
[1 + j
] = absolute
[1];
151 info
->maxval
[1 + j
] = absolute
[2];
152 info
->res
[1 + j
] = absolute
[3];
153 info
->minres
[1 + j
] = absolute
[3];
154 info
->maxres
[1 + j
] = absolute
[3];
158 info
->ledFeedbackClass
= 0; /* Not supported at this time */
161 info
->belFeedbackClass
= 0; /* Not supported at this time */