1 |
1275 |
phoenix |
/*
|
2 |
|
|
* $Id: hid-debug.h,v 1.1.1.1 2004-04-15 01:54:26 phoenix Exp $
|
3 |
|
|
*
|
4 |
|
|
* (c) 1999 Andreas Gal <gal@cs.uni-magdeburg.de>
|
5 |
|
|
* (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz>
|
6 |
|
|
*
|
7 |
|
|
* Some debug stuff for the HID parser.
|
8 |
|
|
*
|
9 |
|
|
* Sponsored by SuSE
|
10 |
|
|
*/
|
11 |
|
|
|
12 |
|
|
/*
|
13 |
|
|
* This program is free software; you can redistribute it and/or modify
|
14 |
|
|
* it under the terms of the GNU General Public License as published by
|
15 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
16 |
|
|
* (at your option) any later version.
|
17 |
|
|
*
|
18 |
|
|
* This program is distributed in the hope that it will be useful,
|
19 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
|
|
* GNU General Public License for more details.
|
22 |
|
|
*
|
23 |
|
|
* You should have received a copy of the GNU General Public License
|
24 |
|
|
* along with this program; if not, write to the Free Software
|
25 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26 |
|
|
*
|
27 |
|
|
* Should you need to contact me, the author, you can do so either by
|
28 |
|
|
* e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
|
29 |
|
|
* Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
struct hid_usage_entry {
|
33 |
|
|
unsigned page;
|
34 |
|
|
unsigned usage;
|
35 |
|
|
char *description;
|
36 |
|
|
};
|
37 |
|
|
|
38 |
|
|
static struct hid_usage_entry hid_usage_table[] = {
|
39 |
|
|
{ 1, 0, "GenericDesktop" },
|
40 |
|
|
{0, 0x01, "Pointer"},
|
41 |
|
|
{0, 0x02, "Mouse"},
|
42 |
|
|
{0, 0x04, "Joystick"},
|
43 |
|
|
{0, 0x05, "GamePad"},
|
44 |
|
|
{0, 0x06, "Keyboard"},
|
45 |
|
|
{0, 0x07, "Keypad"},
|
46 |
|
|
{0, 0x08, "MultiAxis"},
|
47 |
|
|
{0, 0x30, "X"},
|
48 |
|
|
{0, 0x31, "Y"},
|
49 |
|
|
{0, 0x32, "Z"},
|
50 |
|
|
{0, 0x33, "Rx"},
|
51 |
|
|
{0, 0x34, "Ry"},
|
52 |
|
|
{0, 0x35, "Rz"},
|
53 |
|
|
{0, 0x36, "Slider"},
|
54 |
|
|
{0, 0x37, "Dial"},
|
55 |
|
|
{0, 0x38, "Wheel"},
|
56 |
|
|
{0, 0x39, "HatSwitch"},
|
57 |
|
|
{0, 0x3a, "CountedBuffer"},
|
58 |
|
|
{0, 0x3b, "ByteCount"},
|
59 |
|
|
{0, 0x3c, "MotionWakeup"},
|
60 |
|
|
{0, 0x3d, "Start"},
|
61 |
|
|
{0, 0x3e, "Select"},
|
62 |
|
|
{0, 0x40, "Vx"},
|
63 |
|
|
{0, 0x41, "Vy"},
|
64 |
|
|
{0, 0x42, "Vz"},
|
65 |
|
|
{0, 0x43, "Vbrx"},
|
66 |
|
|
{0, 0x44, "Vbry"},
|
67 |
|
|
{0, 0x45, "Vbrz"},
|
68 |
|
|
{0, 0x46, "Vno"},
|
69 |
|
|
{0, 0x80, "SystemControl"},
|
70 |
|
|
{0, 0x81, "SystemPowerDown"},
|
71 |
|
|
{0, 0x82, "SystemSleep"},
|
72 |
|
|
{0, 0x83, "SystemWakeUp"},
|
73 |
|
|
{0, 0x84, "SystemContextMenu"},
|
74 |
|
|
{0, 0x85, "SystemMainMenu"},
|
75 |
|
|
{0, 0x86, "SystemAppMenu"},
|
76 |
|
|
{0, 0x87, "SystemMenuHelp"},
|
77 |
|
|
{0, 0x88, "SystemMenuExit"},
|
78 |
|
|
{0, 0x89, "SystemMenuSelect"},
|
79 |
|
|
{0, 0x8a, "SystemMenuRight"},
|
80 |
|
|
{0, 0x8b, "SystemMenuLeft"},
|
81 |
|
|
{0, 0x8c, "SystemMenuUp"},
|
82 |
|
|
{0, 0x8d, "SystemMenuDown"},
|
83 |
|
|
{0, 0x90, "D-padUp"},
|
84 |
|
|
{0, 0x91, "D-padDown"},
|
85 |
|
|
{0, 0x92, "D-padRight"},
|
86 |
|
|
{0, 0x93, "D-padLeft"},
|
87 |
|
|
{ 7, 0, "Keyboard" },
|
88 |
|
|
{ 8, 0, "LED" },
|
89 |
|
|
{ 9, 0, "Button" },
|
90 |
|
|
{ 12, 0, "Hotkey" },
|
91 |
|
|
{ 13, 0, "Digitizers" },
|
92 |
|
|
{0, 0x01, "Digitizer"},
|
93 |
|
|
{0, 0x02, "Pen"},
|
94 |
|
|
{0, 0x03, "LightPen"},
|
95 |
|
|
{0, 0x04, "TouchScreen"},
|
96 |
|
|
{0, 0x05, "TouchPad"},
|
97 |
|
|
{0, 0x20, "Stylus"},
|
98 |
|
|
{0, 0x21, "Puck"},
|
99 |
|
|
{0, 0x22, "Finger"},
|
100 |
|
|
{0, 0x30, "TipPressure"},
|
101 |
|
|
{0, 0x31, "BarrelPressure"},
|
102 |
|
|
{0, 0x32, "InRange"},
|
103 |
|
|
{0, 0x33, "Touch"},
|
104 |
|
|
{0, 0x34, "UnTouch"},
|
105 |
|
|
{0, 0x35, "Tap"},
|
106 |
|
|
{0, 0x39, "TabletFunctionKey"},
|
107 |
|
|
{0, 0x3a, "ProgramChangeKey"},
|
108 |
|
|
{0, 0x3c, "Invert"},
|
109 |
|
|
{0, 0x42, "TipSwitch"},
|
110 |
|
|
{0, 0x43, "SecondaryTipSwitch"},
|
111 |
|
|
{0, 0x44, "BarrelSwitch"},
|
112 |
|
|
{0, 0x45, "Eraser"},
|
113 |
|
|
{0, 0x46, "TabletPick"},
|
114 |
|
|
{ 15, 0, "PhysicalInterfaceDevice" },
|
115 |
|
|
{ 0, 0, NULL }
|
116 |
|
|
};
|
117 |
|
|
|
118 |
|
|
static void resolv_usage_page(unsigned page) {
|
119 |
|
|
struct hid_usage_entry *p;
|
120 |
|
|
|
121 |
|
|
for (p = hid_usage_table; p->description; p++)
|
122 |
|
|
if (p->page == page) {
|
123 |
|
|
printk("%s", p->description);
|
124 |
|
|
return;
|
125 |
|
|
}
|
126 |
|
|
printk("%04x", page);
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
static void resolv_usage(unsigned usage) {
|
130 |
|
|
struct hid_usage_entry *p;
|
131 |
|
|
|
132 |
|
|
resolv_usage_page(usage >> 16);
|
133 |
|
|
printk(".");
|
134 |
|
|
for (p = hid_usage_table; p->description; p++)
|
135 |
|
|
if (p->page == (usage >> 16)) {
|
136 |
|
|
for(++p; p->description && p->page == 0; p++)
|
137 |
|
|
if (p->usage == (usage & 0xffff)) {
|
138 |
|
|
printk("%s", p->description);
|
139 |
|
|
return;
|
140 |
|
|
}
|
141 |
|
|
break;
|
142 |
|
|
}
|
143 |
|
|
printk("%04x", usage & 0xffff);
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
__inline__ static void tab(int n) {
|
147 |
|
|
while (n--) printk(" ");
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
static void hid_dump_field(struct hid_field *field, int n) {
|
151 |
|
|
int j;
|
152 |
|
|
|
153 |
|
|
if (field->physical) {
|
154 |
|
|
tab(n);
|
155 |
|
|
printk("Physical(");
|
156 |
|
|
resolv_usage(field->physical); printk(")\n");
|
157 |
|
|
}
|
158 |
|
|
if (field->logical) {
|
159 |
|
|
tab(n);
|
160 |
|
|
printk("Logical(");
|
161 |
|
|
resolv_usage(field->logical); printk(")\n");
|
162 |
|
|
}
|
163 |
|
|
tab(n); printk("Usage(%d)\n", field->maxusage);
|
164 |
|
|
for (j = 0; j < field->maxusage; j++) {
|
165 |
|
|
tab(n+2);resolv_usage(field->usage[j].hid); printk("\n");
|
166 |
|
|
}
|
167 |
|
|
if (field->logical_minimum != field->logical_maximum) {
|
168 |
|
|
tab(n); printk("Logical Minimum(%d)\n", field->logical_minimum);
|
169 |
|
|
tab(n); printk("Logical Maximum(%d)\n", field->logical_maximum);
|
170 |
|
|
}
|
171 |
|
|
if (field->physical_minimum != field->physical_maximum) {
|
172 |
|
|
tab(n); printk("Physical Minimum(%d)\n", field->physical_minimum);
|
173 |
|
|
tab(n); printk("Physical Maximum(%d)\n", field->physical_maximum);
|
174 |
|
|
}
|
175 |
|
|
if (field->unit_exponent) {
|
176 |
|
|
tab(n); printk("Unit Exponent(%d)\n", field->unit_exponent);
|
177 |
|
|
}
|
178 |
|
|
if (field->unit) {
|
179 |
|
|
tab(n); printk("Unit(%u)\n", field->unit);
|
180 |
|
|
}
|
181 |
|
|
tab(n); printk("Report Size(%u)\n", field->report_size);
|
182 |
|
|
tab(n); printk("Report Count(%u)\n", field->report_count);
|
183 |
|
|
tab(n); printk("Report Offset(%u)\n", field->report_offset);
|
184 |
|
|
|
185 |
|
|
tab(n); printk("Flags( ");
|
186 |
|
|
j = field->flags;
|
187 |
|
|
printk("%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
|
188 |
|
|
printk("%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
|
189 |
|
|
printk("%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
|
190 |
|
|
printk("%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
|
191 |
|
|
printk("%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
|
192 |
|
|
printk("%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPrefferedState " : "");
|
193 |
|
|
printk("%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
|
194 |
|
|
printk("%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
|
195 |
|
|
printk("%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
|
196 |
|
|
printk(")\n");
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
static void hid_dump_device(struct hid_device *device) {
|
200 |
|
|
struct hid_report_enum *report_enum;
|
201 |
|
|
struct hid_report *report;
|
202 |
|
|
struct list_head *list;
|
203 |
|
|
unsigned i,k;
|
204 |
|
|
static char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
|
205 |
|
|
|
206 |
|
|
for (i = 0; i < device->maxapplication; i++) {
|
207 |
|
|
printk("Application(");
|
208 |
|
|
resolv_usage(device->application[i]);
|
209 |
|
|
printk(")\n");
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
for (i = 0; i < HID_REPORT_TYPES; i++) {
|
213 |
|
|
report_enum = device->report_enum + i;
|
214 |
|
|
list = report_enum->report_list.next;
|
215 |
|
|
while (list != &report_enum->report_list) {
|
216 |
|
|
report = (struct hid_report *) list;
|
217 |
|
|
tab(2);
|
218 |
|
|
printk("%s", table[i]);
|
219 |
|
|
if (report->id)
|
220 |
|
|
printk("(%d)", report->id);
|
221 |
|
|
printk("[%s]", table[report->type]);
|
222 |
|
|
printk("\n");
|
223 |
|
|
for (k = 0; k < report->maxfield; k++) {
|
224 |
|
|
tab(4);
|
225 |
|
|
printk("Field(%d)\n", k);
|
226 |
|
|
hid_dump_field(report->field[k], 6);
|
227 |
|
|
}
|
228 |
|
|
list = list->next;
|
229 |
|
|
}
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
static void hid_dump_input(struct hid_usage *usage, __s32 value) {
|
234 |
|
|
printk("hid-debug: input ");
|
235 |
|
|
resolv_usage(usage->hid);
|
236 |
|
|
printk(" = %d\n", value);
|
237 |
|
|
}
|