summaryrefslogtreecommitdiffstats
path: root/x11vnc/uinput.c
blob: bdd41c27f2f6e2d2f3df8531aa3cf752e77bf8a6 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
/* -- uinput.c -- */

#include "x11vnc.h"
#include "cleanup.h"
#include "scan.h"
#include "xinerama.h"
#include "screen.h"
#include "pointer.h"
#include "allowed_input_t.h"

#if LIBVNCSERVER_HAVE_SYS_IOCTL_H
#if LIBVNCSERVER_HAVE_LINUX_INPUT_H
#if LIBVNCSERVER_HAVE_LINUX_UINPUT_H
#define UINPUT_OK
#endif
#endif
#endif

#ifdef UINPUT_OK
#include <sys/ioctl.h>
#include <linux/input.h>
#include <linux/uinput.h>
#endif

int check_uinput(void);
int initialize_uinput(void);
int set_uinput_accel(char *str);
int set_uinput_thresh(char *str);
void set_uinput_reset(int ms);
char *get_uinput_accel();
char *get_uinput_thresh();
int get_uinput_reset();
void parse_uinput_str(char *str);
void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client);
void uinput_key_command(int down, int keysym, rfbClientPtr client);

static void init_key_tracker(void);
static int mod_is_down(void);
static int key_is_down(void);
static void set_uinput_accel_xy(double fx, double fy);
static void shutdown_uinput(void);
static void ptr_move(int dx, int dy);
static void ptr_rel(int dx, int dy);
static void button_click(int down, int btn);
static int lookup_code(int keysym);

static int fd = -1;
static int db = 0;
static int bmask = 0;

static char *injectable = NULL;
static char *uinput_dev = NULL;

static char *devs[] = {
	"/dev/misc/uinput",
	"/dev/input/uinput",
	"/dev/uinput",
	NULL
};


/* 
 * User may need to do:
 	modprode uinput
	mknod /dev/input/uinput c 10 223
 */

int check_uinput(void) {
	int i;
#ifndef UINPUT_OK
	return 0;
#else
	if (UT.release) {
		int maj, min;
		/* guard against linux 2.4 */
		if (sscanf(UT.release, "%d.%d.", &maj, &min) == 2) {
			if (maj < 2) {
				return 0;
			} else if (maj == 2) {
				if (min < 6) {
					return 0;
				}
			}
		}
	}
	fd = -1;
	i = 0;
	while (devs[i] != NULL) {
		if ( (fd = open(devs[i++], O_RDWR)) >= 0) {
			break;
		}
	}
	if (fd < 0) {
		return 0;
	}
	close(fd);
	fd = -1;
	return 1;
#endif
}

static int key_pressed[256];
static int key_ismod[256];

static void init_key_tracker(void) {
	int i;
	for (i = 0; i < 256; i++) {
		key_pressed[i] = 0;
		key_ismod[i] = 0;
	}
	i = lookup_code(XK_Shift_L);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Shift_R);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Control_L);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Control_R);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Alt_L);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Alt_R);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Meta_L);	if (0<=i && i<256) key_ismod[i] = 1;
	i = lookup_code(XK_Meta_R);	if (0<=i && i<256) key_ismod[i] = 1;
}

static int mod_is_down(void) {
	int i;
	for (i = 0; i < 256; i++) {
		if (key_pressed[i] && key_ismod[i]) {
			return 1;
		}
	}
	return 0;
}

static int key_is_down(void) {
	int i;
	for (i = 0; i < 256; i++) {
		if (key_pressed[i]) {
			return 1;
		}
	}
	return 0;
}

static void shutdown_uinput(void) {
#ifdef UINPUT_OK
	ioctl(fd, UI_DEV_DESTROY);
#endif
}

int initialize_uinput(void) {
#ifndef UINPUT_OK
	return 0;
#else
	int i;
	struct uinput_user_dev udev;

	if (fd >= 0) {
		shutdown_uinput();
		close(fd);
		fd = -1;
	}

	if (getenv("X11VNC_UINPUT_DEBUG")) {
		db = atoi(getenv("X11VNC_UINPUT_DEBUG"));
		rfbLog("set uinput debug to: %d\n", db);
	}

	init_key_tracker();
	
	if (uinput_dev) {
		fd = open(uinput_dev, O_RDWR);
		rfbLog("initialize_uinput: using: %s %d\n", uinput_dev, fd);
	} else {
		i = 0;
		while (devs[i] != NULL) {
			if ( (fd = open(devs[i], O_RDWR)) >= 0) {
				rfbLog("initialize_uinput: using: %s %d\n",
				    devs[i], fd);
				break;
			}
			i++;
		}
	}
	if (fd < 0) {
		rfbLog("initialize_uinput: could not open an uinput device.\n");
		rfbLogPerror("open");
		clean_up_exit(1);
	}

	memset(&udev, 0, sizeof(udev));

	strncpy(udev.name, "x11vnc injector", UINPUT_MAX_NAME_SIZE);

	udev.id.bustype = BUS_USB;	/* Matters? */
	udev.id.version = 4;

	ioctl(fd, UI_SET_EVBIT, EV_REL);
	ioctl(fd, UI_SET_RELBIT, REL_X);
	ioctl(fd, UI_SET_RELBIT, REL_Y);

	ioctl(fd, UI_SET_EVBIT, EV_KEY);

	for (i=0; i < 256; i++) {
		ioctl(fd, UI_SET_KEYBIT, i);
	}

	ioctl(fd, UI_SET_KEYBIT, BTN_MOUSE);
	ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
	ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE);
	ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT);
	ioctl(fd, UI_SET_KEYBIT, BTN_FORWARD);
	ioctl(fd, UI_SET_KEYBIT, BTN_BACK);

	write(fd, &udev, sizeof(udev));

	if (ioctl(fd, UI_DEV_CREATE) != 0) {
		rfbLog("ioctl(fd, UI_DEV_CREATE) failed.\n");
		rfbLogPerror("ioctl");
		close(fd);
		clean_up_exit(1);
	}
	return 1;
#endif
}

/* these defaults are based on qt-embedded 7/2006 */
static double fudge_x = 0.5;	/* accel=2.0 */
static double fudge_y = 0.5;

static int thresh = 5;
static int thresh_or = 1;

static double resid_x = 0.0;
static double resid_y = 0.0;

static double zero_delay = 0.15;
static double last_button_click = 0.0;

static int uinput_always = 0;

static void set_uinput_accel_xy(double fx, double fy) {
	fudge_x = 1.0/fx;
	fudge_y = 1.0/fy;
	rfbLog("set_uinput_accel:  fx=%.5f fy=%.5f\n", fx, fy);
	rfbLog("set_uinput_accel:  ix=%.5f iy=%.5f\n", fudge_x, fudge_y);
}

static char *uinput_accel_str = NULL;
static char *uinput_thresh_str = NULL;

int set_uinput_accel(char *str) {
	double fx, fy;
	rfbLog("set_uinput_accel: str=%s\n", str);
	if (sscanf(str, "%lf+%lf", &fx, &fy) == 2) {
		set_uinput_accel_xy(fx, fy);
	} else if (sscanf(str, "%lf", &fx) == 1) {
		set_uinput_accel_xy(fx, fx);
	} else {
		rfbLog("invalid UINPUT accel= option: %s\n", str);
		return 0;
	}
	if (uinput_accel_str) {
		free(uinput_accel_str);
	}
	uinput_accel_str = strdup(str);
	return 1;
}

int set_uinput_thresh(char *str) {
	rfbLog("set_uinput_thresh: str=%s\n", str);
	if (str[0] == '+') {
		thresh_or = 0;
	}
	thresh = atoi(str);
	if (uinput_thresh_str) {
		free(uinput_thresh_str);
	}
	uinput_thresh_str = strdup(str);
	return 1;
}

void set_uinput_reset(int ms) {
	zero_delay = (double) ms/1000.;
	rfbLog("set_uinput_reset: %d\n", ms);
}

int set_uinput_always(int a) {
	uinput_always = a;
}

char *get_uinput_accel(void) {
	return uinput_accel_str;
}
char *get_uinput_thresh(void) {
	return uinput_thresh_str;
}
int get_uinput_reset(void) {
	return (int) (1000 * zero_delay);
}

int get_uinput_always(void) {
	return uinput_always;
}

void parse_uinput_str(char *in) {
	char *p, *q, *str = strdup(in);

	if (injectable) {
		free(injectable);
		injectable = strdup("KMB");
	}

	p = strtok(str, ",");
	while (p) {
		if (p[0] == '/') {
			if (uinput_dev) {
				free(uinput_dev);
			}
			uinput_dev = strdup(p);
		} else if (strstr(p, "accel=") == p) {
			double fx, fy;
			q = p + strlen("accel=");
			if (! set_uinput_accel(q)) {
				clean_up_exit(1);
			}
		} else if (strstr(p, "thresh=") == p) {
			q = p + strlen("thresh=");
			set_uinput_thresh(q);

		} else if (strstr(p, "reset=") == p) {
			int n = atoi(p + strlen("reset="));
			set_uinput_reset(n);
		} else if (strstr(p, "always=") == p) {
			int n = atoi(p + strlen("always="));
			set_uinput_always(n);
		} else if (strpbrk(p, "KMB") == p) {
			if (injectable) {
				free(injectable);
			}
			injectable = strdup(p);
		} else {
			rfbLog("invalid UINPUT option: %s\n", p);
			clean_up_exit(1);
		}
		p = strtok(NULL, ",");
	}
	free(str);
}

static void ptr_move(int dx, int dy) {
#ifdef UINPUT_OK
	struct input_event ev;

	if (injectable && strchr(injectable, 'M') == NULL) {
		return;
	}

	memset(&ev, 0, sizeof(ev));

	gettimeofday(&ev.time, NULL);
	ev.type = EV_REL;
	ev.code = REL_Y;
	ev.value = dy;
	write(fd, &ev, sizeof(ev));

	ev.type = EV_REL;
	ev.code = REL_X;
	ev.value = dx;
	write(fd, &ev, sizeof(ev));

	ev.type = EV_SYN;
	ev.code = SYN_REPORT;
	ev.value = 0;
	write(fd, &ev, sizeof(ev));
#endif
}

static int inside_thresh(int dx, int dy, int thr) {
	if (thresh_or) {
		/* this is peeking at qt-embedded qmouse_qws.cpp */
		if (nabs(dx) <= thresh && nabs(dy) <= thr) {
			return 1;
		}
	} else {
		/* this is peeking at xfree/xorg xf86Xinput.c */
		if (nabs(dx) + nabs(dy) < thr) {
			return 1;
		}
	}
	return 0;
}

static void ptr_rel(int dx, int dy) {
	int dxf, dyf, nx, ny, k;
	int accel, thresh_high, thresh_mid;
	double fx, fy;
	static int try_threshes = -1;

	if (try_threshes < 0) {
		if (getenv("X11VNC_UINPUT_THRESHOLDS")) {
			try_threshes = 1;
		} else {
			try_threshes = 0;
		}
	}

	if (try_threshes) {
		thresh_high = (int) ( (double) thresh/fudge_x );
		thresh_mid =  (int) ( (double) (thresh + thresh_high) / 2.0 );

		if (thresh_mid <= thresh) {
			thresh_mid = thresh + 1;
		}
		if (thresh_high <= thresh_mid) {
			thresh_high = thresh_mid + 1;
		}

		if (inside_thresh(dx, dy, thresh)) {
			accel = 0;
		} else {
			accel = 1;
		}
		nx = nabs(dx);
		ny = nabs(dy);

	} else {
		accel = 1;
		thresh_high = 0;
		nx = ny = 1;
	}

	if (accel && nx + ny > 0 ) {
		if (thresh_high > 0 && inside_thresh(dx, dy, thresh_high)) {
			double alpha, t;
			/* XXX */
			if (1 || inside_thresh(dx, dy, thresh_mid)) {
				t = thresh; 
				accel = 2;
			} else {
				accel = 3;
				t = thresh_high;
			}
			if (thresh_or) {
				if (nx > ny) {
					fx = t;
					fy =  ((double) ny / (double) nx) * t;
				} else {
					fx =  ((double) nx / (double) ny) * t;
					fy = t;
				}
				dxf = (int) fx;
				dyf = (int) fy;
				fx = dx;
				fy = dy;
				
			} else {
				if (t > 1) {
					/* XXX */
					t = t - 1.0;
				}
				alpha = t/(nx + ny);
				fx = alpha * dx;
				fy = alpha * dy;
				dxf = (int) fx;
				dyf = (int) fy;
				fx = dx;
				fy = dy;
			}
		} else {
			fx = fudge_x * (double) dx;
			fy = fudge_y * (double) dy;
			dxf = (int) fx;
			dyf = (int) fy;
		}
	} else {
		fx = dx;
		fy = dy;
		dxf = dx;
		dyf = dy;
	}

	if (db > 1) fprintf(stderr, "old dx dy: %d %d\n", dx, dy);
	if (db > 1) fprintf(stderr, "new dx dy: %d %d  accel: %d\n", dxf, dyf, accel);

	ptr_move(dxf, dyf);

	resid_x += fx - dxf;
	resid_y += fy - dyf;

	for (k = 0; k < 4; k++) {
		if (resid_x <= -1.0 || resid_x >= 1.0 || resid_y <= -1.0 || resid_y >= 1.0) {
			dxf = 0;
			dyf = 0;
			if (resid_x >= 1.0) {
				dxf = (int) resid_x;
				dxf = 1;
			} else if (resid_x <= -1.0)  {
				dxf = -((int) (-resid_x));
				dxf = -1;
			}
			resid_x -= dxf;
			if (resid_y >= 1.0) {
				dyf = (int) resid_y;
				dyf = 1;
			} else if (resid_y <= -1.0)  {
				dyf = -((int) (-resid_y));
				dyf = -1;
			}
			resid_y -= dyf;

			if (db > 1) fprintf(stderr, "*%s resid: dx dy: %d %d  %f %f\n", accel > 1 ? "*" : " ", dxf, dyf, resid_x, resid_y);
if (0) {usleep(100*1000)};
			ptr_move(dxf, dyf);
		}
	}
}

static void button_click(int down, int btn) {
#ifdef UINPUT_OK
	struct input_event ev;

	if (injectable && strchr(injectable, 'B') == NULL) {
		return;
	}

	if (db) fprintf(stderr, "button_click: btn %d %s\n", btn, down ? "down" : "up");

	memset(&ev, 0, sizeof(ev));
	gettimeofday(&ev.time, NULL);
	ev.type = EV_KEY;
	ev.value = down;

	if (btn == 1) {
		ev.code = BTN_LEFT;
	} else if (btn == 2) {
		ev.code = BTN_MIDDLE;
	} else if (btn == 3) {
		ev.code = BTN_RIGHT;
	} else if (btn == 4) {
		ev.code = BTN_FORWARD;
	} else if (btn == 5) {
		ev.code = BTN_BACK;
	} else {
		return;
	}

	write(fd, &ev, sizeof(ev));

	ev.type = EV_SYN;
	ev.code = SYN_REPORT;
	ev.value = 0;
	write(fd, &ev, sizeof(ev));

	last_button_click = dnow();

#endif
}


void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
	static int last_x = -1, last_y = -1, last_mask = -1;
	static double last_zero = 0.0;
	allowed_input_t input;
	int do_reset, reset_lower_right = 1;
	double now;
	static int first = 1;

	if (first) {
		if (getenv("RESET_ALWAYS")) {
			set_uinput_always(1);
		} else {
			set_uinput_always(0);
		}
	}
	first = 0;
	
	if (db) fprintf(stderr, "uinput_pointer_command: %d %d - %d\n", x, y, mask);

	if (view_only) {
		return;
	}
	get_allowed_input(client, &input);

	now = dnow();

	do_reset = 1;
	if (mask || bmask) {
		do_reset = 0;	/* do not do reset if moust button down */
	} else if (! input.motion) {
		do_reset = 0;
	} else if (now < last_zero + zero_delay) {
		do_reset = 0;
	}
	if (do_reset) {
		if (mod_is_down()) {
			do_reset = 0;
		} else if (now < last_button_click + 0.25) {
			do_reset = 0;
		}
	}

	if (uinput_always && !mask && !bmask && input.motion) {
		do_reset = 1;
	}

	if (do_reset) {
		static int first = 1;

		if (zero_delay > 0.0 || first) {
			/* try to push it to 0,0 */
			int tx, ty, bigjump = 1;

			if (reset_lower_right) {
				tx = fudge_x * (dpy_x - last_x);
				ty = fudge_y * (dpy_y - last_y);
			} else {
				tx = fudge_x * last_x;
				ty = fudge_y * last_y;
			}

			tx += 50;
			ty += 50;

			if (bigjump) {
				if (reset_lower_right) {
					ptr_move(0, +ty);
					usleep(2*1000);
					ptr_move(+tx, +ty);
					ptr_move(+tx, +ty);
				} else {
					ptr_move(0, -ty);
					usleep(2*1000);
					ptr_move(-tx, -ty);
					ptr_move(-tx, -ty);
				}
			} else {
				int i, step, n = 20;
				step = dpy_x / n;

				if (step < 100) step = 100;

				for (i=0; i < n; i++)  {
					if (reset_lower_right) {
						ptr_move(+step, +step);
					} else {
						ptr_move(-step, -step);
					}
				}
				for (i=0; i < n; i++)  {
					if (reset_lower_right) {
						ptr_move(+1, +1);
					} else {
						ptr_move(-1, -1);
					}
				}
			}
			if (db) {
				if (reset_lower_right) {
					fprintf(stderr, "uinput_pointer_command: reset -> (W,H) (%d,%d)  [%d,%d]\n", x, y, tx, ty);
				} else {
					fprintf(stderr, "uinput_pointer_command: reset -> (0,0) (%d,%d)  [%d,%d]\n", x, y, tx, ty);
				}
			}

			/* rest a bit for system to absorb the change */
			if (uinput_always) {
				static double last_sleep = 0.0;
				double nw = dnow(), delay = zero_delay;
				if (delay <= 0.0) delay = 0.1;
				if (nw > last_sleep + delay) {
					usleep(10*1000);
					last_sleep = nw;
				} else {
					usleep(1*1000);
				}
				
			} else {
				usleep(30*1000);
			}

			/* now jump back out */
			if (reset_lower_right) {
				ptr_rel(x - dpy_x, y - dpy_y);
			} else {
				ptr_rel(x, y);
			}
			if (1) {usleep(10*1000)};

			last_x = x;
			last_y = y;
			resid_x = 0.0;
			resid_y = 0.0;

			first = 0;
		}
		last_zero = dnow();
	}

	if (input.motion) {
		if (x != last_x || y != last_y) {
			ptr_rel(x - last_x, y - last_y);
			last_x = x;
			last_y = y;
		}
	}

	if (! input.button) {
		return;
	}

	if (last_mask < 0) {
		last_mask = mask;
	}

	if (db > 2) {
		fprintf(stderr, "mask:        %s\n", bitprint(mask, 16));
		fprintf(stderr, "bmask:       %s\n", bitprint(bmask, 16));
		fprintf(stderr, "last_mask:   %s\n", bitprint(last_mask, 16));
		fprintf(stderr, "button_mask: %s\n", bitprint(button_mask, 16));
	}

	if (mask != last_mask) {
		int i;
		for (i=1; i <= MAX_BUTTONS; i++) {
			int down, b = 1 << (i-1);
			if ( (last_mask & b) == (mask & b)) {
				continue;
			}
			if (mask & b) {
				down = 1;
			} else {
				down = 0;
			}
			button_click(down, i);
		}
		last_mask = mask;
	}
	bmask = mask;
}

void uinput_key_command(int down, int keysym, rfbClientPtr client) {
#ifdef UINPUT_OK
	struct input_event ev;
	int scancode;
	allowed_input_t input;

	if (injectable && strchr(injectable, 'K') == NULL) {
		return;
	}
	if (view_only) {
		return;
	}
	get_allowed_input(client, &input);
	if (! input.keystroke) {
		return;
	}

	scancode = lookup_code(keysym);

	if (scancode < 0) {
		return;
	}
	if (db) fprintf(stderr, "uinput_key_command: %d -> %d %s\n", keysym, scancode, down ? "down" : "up");

	memset(&ev, 0, sizeof(ev));
	gettimeofday(&ev.time, NULL);
	ev.type = EV_KEY;
	ev.code = (unsigned char) scancode;
	ev.value = down;

	write(fd, &ev, sizeof(ev));

	ev.type = EV_SYN;
	ev.code = SYN_REPORT;
	ev.value = 0;
	write(fd, &ev, sizeof(ev));

	if (0 <= scancode && scancode < 256) {
		key_pressed[scancode] = down ? 1 : 0;
	}
#endif
}

static int lookup_code(int keysym) {

	if (keysym == NoSymbol) {
		return -1;
	}

	switch(keysym) {
#ifdef UINPUT_OK
	case XK_Escape:	return KEY_ESC;
	case XK_1:		return KEY_1;
	case XK_2:		return KEY_2;
	case XK_3:		return KEY_3;
	case XK_4:		return KEY_4;
	case XK_5:		return KEY_5;
	case XK_6:		return KEY_6;
	case XK_7:		return KEY_7;
	case XK_8:		return KEY_8;
	case XK_9:		return KEY_9;
	case XK_0:		return KEY_0;
	case XK_exclam:	return KEY_1;
	case XK_at:		return KEY_2;
	case XK_numbersign:	return KEY_3;
	case XK_dollar:	return KEY_4;
	case XK_percent:	return KEY_5;
	case XK_asciicircum:	return KEY_6;
	case XK_ampersand:	return KEY_7;
	case XK_asterisk:	return KEY_8;
	case XK_parenleft:	return KEY_9;
	case XK_parenright:	return KEY_0;
	case XK_minus:	return KEY_MINUS;
	case XK_underscore:	return KEY_MINUS;
	case XK_equal:	return KEY_EQUAL;
	case XK_plus:	return KEY_EQUAL;
	case XK_BackSpace:	return KEY_BACKSPACE;
	case XK_Tab:		return KEY_TAB;
	case XK_q:		return KEY_Q;
	case XK_Q:		return KEY_Q;
	case XK_w:		return KEY_W;
	case XK_W:		return KEY_W;
	case XK_e:		return KEY_E;
	case XK_E:		return KEY_E;
	case XK_r:		return KEY_R;
	case XK_R:		return KEY_R;
	case XK_t:		return KEY_T;
	case XK_T:		return KEY_T;
	case XK_y:		return KEY_Y;
	case XK_Y:		return KEY_Y;
	case XK_u:		return KEY_U;
	case XK_U:		return KEY_U;
	case XK_i:		return KEY_I;
	case XK_I:		return KEY_I;
	case XK_o:		return KEY_O;
	case XK_O:		return KEY_O;
	case XK_p:		return KEY_P;
	case XK_P:		return KEY_P;
	case XK_braceleft:	return KEY_LEFTBRACE;
	case XK_braceright:	return KEY_RIGHTBRACE;
	case XK_bracketleft:	return KEY_LEFTBRACE;
	case XK_bracketright:	return KEY_RIGHTBRACE;
	case XK_Return:	return KEY_ENTER;
	case XK_Control_L:	return KEY_LEFTCTRL;
	case XK_a:		return KEY_A;
	case XK_A:		return KEY_A;
	case XK_s:		return KEY_S;
	case XK_S:		return KEY_S;
	case XK_d:		return KEY_D;
	case XK_D:		return KEY_D;
	case XK_f:		return KEY_F;
	case XK_F:		return KEY_F;
	case XK_g:		return KEY_G;
	case XK_G:		return KEY_G;
	case XK_h:		return KEY_H;
	case XK_H:		return KEY_H;
	case XK_j:		return KEY_J;
	case XK_J:		return KEY_J;
	case XK_k:		return KEY_K;
	case XK_K:		return KEY_K;
	case XK_l:		return KEY_L;
	case XK_L:		return KEY_L;
	case XK_semicolon:	return KEY_SEMICOLON;
	case XK_colon:	return KEY_SEMICOLON;
	case XK_apostrophe:	return KEY_APOSTROPHE;
	case XK_quotedbl:	return KEY_APOSTROPHE;
	case XK_grave:	return KEY_GRAVE;
	case XK_asciitilde:	return KEY_GRAVE;
	case XK_Shift_L:	return KEY_LEFTSHIFT;
	case XK_backslash:	return KEY_BACKSLASH;
	case XK_bar:		return KEY_BACKSLASH;
	case XK_z:		return KEY_Z;
	case XK_Z:		return KEY_Z;
	case XK_x:		return KEY_X;
	case XK_X:		return KEY_X;
	case XK_c:		return KEY_C;
	case XK_C:		return KEY_C;
	case XK_v:		return KEY_V;
	case XK_V:		return KEY_V;
	case XK_b:		return KEY_B;
	case XK_B:		return KEY_B;
	case XK_n:		return KEY_N;
	case XK_N:		return KEY_N;
	case XK_m:		return KEY_M;
	case XK_M:		return KEY_M;
	case XK_comma:	return KEY_COMMA;
	case XK_less:	return KEY_COMMA;
	case XK_period:	return KEY_DOT;
	case XK_greater:	return KEY_DOT;
	case XK_slash:	return KEY_SLASH;
	case XK_question:	return KEY_SLASH;
	case XK_Shift_R:	return KEY_RIGHTSHIFT;
	case XK_KP_Multiply:	return KEY_KPASTERISK;
	case XK_Alt_L:	return KEY_LEFTALT;
	case XK_space:	return KEY_SPACE;
	case XK_Caps_Lock:	return KEY_CAPSLOCK;
	case XK_F1:		return KEY_F1;
	case XK_F2:		return KEY_F2;
	case XK_F3:		return KEY_F3;
	case XK_F4:		return KEY_F4;
	case XK_F5:		return KEY_F5;
	case XK_F6:		return KEY_F6;
	case XK_F7:		return KEY_F7;
	case XK_F8:		return KEY_F8;
	case XK_F9:		return KEY_F9;
	case XK_F10:		return KEY_F10;
	case XK_Num_Lock:	return KEY_NUMLOCK;
	case XK_Scroll_Lock:	return KEY_SCROLLLOCK;
	case XK_KP_7:		return KEY_KP7;
	case XK_KP_8:		return KEY_KP8;
	case XK_KP_9:		return KEY_KP9;
	case XK_KP_Subtract:	return KEY_KPMINUS;
	case XK_KP_4:		return KEY_KP4;
	case XK_KP_5:		return KEY_KP5;
	case XK_KP_6:		return KEY_KP6;
	case XK_KP_Add:	return KEY_KPPLUS;
	case XK_KP_1:		return KEY_KP1;
	case XK_KP_2:		return KEY_KP2;
	case XK_KP_3:		return KEY_KP3;
	case XK_KP_0:		return KEY_KP0;
	case XK_KP_Decimal:	return KEY_KPDOT;
	case XK_F13:		return KEY_F13;
	case XK_F11:		return KEY_F11;
	case XK_F12:		return KEY_F12;
	case XK_F14:		return KEY_F14;
	case XK_F15:		return KEY_F15;
	case XK_F16:		return KEY_F16;
	case XK_F17:		return KEY_F17;
	case XK_F18:		return KEY_F18;
	case XK_F19:		return KEY_F19;
	case XK_F20:		return KEY_F20;
	case XK_KP_Enter:	return KEY_KPENTER;
	case XK_Control_R:	return KEY_RIGHTCTRL;
	case XK_KP_Divide:	return KEY_KPSLASH;
	case XK_Sys_Req:	return KEY_SYSRQ;
	case XK_Alt_R:	return KEY_RIGHTALT;
	case XK_Linefeed:	return KEY_LINEFEED;
	case XK_Home:		return KEY_HOME;
	case XK_Up:		return KEY_UP;
	case XK_Page_Up:	return KEY_PAGEUP;
	case XK_Left:		return KEY_LEFT;
	case XK_Right:	return KEY_RIGHT;
	case XK_End:		return KEY_END;
	case XK_Down:		return KEY_DOWN;
	case XK_Page_Down:	return KEY_PAGEDOWN;
	case XK_Insert:	return KEY_INSERT;
	case XK_Delete:	return KEY_DELETE;
	case XK_KP_Equal:	return KEY_KPEQUAL;
	case XK_Pause:	return KEY_PAUSE;
	case XK_F21:		return KEY_F21;
	case XK_F22:		return KEY_F22;
	case XK_F23:		return KEY_F23;
	case XK_F24:		return KEY_F24;
	case XK_KP_Separator:	return KEY_KPCOMMA;
	case XK_Meta_L:	return KEY_LEFTMETA;
	case XK_Meta_R:	return KEY_RIGHTMETA;
	case XK_Multi_key:	return KEY_COMPOSE;
#endif
	default:		return -1;
	}
}

#if 0

From /usr/include/linux/input.h

We maintain it here since it is such a painful mess.

Here is a little script to make it easier:

#!/usr/bin/perl
while (<>) {
	$_ =~ s/-XK_/XK_/;
	next unless /^XK_/;
	chomp;
	if (/^(\S+)(\s+)(\S+)/) {
		$a = $1;
		$t = $2;
		$b = $3;
		print "\tcase $a:${t}return $b;\n";
		if ($a =~ /XK_[a-z]$/) {
			$a = uc($a);
			print "\tcase $a:${t}return $b;\n";
		}
	}
}

This only handles US kbd, we would need a kbd database in general...
Ugh: parse dumpkeys(1) or -fookeys /usr/share/keymaps/i386/qwerty/dk.kmap.gz

XK_Escape	KEY_ESC
XK_1		KEY_1
XK_2		KEY_2
XK_3		KEY_3
XK_4		KEY_4
XK_5		KEY_5
XK_6		KEY_6
XK_7		KEY_7
XK_8		KEY_8
XK_9		KEY_9
XK_0		KEY_0
-XK_exclam	KEY_1
-XK_at		KEY_2
-XK_numbersign	KEY_3
-XK_dollar	KEY_4
-XK_percent	KEY_5
-XK_asciicircum	KEY_6
-XK_ampersand	KEY_7
-XK_asterisk	KEY_8
-XK_parenleft	KEY_9
-XK_parenright	KEY_0
XK_minus	KEY_MINUS
-XK_underscore	KEY_MINUS
XK_equal	KEY_EQUAL
-XK_plus	KEY_EQUAL
XK_BackSpace	KEY_BACKSPACE
XK_Tab		KEY_TAB
XK_q		KEY_Q
XK_w		KEY_W
XK_e		KEY_E
XK_r		KEY_R
XK_t		KEY_T
XK_y		KEY_Y
XK_u		KEY_U
XK_i		KEY_I
XK_o		KEY_O
XK_p		KEY_P
XK_braceleft	KEY_LEFTBRACE
XK_braceright	KEY_RIGHTBRACE
-XK_bracketleft	KEY_LEFTBRACE
-XK_bracketright	KEY_RIGHTBRACE
XK_Return	KEY_ENTER
XK_Control_L	KEY_LEFTCTRL
XK_a		KEY_A
XK_s		KEY_S
XK_d		KEY_D
XK_f		KEY_F
XK_g		KEY_G
XK_h		KEY_H
XK_j		KEY_J
XK_k		KEY_K
XK_l		KEY_L
XK_semicolon	KEY_SEMICOLON
-XK_colon	KEY_SEMICOLON
XK_apostrophe	KEY_APOSTROPHE
-XK_quotedbl	KEY_APOSTROPHE
XK_grave	KEY_GRAVE
-XK_asciitilde	KEY_GRAVE
XK_Shift_L	KEY_LEFTSHIFT
XK_backslash	KEY_BACKSLASH
-XK_bar		KEY_BACKSLASH
XK_z		KEY_Z
XK_x		KEY_X
XK_c		KEY_C
XK_v		KEY_V
XK_b		KEY_B
XK_n		KEY_N
XK_m		KEY_M
XK_comma	KEY_COMMA
-XK_less	KEY_COMMA
XK_period	KEY_DOT
-XK_greater	KEY_DOT
XK_slash	KEY_SLASH
-XK_question	KEY_SLASH
XK_Shift_R	KEY_RIGHTSHIFT
XK_KP_Multiply	KEY_KPASTERISK
XK_Alt_L	KEY_LEFTALT
XK_space	KEY_SPACE
XK_Caps_Lock	KEY_CAPSLOCK
XK_F1		KEY_F1
XK_F2		KEY_F2
XK_F3		KEY_F3
XK_F4		KEY_F4
XK_F5		KEY_F5
XK_F6		KEY_F6
XK_F7		KEY_F7
XK_F8		KEY_F8
XK_F9		KEY_F9
XK_F10		KEY_F10
XK_Num_Lock	KEY_NUMLOCK
XK_Scroll_Lock	KEY_SCROLLLOCK
XK_KP_7		KEY_KP7
XK_KP_8		KEY_KP8
XK_KP_9		KEY_KP9
XK_KP_Subtract	KEY_KPMINUS
XK_KP_4		KEY_KP4
XK_KP_5		KEY_KP5
XK_KP_6		KEY_KP6
XK_KP_Add	KEY_KPPLUS
XK_KP_1		KEY_KP1
XK_KP_2		KEY_KP2
XK_KP_3		KEY_KP3
XK_KP_0		KEY_KP0
XK_KP_Decimal	KEY_KPDOT
NoSymbol	KEY_103RD
XK_F13		KEY_F13
NoSymbol	KEY_102ND
XK_F11		KEY_F11
XK_F12		KEY_F12
XK_F14		KEY_F14
XK_F15		KEY_F15
XK_F16		KEY_F16
XK_F17		KEY_F17
XK_F18		KEY_F18
XK_F19		KEY_F19
XK_F20		KEY_F20
XK_KP_Enter	KEY_KPENTER
XK_Control_R	KEY_RIGHTCTRL
XK_KP_Divide	KEY_KPSLASH
XK_Sys_Req	KEY_SYSRQ
XK_Alt_R	KEY_RIGHTALT
XK_Linefeed	KEY_LINEFEED
XK_Home		KEY_HOME
XK_Up		KEY_UP
XK_Page_Up	KEY_PAGEUP
XK_Left		KEY_LEFT
XK_Right	KEY_RIGHT
XK_End		KEY_END
XK_Down		KEY_DOWN
XK_Page_Down	KEY_PAGEDOWN
XK_Insert	KEY_INSERT
XK_Delete	KEY_DELETE
NoSymbol	KEY_MACRO
NoSymbol	KEY_MUTE
NoSymbol	KEY_VOLUMEDOWN
NoSymbol	KEY_VOLUMEUP
NoSymbol	KEY_POWER
XK_KP_Equal	KEY_KPEQUAL
NoSymbol	KEY_KPPLUSMINUS
XK_Pause	KEY_PAUSE
XK_F21		KEY_F21
XK_F22		KEY_F22
XK_F23		KEY_F23
XK_F24		KEY_F24
XK_KP_Separator	KEY_KPCOMMA
XK_Meta_L	KEY_LEFTMETA
XK_Meta_R	KEY_RIGHTMETA
XK_Multi_key	KEY_COMPOSE

NoSymbol	KEY_STOP
NoSymbol	KEY_AGAIN
NoSymbol	KEY_PROPS
NoSymbol	KEY_UNDO
NoSymbol	KEY_FRONT
NoSymbol	KEY_COPY
NoSymbol	KEY_OPEN
NoSymbol	KEY_PASTE
NoSymbol	KEY_FIND
NoSymbol	KEY_CUT
NoSymbol	KEY_HELP
NoSymbol	KEY_MENU
NoSymbol	KEY_CALC
NoSymbol	KEY_SETUP
NoSymbol	KEY_SLEEP
NoSymbol	KEY_WAKEUP
NoSymbol	KEY_FILE
NoSymbol	KEY_SENDFILE
NoSymbol	KEY_DELETEFILE
NoSymbol	KEY_XFER
NoSymbol	KEY_PROG1
NoSymbol	KEY_PROG2
NoSymbol	KEY_WWW
NoSymbol	KEY_MSDOS
NoSymbol	KEY_COFFEE
NoSymbol	KEY_DIRECTION
NoSymbol	KEY_CYCLEWINDOWS
NoSymbol	KEY_MAIL
NoSymbol	KEY_BOOKMARKS
NoSymbol	KEY_COMPUTER
NoSymbol	KEY_BACK
NoSymbol	KEY_FORWARD
NoSymbol	KEY_CLOSECD
NoSymbol	KEY_EJECTCD
NoSymbol	KEY_EJECTCLOSECD
NoSymbol	KEY_NEXTSONG
NoSymbol	KEY_PLAYPAUSE
NoSymbol	KEY_PREVIOUSSONG
NoSymbol	KEY_STOPCD
NoSymbol	KEY_RECORD
NoSymbol	KEY_REWIND
NoSymbol	KEY_PHONE
NoSymbol	KEY_ISO
NoSymbol	KEY_CONFIG
NoSymbol	KEY_HOMEPAGE
NoSymbol	KEY_REFRESH
NoSymbol	KEY_EXIT
NoSymbol	KEY_MOVE
NoSymbol	KEY_EDIT
NoSymbol	KEY_SCROLLUP
NoSymbol	KEY_SCROLLDOWN
NoSymbol	KEY_KPLEFTPAREN
NoSymbol	KEY_KPRIGHTPAREN

NoSymbol	KEY_INTL1
NoSymbol	KEY_INTL2
NoSymbol	KEY_INTL3
NoSymbol	KEY_INTL4
NoSymbol	KEY_INTL5
NoSymbol	KEY_INTL6
NoSymbol	KEY_INTL7
NoSymbol	KEY_INTL8
NoSymbol	KEY_INTL9
NoSymbol	KEY_LANG1
NoSymbol	KEY_LANG2
NoSymbol	KEY_LANG3
NoSymbol	KEY_LANG4
NoSymbol	KEY_LANG5
NoSymbol	KEY_LANG6
NoSymbol	KEY_LANG7
NoSymbol	KEY_LANG8
NoSymbol	KEY_LANG9

NoSymbol	KEY_PLAYCD
NoSymbol	KEY_PAUSECD
NoSymbol	KEY_PROG3
NoSymbol	KEY_PROG4
NoSymbol	KEY_SUSPEND
NoSymbol	KEY_CLOSE
NoSymbol	KEY_PLAY
NoSymbol	KEY_FASTFORWARD
NoSymbol	KEY_BASSBOOST
NoSymbol	KEY_PRINT
NoSymbol	KEY_HP
NoSymbol	KEY_CAMERA
NoSymbol	KEY_SOUND
NoSymbol	KEY_QUESTION
NoSymbol	KEY_EMAIL
NoSymbol	KEY_CHAT
NoSymbol	KEY_SEARCH
NoSymbol	KEY_CONNECT
NoSymbol	KEY_FINANCE
NoSymbol	KEY_SPORT
NoSymbol	KEY_SHOP
NoSymbol	KEY_ALTERASE
NoSymbol	KEY_CANCEL
NoSymbol	KEY_BRIGHTNESSDOWN
NoSymbol	KEY_BRIGHTNESSUP
NoSymbol	KEY_MEDIA

NoSymbol	KEY_UNKNOWN
NoSymbol	
NoSymbol	BTN_MISC
NoSymbol	BTN_0
NoSymbol	BTN_1
NoSymbol	BTN_2
NoSymbol	BTN_3
NoSymbol	BTN_4
NoSymbol	BTN_5
NoSymbol	BTN_6
NoSymbol	BTN_7
NoSymbol	BTN_8
NoSymbol	BTN_9
NoSymbol	
NoSymbol	BTN_MOUSE
NoSymbol	BTN_LEFT
NoSymbol	BTN_RIGHT
NoSymbol	BTN_MIDDLE
NoSymbol	BTN_SIDE
NoSymbol	BTN_EXTRA
NoSymbol	BTN_FORWARD
NoSymbol	BTN_BACK
NoSymbol	BTN_TASK
NoSymbol	
NoSymbol	BTN_JOYSTICK
NoSymbol	BTN_TRIGGER
NoSymbol	BTN_THUMB
NoSymbol	BTN_THUMB2
NoSymbol	BTN_TOP
NoSymbol	BTN_TOP2
NoSymbol	BTN_PINKIE
NoSymbol	BTN_BASE
NoSymbol	BTN_BASE2
NoSymbol	BTN_BASE3
NoSymbol	BTN_BASE4
NoSymbol	BTN_BASE5
NoSymbol	BTN_BASE6
NoSymbol	BTN_DEAD

NoSymbol	BTN_GAMEPAD
NoSymbol	BTN_A
NoSymbol	BTN_B
NoSymbol	BTN_C
NoSymbol	BTN_X
NoSymbol	BTN_Y
NoSymbol	BTN_Z
NoSymbol	BTN_TL
NoSymbol	BTN_TR
NoSymbol	BTN_TL2
NoSymbol	BTN_TR2
NoSymbol	BTN_SELECT
NoSymbol	BTN_START
NoSymbol	BTN_MODE
NoSymbol	BTN_THUMBL
NoSymbol	BTN_THUMBR

NoSymbol	BTN_DIGI
NoSymbol	BTN_TOOL_PEN
NoSymbol	BTN_TOOL_RUBBER
NoSymbol	BTN_TOOL_BRUSH
NoSymbol	BTN_TOOL_PENCIL
NoSymbol	BTN_TOOL_AIRBRUSH
NoSymbol	BTN_TOOL_FINGER
NoSymbol	BTN_TOOL_MOUSE
NoSymbol	BTN_TOOL_LENS
NoSymbol	BTN_TOUCH
NoSymbol	BTN_STYLUS
NoSymbol	BTN_STYLUS2
NoSymbol	BTN_TOOL_DOUBLETAP
NoSymbol	BTN_TOOL_TRIPLETAP

NoSymbol	BTN_WHEEL
NoSymbol	BTN_GEAR_DOWN
NoSymbol	BTN_GEAR_UP

NoSymbol	KEY_OK
NoSymbol	KEY_SELECT
NoSymbol	KEY_GOTO
NoSymbol	KEY_CLEAR
NoSymbol	KEY_POWER2
NoSymbol	KEY_OPTION
NoSymbol	KEY_INFO
NoSymbol	KEY_TIME
NoSymbol	KEY_VENDOR
NoSymbol	KEY_ARCHIVE
NoSymbol	KEY_PROGRAM
NoSymbol	KEY_CHANNEL
NoSymbol	KEY_FAVORITES
NoSymbol	KEY_EPG
NoSymbol	KEY_PVR
NoSymbol	KEY_MHP
NoSymbol	KEY_LANGUAGE
NoSymbol	KEY_TITLE
NoSymbol	KEY_SUBTITLE
NoSymbol	KEY_ANGLE
NoSymbol	KEY_ZOOM
NoSymbol	KEY_MODE
NoSymbol	KEY_KEYBOARD
NoSymbol	KEY_SCREEN
NoSymbol	KEY_PC
NoSymbol	KEY_TV
NoSymbol	KEY_TV2
NoSymbol	KEY_VCR
NoSymbol	KEY_VCR2
NoSymbol	KEY_SAT
NoSymbol	KEY_SAT2
NoSymbol	KEY_CD
NoSymbol	KEY_TAPE
NoSymbol	KEY_RADIO
NoSymbol	KEY_TUNER
NoSymbol	KEY_PLAYER
NoSymbol	KEY_TEXT
NoSymbol	KEY_DVD
NoSymbol	KEY_AUX
NoSymbol	KEY_MP3
NoSymbol	KEY_AUDIO
NoSymbol	KEY_VIDEO
NoSymbol	KEY_DIRECTORY
NoSymbol	KEY_LIST
NoSymbol	KEY_MEMO
NoSymbol	KEY_CALENDAR
NoSymbol	KEY_RED
NoSymbol	KEY_GREEN
NoSymbol	KEY_YELLOW
NoSymbol	KEY_BLUE
NoSymbol	KEY_CHANNELUP
NoSymbol	KEY_CHANNELDOWN
NoSymbol	KEY_FIRST
NoSymbol	KEY_LAST
NoSymbol	KEY_AB
NoSymbol	KEY_NEXT
NoSymbol	KEY_RESTART
NoSymbol	KEY_SLOW
NoSymbol	KEY_SHUFFLE
NoSymbol	KEY_BREAK
NoSymbol	KEY_PREVIOUS
NoSymbol	KEY_DIGITS
NoSymbol	KEY_TEEN
NoSymbol	KEY_TWEN

NoSymbol	KEY_DEL_EOL
NoSymbol	KEY_DEL_EOS
NoSymbol	KEY_INS_LINE
NoSymbol	KEY_DEL_LINE
NoSymbol	KEY_MAX

#endif