-
Notifications
You must be signed in to change notification settings - Fork 49
/
event.c
2372 lines (2262 loc) · 46.1 KB
/
event.c
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the Advance project.
*
* Copyright (C) 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* In addition, as a special exception, Andrea Mazzoleni
* gives permission to link the code of this program with
* the MAME library (or with modified versions of MAME that use the
* same license as MAME), and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
* respects for all of the code used other than MAME. If you modify
* this file, you may extend this exception to your version of the
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*/
#include "portable.h"
#include "event.h"
#include "log.h"
#include <linux/input.h>
#ifndef BTN_PLAY
#define BTN_PLAY 0x13f /* missing in kernel 4.19 but used by joystick */
#endif
#ifdef EV_SYN
static void event_syn_log(int f)
{
unsigned char msc_bitmask[SYN_MAX / 8 + 1];
unsigned i;
memset(msc_bitmask, 0, sizeof(msc_bitmask));
if (ioctl(f, EVIOCGBIT(EV_SYN, sizeof(msc_bitmask)), msc_bitmask) < 0) {
log_std(("event: error in ioctl(EVIOCGBIT(EV_SYN,%d))\n", (int)SYN_MAX));
return;
}
log_std(("event: EV_SYN:"));
for (i = 0; i < SYN_MAX; ++i) {
if (event_test_bit(i, msc_bitmask)) {
const char* desc;
switch (i) {
#ifdef SYN_REPORT
case SYN_REPORT: desc = "SYN_REPORT"; break;
#endif
#ifdef SYN_CONFIG
case SYN_CONFIG: desc = "SYN_CONFIG"; break;
#endif
#ifdef SYN_MT_REPORT
case SYN_MT_REPORT: desc = "SYN_MT_REPORT"; break;
#endif
#ifdef SYN_DROPPED
case SYN_DROPPED: desc = "SYN_DROPPED"; break;
#endif
default: desc = 0; break;
}
if (desc)
log_std((" %s", desc));
else
log_std((" 0x%x", i));
}
}
log_std(("\n"));
}
#endif
static void event_key_log(int f)
{
unsigned char key_bitmask[KEY_MAX / 8 + 1];
unsigned i;
unsigned count;
memset(key_bitmask, 0, sizeof(key_bitmask));
if (ioctl(f, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask) < 0) {
log_std(("event: error in ioctl(EVIOCGBIT(EV_KEY,%d))\n", (int)KEY_MAX));
return;
}
log_std(("event: EV_KEY:"));
count = 0;
for (i = 0; i < KEY_MAX; ++i) {
if (event_test_bit(i, key_bitmask)) {
const char* desc;
++count;
switch (i) {
#ifdef KEY_ESC
case KEY_ESC: desc = "KEY_ESC"; break;
#endif
#ifdef KEY_1
case KEY_1: desc = "KEY_1"; break;
#endif
#ifdef KEY_2
case KEY_2: desc = "KEY_2"; break;
#endif
#ifdef KEY_3
case KEY_3: desc = "KEY_3"; break;
#endif
#ifdef KEY_4
case KEY_4: desc = "KEY_4"; break;
#endif
#ifdef KEY_5
case KEY_5: desc = "KEY_5"; break;
#endif
#ifdef KEY_6
case KEY_6: desc = "KEY_6"; break;
#endif
#ifdef KEY_7
case KEY_7: desc = "KEY_7"; break;
#endif
#ifdef KEY_8
case KEY_8: desc = "KEY_8"; break;
#endif
#ifdef KEY_9
case KEY_9: desc = "KEY_9"; break;
#endif
#ifdef KEY_0
case KEY_0: desc = "KEY_0"; break;
#endif
#ifdef KEY_MINUS
case KEY_MINUS: desc = "KEY_MINUS"; break;
#endif
#ifdef KEY_EQUAL
case KEY_EQUAL: desc = "KEY_EQUAL"; break;
#endif
#ifdef KEY_BACKSPACE
case KEY_BACKSPACE: desc = "KEY_BACKSPACE"; break;
#endif
#ifdef KEY_TAB
case KEY_TAB: desc = "KEY_TAB"; break;
#endif
#ifdef KEY_Q
case KEY_Q: desc = "KEY_Q"; break;
#endif
#ifdef KEY_W
case KEY_W: desc = "KEY_W"; break;
#endif
#ifdef KEY_E
case KEY_E: desc = "KEY_E"; break;
#endif
#ifdef KEY_R
case KEY_R: desc = "KEY_R"; break;
#endif
#ifdef KEY_T
case KEY_T: desc = "KEY_T"; break;
#endif
#ifdef KEY_Y
case KEY_Y: desc = "KEY_Y"; break;
#endif
#ifdef KEY_U
case KEY_U: desc = "KEY_U"; break;
#endif
#ifdef KEY_I
case KEY_I: desc = "KEY_I"; break;
#endif
#ifdef KEY_O
case KEY_O: desc = "KEY_O"; break;
#endif
#ifdef KEY_P
case KEY_P: desc = "KEY_P"; break;
#endif
#ifdef KEY_LEFTBRACE
case KEY_LEFTBRACE: desc = "KEY_LEFTBRACE"; break;
#endif
#ifdef KEY_RIGHTBRACE
case KEY_RIGHTBRACE: desc = "KEY_RIGHTBRACE"; break;
#endif
#ifdef KEY_ENTER
case KEY_ENTER: desc = "KEY_ENTER"; break;
#endif
#ifdef KEY_LEFTCTRL
case KEY_LEFTCTRL: desc = "KEY_LEFTCTRL"; break;
#endif
#ifdef KEY_A
case KEY_A: desc = "KEY_A"; break;
#endif
#ifdef KEY_S
case KEY_S: desc = "KEY_S"; break;
#endif
#ifdef KEY_D
case KEY_D: desc = "KEY_D"; break;
#endif
#ifdef KEY_F
case KEY_F: desc = "KEY_F"; break;
#endif
#ifdef KEY_G
case KEY_G: desc = "KEY_G"; break;
#endif
#ifdef KEY_H
case KEY_H: desc = "KEY_H"; break;
#endif
#ifdef KEY_J
case KEY_J: desc = "KEY_J"; break;
#endif
#ifdef KEY_K
case KEY_K: desc = "KEY_K"; break;
#endif
#ifdef KEY_L
case KEY_L: desc = "KEY_L"; break;
#endif
#ifdef KEY_SEMICOLON
case KEY_SEMICOLON: desc = "KEY_SEMICOLON"; break;
#endif
#ifdef KEY_APOSTROPHE
case KEY_APOSTROPHE: desc = "KEY_APOSTROPHE"; break;
#endif
#ifdef KEY_GRAVE
case KEY_GRAVE: desc = "KEY_GRAVE"; break;
#endif
#ifdef KEY_LEFTSHIFT
case KEY_LEFTSHIFT: desc = "KEY_LEFTSHIFT"; break;
#endif
#ifdef KEY_BACKSLASH
case KEY_BACKSLASH: desc = "KEY_BACKSLASH"; break;
#endif
#ifdef KEY_Z
case KEY_Z: desc = "KEY_Z"; break;
#endif
#ifdef KEY_X
case KEY_X: desc = "KEY_X"; break;
#endif
#ifdef KEY_C
case KEY_C: desc = "KEY_C"; break;
#endif
#ifdef KEY_V
case KEY_V: desc = "KEY_V"; break;
#endif
#ifdef KEY_B
case KEY_B: desc = "KEY_B"; break;
#endif
#ifdef KEY_N
case KEY_N: desc = "KEY_N"; break;
#endif
#ifdef KEY_M
case KEY_M: desc = "KEY_M"; break;
#endif
#ifdef KEY_COMMA
case KEY_COMMA: desc = "KEY_COMMA"; break;
#endif
#ifdef KEY_DOT
case KEY_DOT: desc = "KEY_DOT"; break;
#endif
#ifdef KEY_SLASH
case KEY_SLASH: desc = "KEY_SLASH"; break;
#endif
#ifdef KEY_RIGHTSHIFT
case KEY_RIGHTSHIFT: desc = "KEY_RIGHTSHIFT"; break;
#endif
#ifdef KEY_KPASTERISK
case KEY_KPASTERISK: desc = "KEY_KPASTERISK"; break;
#endif
#ifdef KEY_LEFTALT
case KEY_LEFTALT: desc = "KEY_LEFTALT"; break;
#endif
#ifdef KEY_SPACE
case KEY_SPACE: desc = "KEY_SPACE"; break;
#endif
#ifdef KEY_CAPSLOCK
case KEY_CAPSLOCK: desc = "KEY_CAPSLOCK"; break;
#endif
#ifdef KEY_F1
case KEY_F1: desc = "KEY_F1"; break;
#endif
#ifdef KEY_F2
case KEY_F2: desc = "KEY_F2"; break;
#endif
#ifdef KEY_F3
case KEY_F3: desc = "KEY_F3"; break;
#endif
#ifdef KEY_F4
case KEY_F4: desc = "KEY_F4"; break;
#endif
#ifdef KEY_F5
case KEY_F5: desc = "KEY_F5"; break;
#endif
#ifdef KEY_F6
case KEY_F6: desc = "KEY_F6"; break;
#endif
#ifdef KEY_F7
case KEY_F7: desc = "KEY_F7"; break;
#endif
#ifdef KEY_F8
case KEY_F8: desc = "KEY_F8"; break;
#endif
#ifdef KEY_F9
case KEY_F9: desc = "KEY_F9"; break;
#endif
#ifdef KEY_F10
case KEY_F10: desc = "KEY_F10"; break;
#endif
#ifdef KEY_NUMLOCK
case KEY_NUMLOCK: desc = "KEY_NUMLOCK"; break;
#endif
#ifdef KEY_SCROLLLOCK
case KEY_SCROLLLOCK: desc = "KEY_SCROLLLOCK"; break;
#endif
#ifdef KEY_KP7
case KEY_KP7: desc = "KEY_KP7"; break;
#endif
#ifdef KEY_KP8
case KEY_KP8: desc = "KEY_KP8"; break;
#endif
#ifdef KEY_KP9
case KEY_KP9: desc = "KEY_KP9"; break;
#endif
#ifdef KEY_KPMINUS
case KEY_KPMINUS: desc = "KEY_KPMINUS"; break;
#endif
#ifdef KEY_KP4
case KEY_KP4: desc = "KEY_KP4"; break;
#endif
#ifdef KEY_KP5
case KEY_KP5: desc = "KEY_KP5"; break;
#endif
#ifdef KEY_KP6
case KEY_KP6: desc = "KEY_KP6"; break;
#endif
#ifdef KEY_KPPLUS
case KEY_KPPLUS: desc = "KEY_KPPLUS"; break;
#endif
#ifdef KEY_KP1
case KEY_KP1: desc = "KEY_KP1"; break;
#endif
#ifdef KEY_KP2
case KEY_KP2: desc = "KEY_KP2"; break;
#endif
#ifdef KEY_KP3
case KEY_KP3: desc = "KEY_KP3"; break;
#endif
#ifdef KEY_KP0
case KEY_KP0: desc = "KEY_KP0"; break;
#endif
#ifdef KEY_KPDOT
case KEY_KPDOT: desc = "KEY_KPDOT"; break;
#endif
#ifdef KEY_103RD
case KEY_103RD: desc = "KEY_103RD"; break;
#endif
#ifdef KEY_F13
case KEY_F13: desc = "KEY_F13"; break;
#endif
#ifdef KEY_102ND
case KEY_102ND: desc = "KEY_102ND"; break;
#endif
#ifdef KEY_F11
case KEY_F11: desc = "KEY_F11"; break;
#endif
#ifdef KEY_F12
case KEY_F12: desc = "KEY_F12"; break;
#endif
#ifdef KEY_F14
case KEY_F14: desc = "KEY_F14"; break;
#endif
#ifdef KEY_F15
case KEY_F15: desc = "KEY_F15"; break;
#endif
#ifdef KEY_F16
case KEY_F16: desc = "KEY_F16"; break;
#endif
#ifdef KEY_F17
case KEY_F17: desc = "KEY_F17"; break;
#endif
#ifdef KEY_F18
case KEY_F18: desc = "KEY_F18"; break;
#endif
#ifdef KEY_F19
case KEY_F19: desc = "KEY_F19"; break;
#endif
#ifdef KEY_F20
case KEY_F20: desc = "KEY_F20"; break;
#endif
#ifdef KEY_KPENTER
case KEY_KPENTER: desc = "KEY_KPENTER"; break;
#endif
#ifdef KEY_RIGHTCTRL
case KEY_RIGHTCTRL: desc = "KEY_RIGHTCTRL"; break;
#endif
#ifdef KEY_KPSLASH
case KEY_KPSLASH: desc = "KEY_KPSLASH"; break;
#endif
#ifdef KEY_SYSRQ
case KEY_SYSRQ: desc = "KEY_SYSRQ"; break;
#endif
#ifdef KEY_RIGHTALT
case KEY_RIGHTALT: desc = "KEY_RIGHTALT"; break;
#endif
#ifdef KEY_LINEFEED
case KEY_LINEFEED: desc = "KEY_LINEFEED"; break;
#endif
#ifdef KEY_HOME
case KEY_HOME: desc = "KEY_HOME"; break;
#endif
#ifdef KEY_UP
case KEY_UP: desc = "KEY_UP"; break;
#endif
#ifdef KEY_PAGEUP
case KEY_PAGEUP: desc = "KEY_PAGEUP"; break;
#endif
#ifdef KEY_LEFT
case KEY_LEFT: desc = "KEY_LEFT"; break;
#endif
#ifdef KEY_RIGHT
case KEY_RIGHT: desc = "KEY_RIGHT"; break;
#endif
#ifdef KEY_END
case KEY_END: desc = "KEY_END"; break;
#endif
#ifdef KEY_DOWN
case KEY_DOWN: desc = "KEY_DOWN"; break;
#endif
#ifdef KEY_PAGEDOWN
case KEY_PAGEDOWN: desc = "KEY_PAGEDOWN"; break;
#endif
#ifdef KEY_INSERT
case KEY_INSERT: desc = "KEY_INSERT"; break;
#endif
#ifdef KEY_DELETE
case KEY_DELETE: desc = "KEY_DELETE"; break;
#endif
#ifdef KEY_MACRO
case KEY_MACRO: desc = "KEY_MACRO"; break;
#endif
#ifdef KEY_MUTE
case KEY_MUTE: desc = "KEY_MUTE"; break;
#endif
#ifdef KEY_VOLUMEDOWN
case KEY_VOLUMEDOWN: desc = "KEY_VOLUMEDOWN"; break;
#endif
#ifdef KEY_VOLUMEUP
case KEY_VOLUMEUP: desc = "KEY_VOLUMEUP"; break;
#endif
#ifdef KEY_POWER
case KEY_POWER: desc = "KEY_POWER"; break;
#endif
#ifdef KEY_KPEQUAL
case KEY_KPEQUAL: desc = "KEY_KPEQUAL"; break;
#endif
#ifdef KEY_KPPLUSMINUS
case KEY_KPPLUSMINUS: desc = "KEY_KPPLUSMINUS"; break;
#endif
#ifdef KEY_PAUSE
case KEY_PAUSE: desc = "KEY_PAUSE"; break;
#endif
#ifdef KEY_F21
case KEY_F21: desc = "KEY_F21"; break;
#endif
#ifdef KEY_F22
case KEY_F22: desc = "KEY_F22"; break;
#endif
#ifdef KEY_F23
case KEY_F23: desc = "KEY_F23"; break;
#endif
#ifdef KEY_F24
case KEY_F24: desc = "KEY_F24"; break;
#endif
#ifdef KEY_KPCOMMA
case KEY_KPCOMMA: desc = "KEY_KPCOMMA"; break;
#endif
#ifdef KEY_LEFTMETA
case KEY_LEFTMETA: desc = "KEY_LEFTMETA"; break;
#endif
#ifdef KEY_RIGHTMETA
case KEY_RIGHTMETA: desc = "KEY_RIGHTMETA"; break;
#endif
#ifdef KEY_COMPOSE
case KEY_COMPOSE: desc = "KEY_COMPOSE"; break;
#endif
#ifdef KEY_STOP
case KEY_STOP: desc = "KEY_STOP"; break;
#endif
#ifdef KEY_AGAIN
case KEY_AGAIN: desc = "KEY_AGAIN"; break;
#endif
#ifdef KEY_PROPS
case KEY_PROPS: desc = "KEY_PROPS"; break;
#endif
#ifdef KEY_UNDO
case KEY_UNDO: desc = "KEY_UNDO"; break;
#endif
#ifdef KEY_FRONT
case KEY_FRONT: desc = "KEY_FRONT"; break;
#endif
#ifdef KEY_COPY
case KEY_COPY: desc = "KEY_COPY"; break;
#endif
#ifdef KEY_OPEN
case KEY_OPEN: desc = "KEY_OPEN"; break;
#endif
#ifdef KEY_PASTE
case KEY_PASTE: desc = "KEY_PASTE"; break;
#endif
#ifdef KEY_FIND
case KEY_FIND: desc = "KEY_FIND"; break;
#endif
#ifdef KEY_CUT
case KEY_CUT: desc = "KEY_CUT"; break;
#endif
#ifdef KEY_HELP
case KEY_HELP: desc = "KEY_HELP"; break;
#endif
#ifdef KEY_MENU
case KEY_MENU: desc = "KEY_MENU"; break;
#endif
#ifdef KEY_CALC
case KEY_CALC: desc = "KEY_CALC"; break;
#endif
#ifdef KEY_SETUP
case KEY_SETUP: desc = "KEY_SETUP"; break;
#endif
#ifdef KEY_SLEEP
case KEY_SLEEP: desc = "KEY_SLEEP"; break;
#endif
#ifdef KEY_WAKEUP
case KEY_WAKEUP: desc = "KEY_WAKEUP"; break;
#endif
#ifdef KEY_FILE
case KEY_FILE: desc = "KEY_FILE"; break;
#endif
#ifdef KEY_SENDFILE
case KEY_SENDFILE: desc = "KEY_SENDFILE"; break;
#endif
#ifdef KEY_DELETEFILE
case KEY_DELETEFILE: desc = "KEY_DELETEFILE"; break;
#endif
#ifdef KEY_XFER
case KEY_XFER: desc = "KEY_XFER"; break;
#endif
#ifdef KEY_PROG1
case KEY_PROG1: desc = "KEY_PROG1"; break;
#endif
#ifdef KEY_PROG2
case KEY_PROG2: desc = "KEY_PROG2"; break;
#endif
#ifdef KEY_WWW
case KEY_WWW: desc = "KEY_WWW"; break;
#endif
#ifdef KEY_MSDOS
case KEY_MSDOS: desc = "KEY_MSDOS"; break;
#endif
#ifdef KEY_COFFEE
case KEY_COFFEE: desc = "KEY_COFFEE"; break;
#endif
#ifdef KEY_DIRECTION
case KEY_DIRECTION: desc = "KEY_DIRECTION"; break;
#endif
#ifdef KEY_CYCLEWINDOWS
case KEY_CYCLEWINDOWS: desc = "KEY_CYCLEWINDOWS"; break;
#endif
#ifdef KEY_MAIL
case KEY_MAIL: desc = "KEY_MAIL"; break;
#endif
#ifdef KEY_BOOKMARKS
case KEY_BOOKMARKS: desc = "KEY_BOOKMARKS"; break;
#endif
#ifdef KEY_COMPUTER
case KEY_COMPUTER: desc = "KEY_COMPUTER"; break;
#endif
#ifdef KEY_BACK
case KEY_BACK: desc = "KEY_BACK"; break;
#endif
#ifdef KEY_FORWARD
case KEY_FORWARD: desc = "KEY_FORWARD"; break;
#endif
#ifdef KEY_CLOSECD
case KEY_CLOSECD: desc = "KEY_CLOSECD"; break;
#endif
#ifdef KEY_EJECTCD
case KEY_EJECTCD: desc = "KEY_EJECTCD"; break;
#endif
#ifdef KEY_EJECTCLOSECD
case KEY_EJECTCLOSECD: desc = "KEY_EJECTCLOSECD"; break;
#endif
#ifdef KEY_NEXTSONG
case KEY_NEXTSONG: desc = "KEY_NEXTSONG"; break;
#endif
#ifdef KEY_PLAYPAUSE
case KEY_PLAYPAUSE: desc = "KEY_PLAYPAUSE"; break;
#endif
#ifdef KEY_PREVIOUSSONG
case KEY_PREVIOUSSONG: desc = "KEY_PREVIOUSSONG"; break;
#endif
#ifdef KEY_STOPCD
case KEY_STOPCD: desc = "KEY_STOPCD"; break;
#endif
#ifdef KEY_RECORD
case KEY_RECORD: desc = "KEY_RECORD"; break;
#endif
#ifdef KEY_REWIND
case KEY_REWIND: desc = "KEY_REWIND"; break;
#endif
#ifdef KEY_PHONE
case KEY_PHONE: desc = "KEY_PHONE"; break;
#endif
#ifdef KEY_ISO
case KEY_ISO: desc = "KEY_ISO"; break;
#endif
#ifdef KEY_CONFIG
case KEY_CONFIG: desc = "KEY_CONFIG"; break;
#endif
#ifdef KEY_HOMEPAGE
case KEY_HOMEPAGE: desc = "KEY_HOMEPAGE"; break;
#endif
#ifdef KEY_REFRESH
case KEY_REFRESH: desc = "KEY_REFRESH"; break;
#endif
#ifdef KEY_EXIT
case KEY_EXIT: desc = "KEY_EXIT"; break;
#endif
#ifdef KEY_MOVE
case KEY_MOVE: desc = "KEY_MOVE"; break;
#endif
#ifdef KEY_EDIT
case KEY_EDIT: desc = "KEY_EDIT"; break;
#endif
#ifdef KEY_SCROLLUP
case KEY_SCROLLUP: desc = "KEY_SCROLLUP"; break;
#endif
#ifdef KEY_SCROLLDOWN
case KEY_SCROLLDOWN: desc = "KEY_SCROLLDOWN"; break;
#endif
#ifdef KEY_KPLEFTPAREN
case KEY_KPLEFTPAREN: desc = "KEY_KPLEFTPAREN"; break;
#endif
#ifdef KEY_KPRIGHTPAREN
case KEY_KPRIGHTPAREN: desc = "KEY_KPRIGHTPAREN"; break;
#endif
#ifdef KEY_INTL1
case KEY_INTL1: desc = "KEY_INTL1"; break;
#endif
#ifdef KEY_INTL2
case KEY_INTL2: desc = "KEY_INTL2"; break;
#endif
#ifdef KEY_INTL3
case KEY_INTL3: desc = "KEY_INTL3"; break;
#endif
#ifdef KEY_INTL4
case KEY_INTL4: desc = "KEY_INTL4"; break;
#endif
#ifdef KEY_INTL5
case KEY_INTL5: desc = "KEY_INTL5"; break;
#endif
#ifdef KEY_INTL6
case KEY_INTL6: desc = "KEY_INTL6"; break;
#endif
#ifdef KEY_INTL7
case KEY_INTL7: desc = "KEY_INTL7"; break;
#endif
#ifdef KEY_INTL8
case KEY_INTL8: desc = "KEY_INTL8"; break;
#endif
#ifdef KEY_INTL9
case KEY_INTL9: desc = "KEY_INTL9"; break;
#endif
#ifdef KEY_LANG1
case KEY_LANG1: desc = "KEY_LANG1"; break;
#endif
#ifdef KEY_LANG2
case KEY_LANG2: desc = "KEY_LANG2"; break;
#endif
#ifdef KEY_LANG3
case KEY_LANG3: desc = "KEY_LANG3"; break;
#endif
#ifdef KEY_LANG4
case KEY_LANG4: desc = "KEY_LANG4"; break;
#endif
#ifdef KEY_LANG5
case KEY_LANG5: desc = "KEY_LANG5"; break;
#endif
#ifdef KEY_LANG6
case KEY_LANG6: desc = "KEY_LANG6"; break;
#endif
#ifdef KEY_LANG7
case KEY_LANG7: desc = "KEY_LANG7"; break;
#endif
#ifdef KEY_LANG8
case KEY_LANG8: desc = "KEY_LANG8"; break;
#endif
#ifdef KEY_LANG9
case KEY_LANG9: desc = "KEY_LANG9"; break;
#endif
#ifdef KEY_PLAYCD
case KEY_PLAYCD: desc = "KEY_PLAYCD"; break;
#endif
#ifdef KEY_PAUSECD
case KEY_PAUSECD: desc = "KEY_PAUSECD"; break;
#endif
#ifdef KEY_PROG3
case KEY_PROG3: desc = "KEY_PROG3"; break;
#endif
#ifdef KEY_PROG4
case KEY_PROG4: desc = "KEY_PROG4"; break;
#endif
#ifdef KEY_SUSPEND
case KEY_SUSPEND: desc = "KEY_SUSPEND"; break;
#endif
#ifdef KEY_CLOSE
case KEY_CLOSE: desc = "KEY_CLOSE"; break;
#endif
#ifdef KEY_UNKNOWN
case KEY_UNKNOWN: desc = "KEY_UNKNOWN"; break;
#endif
#ifdef KEY_BRIGHTNESSDOWN
case KEY_BRIGHTNESSDOWN: desc = "KEY_BRIGHTNESSDOWN"; break;
#endif
#ifdef KEY_BRIGHTNESSUP
case KEY_BRIGHTNESSUP: desc = "KEY_BRIGHTNESSUP"; break;
#endif
#ifdef BTN_0
case BTN_0: desc = "BTN_0"; break;
#endif
#ifdef BTN_1
case BTN_1: desc = "BTN_1"; break;
#endif
#ifdef BTN_2
case BTN_2: desc = "BTN_2"; break;
#endif
#ifdef BTN_3
case BTN_3: desc = "BTN_3"; break;
#endif
#ifdef BTN_4
case BTN_4: desc = "BTN_4"; break;
#endif
#ifdef BTN_5
case BTN_5: desc = "BTN_5"; break;
#endif
#ifdef BTN_6
case BTN_6: desc = "BTN_6"; break;
#endif
#ifdef BTN_7
case BTN_7: desc = "BTN_7"; break;
#endif
#ifdef BTN_8
case BTN_8: desc = "BTN_8"; break;
#endif
#ifdef BTN_9
case BTN_9: desc = "BTN_9"; break;
#endif
#ifdef BTN_LEFT
case BTN_LEFT: desc = "BTN_LEFT"; break;
#endif
#ifdef BTN_RIGHT
case BTN_RIGHT: desc = "BTN_RIGHT"; break;
#endif
#ifdef BTN_MIDDLE
case BTN_MIDDLE: desc = "BTN_MIDDLE"; break;
#endif
#ifdef BTN_SIDE
case BTN_SIDE: desc = "BTN_SIDE"; break;
#endif
#ifdef BTN_EXTRA
case BTN_EXTRA: desc = "BTN_EXTRA"; break;
#endif
#ifdef BTN_FORWARD
case BTN_FORWARD: desc = "BTN_FORWARD"; break;
#endif
#ifdef BTN_BACK
case BTN_BACK: desc = "BTN_BACK"; break;
#endif
#ifdef BTN_TRIGGER
case BTN_TRIGGER: desc = "BTN_TRIGGER"; break;
#endif
#ifdef BTN_THUMB
case BTN_THUMB: desc = "BTN_THUMB"; break;
#endif
#ifdef BTN_THUMB2
case BTN_THUMB2: desc = "BTN_THUMB2"; break;
#endif
#ifdef BTN_TOP
case BTN_TOP: desc = "BTN_TOP"; break;
#endif
#ifdef BTN_TOP2
case BTN_TOP2: desc = "BTN_TOP2"; break;
#endif
#ifdef BTN_PINKIE
case BTN_PINKIE: desc = "BTN_PINKIE"; break;
#endif
#ifdef BTN_BASE
case BTN_BASE: desc = "BTN_BASE"; break;
#endif
#ifdef BTN_BASE2
case BTN_BASE2: desc = "BTN_BASE2"; break;
#endif
#ifdef BTN_BASE3
case BTN_BASE3: desc = "BTN_BASE3"; break;
#endif
#ifdef BTN_BASE4
case BTN_BASE4: desc = "BTN_BASE4"; break;
#endif
#ifdef BTN_BASE5
case BTN_BASE5: desc = "BTN_BASE5"; break;
#endif
#ifdef BTN_BASE6
case BTN_BASE6: desc = "BTN_BASE6"; break;
#endif
#ifdef BTN_DEAD
case BTN_DEAD: desc = "BTN_DEAD"; break;
#endif
#ifdef BTN_A
case BTN_A: desc = "BTN_A"; break;
#endif
#ifdef BTN_B
case BTN_B: desc = "BTN_B"; break;
#endif
#ifdef BTN_C
case BTN_C: desc = "BTN_C"; break;
#endif
#ifdef BTN_X
case BTN_X: desc = "BTN_X"; break;
#endif
#ifdef BTN_Y
case BTN_Y: desc = "BTN_Y"; break;
#endif
#ifdef BTN_Z
case BTN_Z: desc = "BTN_Z"; break;
#endif
#ifdef BTN_TL
case BTN_TL: desc = "BTN_TL"; break;
#endif
#ifdef BTN_TR
case BTN_TR: desc = "BTN_TR"; break;
#endif
#ifdef BTN_TL2
case BTN_TL2: desc = "BTN_TL2"; break;
#endif
#ifdef BTN_TR2
case BTN_TR2: desc = "BTN_TR2"; break;
#endif
#ifdef BTN_SELECT
case BTN_SELECT: desc = "BTN_SELECT"; break;
#endif
#ifdef BTN_START
case BTN_START: desc = "BTN_START"; break;
#endif
#ifdef BTN_MODE
case BTN_MODE: desc = "BTN_MODE"; break;
#endif
#ifdef BTN_THUMBL
case BTN_THUMBL: desc = "BTN_THUMBL"; break;
#endif
#ifdef BTN_THUMBR
case BTN_THUMBR: desc = "BTN_THUMBR"; break;
#endif
#ifdef BTN_PLAY
case BTN_PLAY: desc = "BTN_PLAY"; break;
#endif
#ifdef BTN_TOOL_PEN
case BTN_TOOL_PEN: desc = "BTN_TOOL_PEN"; break;
#endif
#ifdef BTN_TOOL_RUBBER
case BTN_TOOL_RUBBER: desc = "BTN_TOOL_RUBBER"; break;
#endif
#ifdef BTN_TOOL_BRUSH
case BTN_TOOL_BRUSH: desc = "BTN_TOOL_BRUSH"; break;
#endif
#ifdef BTN_TOOL_PENCIL
case BTN_TOOL_PENCIL: desc = "BTN_TOOL_PENCIL"; break;
#endif
#ifdef BTN_TOOL_AIRBRUSH
case BTN_TOOL_AIRBRUSH: desc = "BTN_TOOL_AIRBRUSH"; break;
#endif
#ifdef BTN_TOOL_FINGER
case BTN_TOOL_FINGER: desc = "BTN_TOOL_FINGER"; break;
#endif
#ifdef BTN_TOOL_MOUSE
case BTN_TOOL_MOUSE: desc = "BTN_TOOL_MOUSE"; break;
#endif
#ifdef BTN_TOOL_LENS
case BTN_TOOL_LENS: desc = "BTN_TOOL_LENS"; break;
#endif
#ifdef BTN_TOUCH
case BTN_TOUCH: desc = "BTN_TOUCH"; break;
#endif
#ifdef BTN_STYLUS
case BTN_STYLUS: desc = "BTN_STYLUS"; break;
#endif
#ifdef BTN_STYLUS2
case BTN_STYLUS2: desc = "BTN_STYLUS2"; break;
#endif
default: desc = 0; break;
}
if (desc)
log_std((" %s", desc));
else
log_std((" 0x%x", i));
}
}
log_std((" [%u]\n", count));
}
static void event_rel_log(int f)
{
unsigned char rel_bitmask[REL_MAX / 8 + 1];
unsigned i;
memset(rel_bitmask, 0, sizeof(rel_bitmask));
if (ioctl(f, EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask) < 0) {
log_std(("event: error in ioctl(EVIOCGBIT(EV_REL,%d))\n", (int)REL_MAX));
return;
}
log_std(("event: EV_REL:"));
for (i = 0; i < REL_MAX; ++i) {
if (event_test_bit(i, rel_bitmask)) {
const char* desc;
switch (i) {
#ifdef REL_X
case REL_X: desc = "REL_X"; break;
#endif
#ifdef REL_Y
case REL_Y: desc = "REL_Y"; break;
#endif
#ifdef REL_Z
case REL_Z: desc = "REL_Z"; break;
#endif
#ifdef REL_HWHEEL
case REL_HWHEEL: desc = "REL_HWHEEL"; break;
#endif
#ifdef REL_DIAL
case REL_DIAL: desc = "REL_DIAL"; break;
#endif
#ifdef REL_WHEEL
case REL_WHEEL: desc = "REL_WHEEL"; break;
#endif
#ifdef REL_MISC
case REL_MISC: desc = "REL_MISC"; break;
#endif
default: desc = 0; break;
}
if (desc)
log_std((" %s", desc));
else
log_std((" 0x%x", i));
}
}
log_std(("\n"));
}
static void event_abs_log(int f)
{
unsigned char abs_bitmask[ABS_MAX / 8 + 1];
unsigned i;
memset(abs_bitmask, 0, sizeof(abs_bitmask));
if (ioctl(f, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) < 0) {
log_std(("event: error in ioctl(EVIOCGBIT(EV_ABS,%d))\n", (int)ABS_MAX));
return;
}
log_std(("event: EV_ABS:"));
for (i = 0; i < ABS_MAX; ++i) {
if (event_test_bit(i, abs_bitmask)) {
const char* desc;
int features[5];
switch (i) {
#ifdef ABS_X
case ABS_X: desc = "ABS_X"; break;
#endif
#ifdef ABS_Y
case ABS_Y: desc = "ABS_Y"; break;
#endif
#ifdef ABS_Z
case ABS_Z: desc = "ABS_Z"; break;
#endif
#ifdef ABS_RX
case ABS_RX: desc = "ABS_RX"; break;
#endif
#ifdef ABS_RY
case ABS_RY: desc = "ABS_RY"; break;
#endif
#ifdef ABS_RZ
case ABS_RZ: desc = "ABS_RZ"; break;
#endif
#ifdef ABS_THROTTLE
case ABS_THROTTLE: desc = "ABS_THROTTLE"; break;
#endif
#ifdef ABS_RUDDER
case ABS_RUDDER: desc = "ABS_RUDDER"; break;
#endif