[PATCH] USB: fix up some sparse warnings about static functions that aren't static.
[linux-2.6] / drivers / usb / input / hid-debug.h
1 /*
2  * $Id: hid-debug.h,v 1.8 2001/09/25 09:37:57 vojtech Exp $
3  *
4  *  (c) 1999 Andreas Gal                <gal@cs.uni-magdeburg.de>
5  *  (c) 2000-2001 Vojtech Pavlik        <vojtech@ucw.cz>
6  *
7  *  Some debug stuff for the HID parser.
8  */
9
10 /*
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  * Should you need to contact me, the author, you can do so either by
26  * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27  * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28  */
29
30 #include <linux/input.h>
31
32 struct hid_usage_entry {
33         unsigned  page;
34         unsigned  usage;
35         char     *description;
36 };
37
38 static const struct hid_usage_entry hid_usage_table[] = {
39   {  0,      0, "Undefined" },
40   {  1,      0, "GenericDesktop" },
41     {0, 0x01, "Pointer"},
42     {0, 0x02, "Mouse"},
43     {0, 0x04, "Joystick"},
44     {0, 0x05, "GamePad"},
45     {0, 0x06, "Keyboard"},
46     {0, 0x07, "Keypad"},
47     {0, 0x08, "MultiAxis"},
48       {0, 0x30, "X"},
49       {0, 0x31, "Y"},
50       {0, 0x32, "Z"},
51       {0, 0x33, "Rx"},
52       {0, 0x34, "Ry"},
53       {0, 0x35, "Rz"},
54       {0, 0x36, "Slider"},
55       {0, 0x37, "Dial"},
56       {0, 0x38, "Wheel"},
57       {0, 0x39, "HatSwitch"},
58     {0, 0x3a, "CountedBuffer"},
59       {0, 0x3b, "ByteCount"},
60       {0, 0x3c, "MotionWakeup"},
61       {0, 0x3d, "Start"},
62       {0, 0x3e, "Select"},
63       {0, 0x40, "Vx"},
64       {0, 0x41, "Vy"},
65       {0, 0x42, "Vz"},
66       {0, 0x43, "Vbrx"},
67       {0, 0x44, "Vbry"},
68       {0, 0x45, "Vbrz"},
69       {0, 0x46, "Vno"},
70     {0, 0x80, "SystemControl"}, 
71       {0, 0x81, "SystemPowerDown"},
72       {0, 0x82, "SystemSleep"},
73       {0, 0x83, "SystemWakeUp"},
74       {0, 0x84, "SystemContextMenu"},
75       {0, 0x85, "SystemMainMenu"},
76       {0, 0x86, "SystemAppMenu"},
77       {0, 0x87, "SystemMenuHelp"},
78       {0, 0x88, "SystemMenuExit"},
79       {0, 0x89, "SystemMenuSelect"},
80       {0, 0x8a, "SystemMenuRight"},
81       {0, 0x8b, "SystemMenuLeft"},
82       {0, 0x8c, "SystemMenuUp"},
83       {0, 0x8d, "SystemMenuDown"},
84       {0, 0x90, "D-PadUp"},
85       {0, 0x91, "D-PadDown"},
86       {0, 0x92, "D-PadRight"},
87       {0, 0x93, "D-PadLeft"},
88   {  7, 0, "Keyboard" },
89   {  8, 0, "LED" },
90       {0, 0x01, "NumLock"},
91       {0, 0x02, "CapsLock"},
92       {0, 0x03, "ScrollLock"},
93       {0, 0x04, "Compose"},
94       {0, 0x05, "Kana"},
95   {  9, 0, "Button" },
96   { 10, 0, "Ordinal" },
97   { 12, 0, "Consumer" },
98       {0, 0x238, "HorizontalWheel"},
99   { 13, 0, "Digitizers" },
100     {0, 0x01, "Digitizer"},
101     {0, 0x02, "Pen"},
102     {0, 0x03, "LightPen"},
103     {0, 0x04, "TouchScreen"},
104     {0, 0x05, "TouchPad"},
105     {0, 0x20, "Stylus"},
106     {0, 0x21, "Puck"},
107     {0, 0x22, "Finger"},
108     {0, 0x30, "TipPressure"},
109     {0, 0x31, "BarrelPressure"},
110     {0, 0x32, "InRange"},
111     {0, 0x33, "Touch"},
112     {0, 0x34, "UnTouch"},
113     {0, 0x35, "Tap"},
114     {0, 0x39, "TabletFunctionKey"},
115     {0, 0x3a, "ProgramChangeKey"},
116     {0, 0x3c, "Invert"},
117     {0, 0x42, "TipSwitch"},
118     {0, 0x43, "SecondaryTipSwitch"},
119     {0, 0x44, "BarrelSwitch"},
120     {0, 0x45, "Eraser"},
121     {0, 0x46, "TabletPick"},
122   { 15, 0, "PhysicalInterfaceDevice" },
123     {0, 0x00, "Undefined"},
124     {0, 0x01, "Physical_Interface_Device"},
125       {0, 0x20, "Normal"},
126     {0, 0x21, "Set_Effect_Report"},
127       {0, 0x22, "Effect_Block_Index"},
128       {0, 0x23, "Parameter_Block_Offset"},
129       {0, 0x24, "ROM_Flag"},
130       {0, 0x25, "Effect_Type"},
131         {0, 0x26, "ET_Constant_Force"},
132         {0, 0x27, "ET_Ramp"},
133         {0, 0x28, "ET_Custom_Force_Data"},
134         {0, 0x30, "ET_Square"},
135         {0, 0x31, "ET_Sine"},
136         {0, 0x32, "ET_Triangle"},
137         {0, 0x33, "ET_Sawtooth_Up"},
138         {0, 0x34, "ET_Sawtooth_Down"},
139         {0, 0x40, "ET_Spring"},
140         {0, 0x41, "ET_Damper"},
141         {0, 0x42, "ET_Inertia"},
142         {0, 0x43, "ET_Friction"},
143       {0, 0x50, "Duration"},
144       {0, 0x51, "Sample_Period"},
145       {0, 0x52, "Gain"},
146       {0, 0x53, "Trigger_Button"},
147       {0, 0x54, "Trigger_Repeat_Interval"},
148       {0, 0x55, "Axes_Enable"},
149         {0, 0x56, "Direction_Enable"},
150       {0, 0x57, "Direction"},
151       {0, 0x58, "Type_Specific_Block_Offset"},
152         {0, 0x59, "Block_Type"},
153         {0, 0x5A, "Set_Envelope_Report"},
154           {0, 0x5B, "Attack_Level"},
155           {0, 0x5C, "Attack_Time"},
156           {0, 0x5D, "Fade_Level"},
157           {0, 0x5E, "Fade_Time"},
158         {0, 0x5F, "Set_Condition_Report"},
159         {0, 0x60, "CP_Offset"},
160         {0, 0x61, "Positive_Coefficient"},
161         {0, 0x62, "Negative_Coefficient"},
162         {0, 0x63, "Positive_Saturation"},
163         {0, 0x64, "Negative_Saturation"},
164         {0, 0x65, "Dead_Band"},
165       {0, 0x66, "Download_Force_Sample"},
166       {0, 0x67, "Isoch_Custom_Force_Enable"},
167       {0, 0x68, "Custom_Force_Data_Report"},
168         {0, 0x69, "Custom_Force_Data"},
169         {0, 0x6A, "Custom_Force_Vendor_Defined_Data"},
170       {0, 0x6B, "Set_Custom_Force_Report"},
171         {0, 0x6C, "Custom_Force_Data_Offset"},
172         {0, 0x6D, "Sample_Count"},
173       {0, 0x6E, "Set_Periodic_Report"},
174         {0, 0x6F, "Offset"},
175         {0, 0x70, "Magnitude"},
176         {0, 0x71, "Phase"},
177         {0, 0x72, "Period"},
178       {0, 0x73, "Set_Constant_Force_Report"},
179         {0, 0x74, "Set_Ramp_Force_Report"},
180         {0, 0x75, "Ramp_Start"},
181         {0, 0x76, "Ramp_End"},
182       {0, 0x77, "Effect_Operation_Report"},
183         {0, 0x78, "Effect_Operation"},
184           {0, 0x79, "Op_Effect_Start"},
185           {0, 0x7A, "Op_Effect_Start_Solo"},
186           {0, 0x7B, "Op_Effect_Stop"},
187           {0, 0x7C, "Loop_Count"},
188       {0, 0x7D, "Device_Gain_Report"},
189         {0, 0x7E, "Device_Gain"},
190     {0, 0x7F, "PID_Pool_Report"},
191       {0, 0x80, "RAM_Pool_Size"},
192       {0, 0x81, "ROM_Pool_Size"},
193       {0, 0x82, "ROM_Effect_Block_Count"},
194       {0, 0x83, "Simultaneous_Effects_Max"},
195       {0, 0x84, "Pool_Alignment"},
196     {0, 0x85, "PID_Pool_Move_Report"},
197       {0, 0x86, "Move_Source"},
198       {0, 0x87, "Move_Destination"},
199       {0, 0x88, "Move_Length"},
200     {0, 0x89, "PID_Block_Load_Report"},
201       {0, 0x8B, "Block_Load_Status"},
202       {0, 0x8C, "Block_Load_Success"},
203       {0, 0x8D, "Block_Load_Full"},
204       {0, 0x8E, "Block_Load_Error"},
205       {0, 0x8F, "Block_Handle"},
206       {0, 0x90, "PID_Block_Free_Report"},
207       {0, 0x91, "Type_Specific_Block_Handle"},
208     {0, 0x92, "PID_State_Report"},
209       {0, 0x94, "Effect_Playing"},
210       {0, 0x95, "PID_Device_Control_Report"},
211         {0, 0x96, "PID_Device_Control"},
212         {0, 0x97, "DC_Enable_Actuators"},
213         {0, 0x98, "DC_Disable_Actuators"},
214         {0, 0x99, "DC_Stop_All_Effects"},
215         {0, 0x9A, "DC_Device_Reset"},
216         {0, 0x9B, "DC_Device_Pause"},
217         {0, 0x9C, "DC_Device_Continue"},
218       {0, 0x9F, "Device_Paused"},
219       {0, 0xA0, "Actuators_Enabled"},
220       {0, 0xA4, "Safety_Switch"},
221       {0, 0xA5, "Actuator_Override_Switch"},
222       {0, 0xA6, "Actuator_Power"},
223     {0, 0xA7, "Start_Delay"},
224     {0, 0xA8, "Parameter_Block_Size"},
225     {0, 0xA9, "Device_Managed_Pool"},
226     {0, 0xAA, "Shared_Parameter_Blocks"},
227     {0, 0xAB, "Create_New_Effect_Report"},
228     {0, 0xAC, "RAM_Pool_Available"},
229   { 0x84, 0, "Power Device" },
230     { 0x84, 0x02, "PresentStatus" },
231     { 0x84, 0x03, "ChangeStatus" },
232     { 0x84, 0x04, "UPS" },
233     { 0x84, 0x05, "PowerSupply" },
234     { 0x84, 0x10, "BatterySystem" },
235     { 0x84, 0x11, "BatterySystemID" },
236     { 0x84, 0x12, "Battery" },
237     { 0x84, 0x13, "BatteryID" },
238     { 0x84, 0x14, "Charger" },
239     { 0x84, 0x15, "ChargerID" },
240     { 0x84, 0x16, "PowerConverter" },
241     { 0x84, 0x17, "PowerConverterID" },
242     { 0x84, 0x18, "OutletSystem" },
243     { 0x84, 0x19, "OutletSystemID" },
244     { 0x84, 0x1a, "Input" },
245     { 0x84, 0x1b, "InputID" },
246     { 0x84, 0x1c, "Output" },
247     { 0x84, 0x1d, "OutputID" },
248     { 0x84, 0x1e, "Flow" },
249     { 0x84, 0x1f, "FlowID" },
250     { 0x84, 0x20, "Outlet" },
251     { 0x84, 0x21, "OutletID" },
252     { 0x84, 0x22, "Gang" },
253     { 0x84, 0x24, "PowerSummary" },
254     { 0x84, 0x25, "PowerSummaryID" },
255     { 0x84, 0x30, "Voltage" },
256     { 0x84, 0x31, "Current" },
257     { 0x84, 0x32, "Frequency" },
258     { 0x84, 0x33, "ApparentPower" },
259     { 0x84, 0x35, "PercentLoad" },
260     { 0x84, 0x40, "ConfigVoltage" },
261     { 0x84, 0x41, "ConfigCurrent" },
262     { 0x84, 0x43, "ConfigApparentPower" },
263     { 0x84, 0x53, "LowVoltageTransfer" },
264     { 0x84, 0x54, "HighVoltageTransfer" },
265     { 0x84, 0x56, "DelayBeforeStartup" },
266     { 0x84, 0x57, "DelayBeforeShutdown" },
267     { 0x84, 0x58, "Test" },
268     { 0x84, 0x5a, "AudibleAlarmControl" },
269     { 0x84, 0x60, "Present" },
270     { 0x84, 0x61, "Good" },
271     { 0x84, 0x62, "InternalFailure" },
272     { 0x84, 0x65, "Overload" },
273     { 0x84, 0x66, "OverCharged" },
274     { 0x84, 0x67, "OverTemperature" },
275     { 0x84, 0x68, "ShutdownRequested" },
276     { 0x84, 0x69, "ShutdownImminent" },
277     { 0x84, 0x6b, "SwitchOn/Off" },
278     { 0x84, 0x6c, "Switchable" },
279     { 0x84, 0x6d, "Used" },
280     { 0x84, 0x6e, "Boost" },
281     { 0x84, 0x73, "CommunicationLost" },
282     { 0x84, 0xfd, "iManufacturer" },
283     { 0x84, 0xfe, "iProduct" },
284     { 0x84, 0xff, "iSerialNumber" },
285   { 0x85, 0, "Battery System" },
286     { 0x85, 0x01, "SMBBatteryMode" },
287     { 0x85, 0x02, "SMBBatteryStatus" },
288     { 0x85, 0x03, "SMBAlarmWarning" },
289     { 0x85, 0x04, "SMBChargerMode" },
290     { 0x85, 0x05, "SMBChargerStatus" },
291     { 0x85, 0x06, "SMBChargerSpecInfo" },
292     { 0x85, 0x07, "SMBSelectorState" },
293     { 0x85, 0x08, "SMBSelectorPresets" },
294     { 0x85, 0x09, "SMBSelectorInfo" },
295     { 0x85, 0x29, "RemainingCapacityLimit" },
296     { 0x85, 0x2c, "CapacityMode" },
297     { 0x85, 0x42, "BelowRemainingCapacityLimit" },
298     { 0x85, 0x44, "Charging" },
299     { 0x85, 0x45, "Discharging" },
300     { 0x85, 0x4b, "NeedReplacement" },
301     { 0x85, 0x66, "RemainingCapacity" },
302     { 0x85, 0x68, "RunTimeToEmpty" },
303     { 0x85, 0x6a, "AverageTimeToFull" },
304     { 0x85, 0x83, "DesignCapacity" },
305     { 0x85, 0x85, "ManufacturerDate" },
306     { 0x85, 0x89, "iDeviceChemistry" },
307     { 0x85, 0x8b, "Rechargable" },
308     { 0x85, 0x8f, "iOEMInformation" },
309     { 0x85, 0x8d, "CapacityGranularity1" },
310     { 0x85, 0xd0, "ACPresent" },
311   /* pages 0xff00 to 0xffff are vendor-specific */
312   { 0xffff, 0, "Vendor-specific-FF" },
313   { 0, 0, NULL }
314 };
315
316 static void resolv_usage_page(unsigned page) {
317         const struct hid_usage_entry *p;
318
319         for (p = hid_usage_table; p->description; p++)
320                 if (p->page == page) {
321                         printk("%s", p->description);
322                         return;
323                 }
324         printk("%04x", page);
325 }
326
327 static void resolv_usage(unsigned usage) {
328         const struct hid_usage_entry *p;
329
330         resolv_usage_page(usage >> 16);
331         printk(".");
332         for (p = hid_usage_table; p->description; p++)
333                 if (p->page == (usage >> 16)) {
334                         for(++p; p->description && p->usage != 0; p++)
335                                 if (p->usage == (usage & 0xffff)) {
336                                         printk("%s", p->description);
337                                         return;
338                                 }
339                         break;
340                 }
341         printk("%04x", usage & 0xffff);
342 }
343
344 __inline__ static void tab(int n) {
345         while (n--) printk(" ");
346 }
347
348 static void hid_dump_field(struct hid_field *field, int n) {
349         int j;
350         
351         if (field->physical) {
352                 tab(n);
353                 printk("Physical(");
354                 resolv_usage(field->physical); printk(")\n");
355         }
356         if (field->logical) {
357                 tab(n);
358                 printk("Logical(");
359                 resolv_usage(field->logical); printk(")\n");
360         }
361         tab(n); printk("Usage(%d)\n", field->maxusage);
362         for (j = 0; j < field->maxusage; j++) {
363                 tab(n+2);resolv_usage(field->usage[j].hid); printk("\n");
364         }
365         if (field->logical_minimum != field->logical_maximum) {
366                 tab(n); printk("Logical Minimum(%d)\n", field->logical_minimum);
367                 tab(n); printk("Logical Maximum(%d)\n", field->logical_maximum);
368         }
369         if (field->physical_minimum != field->physical_maximum) {
370                 tab(n); printk("Physical Minimum(%d)\n", field->physical_minimum);
371                 tab(n); printk("Physical Maximum(%d)\n", field->physical_maximum);
372         }
373         if (field->unit_exponent) {
374                 tab(n); printk("Unit Exponent(%d)\n", field->unit_exponent);
375         }
376         if (field->unit) {
377                 char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" };
378                 char *units[5][8] = {
379                         { "None", "None", "None", "None", "None", "None", "None", "None" },
380                         { "None", "Centimeter", "Gram", "Seconds", "Kelvin",     "Ampere", "Candela", "None" },
381                         { "None", "Radians",    "Gram", "Seconds", "Kelvin",     "Ampere", "Candela", "None" },
382                         { "None", "Inch",       "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" },
383                         { "None", "Degrees",    "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }
384                 };
385
386                 int i;
387                 int sys;
388                 __u32 data = field->unit;
389
390                 /* First nibble tells us which system we're in. */
391                 sys = data & 0xf;
392                 data >>= 4;
393
394                 if(sys > 4) {
395                         tab(n); printk("Unit(Invalid)\n");
396                 }
397                 else {
398                         int earlier_unit = 0;
399
400                         tab(n); printk("Unit(%s : ", systems[sys]);
401
402                         for (i=1 ; i<sizeof(__u32)*2 ; i++) {
403                                 char nibble = data & 0xf;
404                                 data >>= 4;
405                                 if (nibble != 0) {
406                                         if(earlier_unit++ > 0)
407                                                 printk("*");
408                                         printk("%s", units[sys][i]);
409                                         if(nibble != 1) {
410                                                 /* This is a _signed_ nibble(!) */
411         
412                                                 int val = nibble & 0x7;
413                                                 if(nibble & 0x08)
414                                                         val = -((0x7 & ~val) +1);
415                                                 printk("^%d", val);
416                                         }
417                                 }
418                         }
419                         printk(")\n");
420                 }
421         }
422         tab(n); printk("Report Size(%u)\n", field->report_size);
423         tab(n); printk("Report Count(%u)\n", field->report_count);
424         tab(n); printk("Report Offset(%u)\n", field->report_offset);
425
426         tab(n); printk("Flags( ");
427         j = field->flags;
428         printk("%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
429         printk("%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
430         printk("%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
431         printk("%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
432         printk("%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
433         printk("%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPrefferedState " : "");
434         printk("%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
435         printk("%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
436         printk("%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
437         printk(")\n");
438 }
439
440 static void __attribute__((unused)) hid_dump_device(struct hid_device *device) {
441         struct hid_report_enum *report_enum;
442         struct hid_report *report;
443         struct list_head *list;
444         unsigned i,k;
445         static char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
446         
447         for (i = 0; i < HID_REPORT_TYPES; i++) {
448                 report_enum = device->report_enum + i;
449                 list = report_enum->report_list.next;
450                 while (list != &report_enum->report_list) {
451                         report = (struct hid_report *) list;
452                         tab(2);
453                         printk("%s", table[i]);
454                         if (report->id)
455                                 printk("(%d)", report->id);
456                         printk("[%s]", table[report->type]);
457                         printk("\n");
458                         for (k = 0; k < report->maxfield; k++) {
459                                 tab(4);
460                                 printk("Field(%d)\n", k);
461                                 hid_dump_field(report->field[k], 6);
462                         }
463                         list = list->next;
464                 }
465         }
466 }
467
468 static void __attribute__((unused)) hid_dump_input(struct hid_usage *usage, __s32 value) {
469         printk("hid-debug: input ");
470         resolv_usage(usage->hid);
471         printk(" = %d\n", value);
472 }
473
474
475 static char *events[EV_MAX + 1] = {
476         [EV_SYN] = "Sync",                      [EV_KEY] = "Key",
477         [EV_REL] = "Relative",                  [EV_ABS] = "Absolute",
478         [EV_MSC] = "Misc",                      [EV_LED] = "LED",
479         [EV_SND] = "Sound",                     [EV_REP] = "Repeat",
480         [EV_FF] = "ForceFeedback",              [EV_PWR] = "Power",
481         [EV_FF_STATUS] = "ForceFeedbackStatus",
482 };
483
484 static char *syncs[2] = {
485         [SYN_REPORT] = "Report",                [SYN_CONFIG] = "Config",
486 };
487 static char *keys[KEY_MAX + 1] = {
488         [KEY_RESERVED] = "Reserved",            [KEY_ESC] = "Esc",
489         [KEY_1] = "1",                          [KEY_2] = "2",
490         [KEY_3] = "3",                          [KEY_4] = "4",
491         [KEY_5] = "5",                          [KEY_6] = "6",
492         [KEY_7] = "7",                          [KEY_8] = "8",
493         [KEY_9] = "9",                          [KEY_0] = "0",
494         [KEY_MINUS] = "Minus",                  [KEY_EQUAL] = "Equal",
495         [KEY_BACKSPACE] = "Backspace",          [KEY_TAB] = "Tab",
496         [KEY_Q] = "Q",                          [KEY_W] = "W",
497         [KEY_E] = "E",                          [KEY_R] = "R",
498         [KEY_T] = "T",                          [KEY_Y] = "Y",
499         [KEY_U] = "U",                          [KEY_I] = "I",
500         [KEY_O] = "O",                          [KEY_P] = "P",
501         [KEY_LEFTBRACE] = "LeftBrace",          [KEY_RIGHTBRACE] = "RightBrace",
502         [KEY_ENTER] = "Enter",                  [KEY_LEFTCTRL] = "LeftControl",
503         [KEY_A] = "A",                          [KEY_S] = "S",
504         [KEY_D] = "D",                          [KEY_F] = "F",
505         [KEY_G] = "G",                          [KEY_H] = "H",
506         [KEY_J] = "J",                          [KEY_K] = "K",
507         [KEY_L] = "L",                          [KEY_SEMICOLON] = "Semicolon",
508         [KEY_APOSTROPHE] = "Apostrophe",        [KEY_GRAVE] = "Grave",
509         [KEY_LEFTSHIFT] = "LeftShift",          [KEY_BACKSLASH] = "BackSlash",
510         [KEY_Z] = "Z",                          [KEY_X] = "X",
511         [KEY_C] = "C",                          [KEY_V] = "V",
512         [KEY_B] = "B",                          [KEY_N] = "N",
513         [KEY_M] = "M",                          [KEY_COMMA] = "Comma",
514         [KEY_DOT] = "Dot",                      [KEY_SLASH] = "Slash",
515         [KEY_RIGHTSHIFT] = "RightShift",        [KEY_KPASTERISK] = "KPAsterisk",
516         [KEY_LEFTALT] = "LeftAlt",              [KEY_SPACE] = "Space",
517         [KEY_CAPSLOCK] = "CapsLock",            [KEY_F1] = "F1",
518         [KEY_F2] = "F2",                        [KEY_F3] = "F3",
519         [KEY_F4] = "F4",                        [KEY_F5] = "F5",
520         [KEY_F6] = "F6",                        [KEY_F7] = "F7",
521         [KEY_F8] = "F8",                        [KEY_F9] = "F9",
522         [KEY_F10] = "F10",                      [KEY_NUMLOCK] = "NumLock",
523         [KEY_SCROLLLOCK] = "ScrollLock",        [KEY_KP7] = "KP7",
524         [KEY_KP8] = "KP8",                      [KEY_KP9] = "KP9",
525         [KEY_KPMINUS] = "KPMinus",              [KEY_KP4] = "KP4",
526         [KEY_KP5] = "KP5",                      [KEY_KP6] = "KP6",
527         [KEY_KPPLUS] = "KPPlus",                [KEY_KP1] = "KP1",
528         [KEY_KP2] = "KP2",                      [KEY_KP3] = "KP3",
529         [KEY_KP0] = "KP0",                      [KEY_KPDOT] = "KPDot",
530         [KEY_ZENKAKUHANKAKU] = "Zenkaku/Hankaku", [KEY_102ND] = "102nd",
531         [KEY_F11] = "F11",                      [KEY_F12] = "F12",
532         [KEY_RO] = "RO",                        [KEY_KATAKANA] = "Katakana",
533         [KEY_HIRAGANA] = "HIRAGANA",            [KEY_HENKAN] = "Henkan",
534         [KEY_KATAKANAHIRAGANA] = "Katakana/Hiragana", [KEY_MUHENKAN] = "Muhenkan",
535         [KEY_KPJPCOMMA] = "KPJpComma",          [KEY_KPENTER] = "KPEnter",
536         [KEY_RIGHTCTRL] = "RightCtrl",          [KEY_KPSLASH] = "KPSlash",
537         [KEY_SYSRQ] = "SysRq",                  [KEY_RIGHTALT] = "RightAlt",
538         [KEY_LINEFEED] = "LineFeed",            [KEY_HOME] = "Home",
539         [KEY_UP] = "Up",                        [KEY_PAGEUP] = "PageUp",
540         [KEY_LEFT] = "Left",                    [KEY_RIGHT] = "Right",
541         [KEY_END] = "End",                      [KEY_DOWN] = "Down",
542         [KEY_PAGEDOWN] = "PageDown",            [KEY_INSERT] = "Insert",
543         [KEY_DELETE] = "Delete",                [KEY_MACRO] = "Macro",
544         [KEY_MUTE] = "Mute",                    [KEY_VOLUMEDOWN] = "VolumeDown",
545         [KEY_VOLUMEUP] = "VolumeUp",            [KEY_POWER] = "Power",
546         [KEY_KPEQUAL] = "KPEqual",              [KEY_KPPLUSMINUS] = "KPPlusMinus",
547         [KEY_PAUSE] = "Pause",                  [KEY_KPCOMMA] = "KPComma",
548         [KEY_HANGUEL] = "Hanguel",              [KEY_HANJA] = "Hanja",
549         [KEY_YEN] = "Yen",                      [KEY_LEFTMETA] = "LeftMeta",
550         [KEY_RIGHTMETA] = "RightMeta",          [KEY_COMPOSE] = "Compose",
551         [KEY_STOP] = "Stop",                    [KEY_AGAIN] = "Again",
552         [KEY_PROPS] = "Props",                  [KEY_UNDO] = "Undo",
553         [KEY_FRONT] = "Front",                  [KEY_COPY] = "Copy",
554         [KEY_OPEN] = "Open",                    [KEY_PASTE] = "Paste",
555         [KEY_FIND] = "Find",                    [KEY_CUT] = "Cut",
556         [KEY_HELP] = "Help",                    [KEY_MENU] = "Menu",
557         [KEY_CALC] = "Calc",                    [KEY_SETUP] = "Setup",
558         [KEY_SLEEP] = "Sleep",                  [KEY_WAKEUP] = "WakeUp",
559         [KEY_FILE] = "File",                    [KEY_SENDFILE] = "SendFile",
560         [KEY_DELETEFILE] = "DeleteFile",        [KEY_XFER] = "X-fer",
561         [KEY_PROG1] = "Prog1",                  [KEY_PROG2] = "Prog2",
562         [KEY_WWW] = "WWW",                      [KEY_MSDOS] = "MSDOS",
563         [KEY_COFFEE] = "Coffee",                [KEY_DIRECTION] = "Direction",
564         [KEY_CYCLEWINDOWS] = "CycleWindows",    [KEY_MAIL] = "Mail",
565         [KEY_BOOKMARKS] = "Bookmarks",          [KEY_COMPUTER] = "Computer",
566         [KEY_BACK] = "Back",                    [KEY_FORWARD] = "Forward",
567         [KEY_CLOSECD] = "CloseCD",              [KEY_EJECTCD] = "EjectCD",
568         [KEY_EJECTCLOSECD] = "EjectCloseCD",    [KEY_NEXTSONG] = "NextSong",
569         [KEY_PLAYPAUSE] = "PlayPause",          [KEY_PREVIOUSSONG] = "PreviousSong",
570         [KEY_STOPCD] = "StopCD",                [KEY_RECORD] = "Record",
571         [KEY_REWIND] = "Rewind",                [KEY_PHONE] = "Phone",
572         [KEY_ISO] = "ISOKey",                   [KEY_CONFIG] = "Config",
573         [KEY_HOMEPAGE] = "HomePage",            [KEY_REFRESH] = "Refresh",
574         [KEY_EXIT] = "Exit",                    [KEY_MOVE] = "Move",
575         [KEY_EDIT] = "Edit",                    [KEY_SCROLLUP] = "ScrollUp",
576         [KEY_SCROLLDOWN] = "ScrollDown",        [KEY_KPLEFTPAREN] = "KPLeftParenthesis",
577         [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13",
578         [KEY_F14] = "F14",                      [KEY_F15] = "F15",
579         [KEY_F16] = "F16",                      [KEY_F17] = "F17",
580         [KEY_F18] = "F18",                      [KEY_F19] = "F19",
581         [KEY_F20] = "F20",                      [KEY_F21] = "F21",
582         [KEY_F22] = "F22",                      [KEY_F23] = "F23",
583         [KEY_F24] = "F24",                      [KEY_PLAYCD] = "PlayCD",
584         [KEY_PAUSECD] = "PauseCD",              [KEY_PROG3] = "Prog3",
585         [KEY_PROG4] = "Prog4",                  [KEY_SUSPEND] = "Suspend",
586         [KEY_CLOSE] = "Close",                  [KEY_PLAY] = "Play",
587         [KEY_FASTFORWARD] = "Fast Forward",     [KEY_BASSBOOST] = "Bass Boost",
588         [KEY_PRINT] = "Print",                  [KEY_HP] = "HP",
589         [KEY_CAMERA] = "Camera",                [KEY_SOUND] = "Sound",
590         [KEY_QUESTION] = "Question",            [KEY_EMAIL] = "Email",
591         [KEY_CHAT] = "Chat",                    [KEY_SEARCH] = "Search",
592         [KEY_CONNECT] = "Connect",              [KEY_FINANCE] = "Finance",
593         [KEY_SPORT] = "Sport",                  [KEY_SHOP] = "Shop",
594         [KEY_ALTERASE] = "Alternate Erase",     [KEY_CANCEL] = "Cancel",
595         [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up",
596         [KEY_MEDIA] = "Media",                  [KEY_UNKNOWN] = "Unknown",
597         [BTN_0] = "Btn0",                       [BTN_1] = "Btn1",
598         [BTN_2] = "Btn2",                       [BTN_3] = "Btn3",
599         [BTN_4] = "Btn4",                       [BTN_5] = "Btn5",
600         [BTN_6] = "Btn6",                       [BTN_7] = "Btn7",
601         [BTN_8] = "Btn8",                       [BTN_9] = "Btn9",
602         [BTN_LEFT] = "LeftBtn",                 [BTN_RIGHT] = "RightBtn",
603         [BTN_MIDDLE] = "MiddleBtn",             [BTN_SIDE] = "SideBtn",
604         [BTN_EXTRA] = "ExtraBtn",               [BTN_FORWARD] = "ForwardBtn",
605         [BTN_BACK] = "BackBtn",                 [BTN_TASK] = "TaskBtn",
606         [BTN_TRIGGER] = "Trigger",              [BTN_THUMB] = "ThumbBtn",
607         [BTN_THUMB2] = "ThumbBtn2",             [BTN_TOP] = "TopBtn",
608         [BTN_TOP2] = "TopBtn2",                 [BTN_PINKIE] = "PinkieBtn",
609         [BTN_BASE] = "BaseBtn",                 [BTN_BASE2] = "BaseBtn2",
610         [BTN_BASE3] = "BaseBtn3",               [BTN_BASE4] = "BaseBtn4",
611         [BTN_BASE5] = "BaseBtn5",               [BTN_BASE6] = "BaseBtn6",
612         [BTN_DEAD] = "BtnDead",                 [BTN_A] = "BtnA",
613         [BTN_B] = "BtnB",                       [BTN_C] = "BtnC",
614         [BTN_X] = "BtnX",                       [BTN_Y] = "BtnY",
615         [BTN_Z] = "BtnZ",                       [BTN_TL] = "BtnTL",
616         [BTN_TR] = "BtnTR",                     [BTN_TL2] = "BtnTL2",
617         [BTN_TR2] = "BtnTR2",                   [BTN_SELECT] = "BtnSelect",
618         [BTN_START] = "BtnStart",               [BTN_MODE] = "BtnMode",
619         [BTN_THUMBL] = "BtnThumbL",             [BTN_THUMBR] = "BtnThumbR",
620         [BTN_TOOL_PEN] = "ToolPen",             [BTN_TOOL_RUBBER] = "ToolRubber",
621         [BTN_TOOL_BRUSH] = "ToolBrush",         [BTN_TOOL_PENCIL] = "ToolPencil",
622         [BTN_TOOL_AIRBRUSH] = "ToolAirbrush",   [BTN_TOOL_FINGER] = "ToolFinger",
623         [BTN_TOOL_MOUSE] = "ToolMouse",         [BTN_TOOL_LENS] = "ToolLens",
624         [BTN_TOUCH] = "Touch",                  [BTN_STYLUS] = "Stylus",
625         [BTN_STYLUS2] = "Stylus2",              [BTN_TOOL_DOUBLETAP] = "Tool Doubletap",
626         [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_GEAR_DOWN] = "WheelBtn",
627         [BTN_GEAR_UP] = "Gear up",              [KEY_OK] = "Ok",
628         [KEY_SELECT] = "Select",                [KEY_GOTO] = "Goto",
629         [KEY_CLEAR] = "Clear",                  [KEY_POWER2] = "Power2",
630         [KEY_OPTION] = "Option",                [KEY_INFO] = "Info",
631         [KEY_TIME] = "Time",                    [KEY_VENDOR] = "Vendor",
632         [KEY_ARCHIVE] = "Archive",              [KEY_PROGRAM] = "Program",
633         [KEY_CHANNEL] = "Channel",              [KEY_FAVORITES] = "Favorites",
634         [KEY_EPG] = "EPG",                      [KEY_PVR] = "PVR",
635         [KEY_MHP] = "MHP",                      [KEY_LANGUAGE] = "Language",
636         [KEY_TITLE] = "Title",                  [KEY_SUBTITLE] = "Subtitle",
637         [KEY_ANGLE] = "Angle",                  [KEY_ZOOM] = "Zoom",
638         [KEY_MODE] = "Mode",                    [KEY_KEYBOARD] = "Keyboard",
639         [KEY_SCREEN] = "Screen",                [KEY_PC] = "PC",
640         [KEY_TV] = "TV",                        [KEY_TV2] = "TV2",
641         [KEY_VCR] = "VCR",                      [KEY_VCR2] = "VCR2",
642         [KEY_SAT] = "Sat",                      [KEY_SAT2] = "Sat2",
643         [KEY_CD] = "CD",                        [KEY_TAPE] = "Tape",
644         [KEY_RADIO] = "Radio",                  [KEY_TUNER] = "Tuner",
645         [KEY_PLAYER] = "Player",                [KEY_TEXT] = "Text",
646         [KEY_DVD] = "DVD",                      [KEY_AUX] = "Aux",
647         [KEY_MP3] = "MP3",                      [KEY_AUDIO] = "Audio",
648         [KEY_VIDEO] = "Video",                  [KEY_DIRECTORY] = "Directory",
649         [KEY_LIST] = "List",                    [KEY_MEMO] = "Memo",
650         [KEY_CALENDAR] = "Calendar",            [KEY_RED] = "Red",
651         [KEY_GREEN] = "Green",                  [KEY_YELLOW] = "Yellow",
652         [KEY_BLUE] = "Blue",                    [KEY_CHANNELUP] = "ChannelUp",
653         [KEY_CHANNELDOWN] = "ChannelDown",      [KEY_FIRST] = "First",
654         [KEY_LAST] = "Last",                    [KEY_AB] = "AB",
655         [KEY_NEXT] = "Next",                    [KEY_RESTART] = "Restart",
656         [KEY_SLOW] = "Slow",                    [KEY_SHUFFLE] = "Shuffle",
657         [KEY_BREAK] = "Break",                  [KEY_PREVIOUS] = "Previous",
658         [KEY_DIGITS] = "Digits",                [KEY_TEEN] = "TEEN",
659         [KEY_TWEN] = "TWEN",                    [KEY_DEL_EOL] = "DeleteEOL",
660         [KEY_DEL_EOS] = "DeleteEOS",            [KEY_INS_LINE] = "InsertLine",
661         [KEY_DEL_LINE] = "DeleteLine",
662 };
663
664 static char *relatives[REL_MAX + 1] = {
665         [REL_X] = "X",                  [REL_Y] = "Y",
666         [REL_Z] = "Z",                  [REL_HWHEEL] = "HWheel",
667         [REL_DIAL] = "Dial",            [REL_WHEEL] = "Wheel", 
668         [REL_MISC] = "Misc",    
669 };
670
671 static char *absolutes[ABS_MAX + 1] = {
672         [ABS_X] = "X",                  [ABS_Y] = "Y",
673         [ABS_Z] = "Z",                  [ABS_RX] = "Rx",
674         [ABS_RY] = "Ry",                [ABS_RZ] = "Rz",
675         [ABS_THROTTLE] = "Throttle",    [ABS_RUDDER] = "Rudder",
676         [ABS_WHEEL] = "Wheel",          [ABS_GAS] = "Gas",
677         [ABS_BRAKE] = "Brake",          [ABS_HAT0X] = "Hat0X",
678         [ABS_HAT0Y] = "Hat0Y",          [ABS_HAT1X] = "Hat1X",
679         [ABS_HAT1Y] = "Hat1Y",          [ABS_HAT2X] = "Hat2X",
680         [ABS_HAT2Y] = "Hat2Y",          [ABS_HAT3X] = "Hat3X",
681         [ABS_HAT3Y] = "Hat 3Y",         [ABS_PRESSURE] = "Pressure",
682         [ABS_DISTANCE] = "Distance",    [ABS_TILT_X] = "XTilt",
683         [ABS_TILT_Y] = "YTilt",         [ABS_TOOL_WIDTH] = "Tool Width",
684         [ABS_VOLUME] = "Volume",        [ABS_MISC] = "Misc",
685 };
686
687 static char *misc[MSC_MAX + 1] = {
688         [MSC_SERIAL] = "Serial",        [MSC_PULSELED] = "Pulseled",
689         [MSC_GESTURE] = "Gesture",      [MSC_RAW] = "RawData"
690 };
691
692 static char *leds[LED_MAX + 1] = {
693         [LED_NUML] = "NumLock",         [LED_CAPSL] = "CapsLock", 
694         [LED_SCROLLL] = "ScrollLock",   [LED_COMPOSE] = "Compose",
695         [LED_KANA] = "Kana",            [LED_SLEEP] = "Sleep", 
696         [LED_SUSPEND] = "Suspend",      [LED_MUTE] = "Mute",
697         [LED_MISC] = "Misc",
698 };
699
700 static char *repeats[REP_MAX + 1] = {
701         [REP_DELAY] = "Delay",          [REP_PERIOD] = "Period"
702 };
703
704 static char *sounds[SND_MAX + 1] = {
705         [SND_CLICK] = "Click",          [SND_BELL] = "Bell",
706         [SND_TONE] = "Tone"
707 };
708
709 static char **names[EV_MAX + 1] = {
710         [EV_SYN] = syncs,                       [EV_KEY] = keys,
711         [EV_REL] = relatives,                   [EV_ABS] = absolutes,
712         [EV_MSC] = misc,                        [EV_LED] = leds,
713         [EV_SND] = sounds,                      [EV_REP] = repeats,
714 };
715
716 static void __attribute__((unused)) resolv_event(__u8 type, __u16 code) {
717
718         printk("%s.%s", events[type] ? events[type] : "?",
719                 names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
720 }