annotate uinput.c @ 6:eafcd170dc6d

Add circle pad and c pad support, and provisional touch support.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Aug 2015 02:07:48 +0100
parents 73c20831be0a
children 6aa40a25de22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 #include "uinput.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 #include "ds.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 #include "service.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 #include <stdio.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 #include <fcntl.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 #include <string.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 #include <sys/ioctl.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 #include <unistd.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 #include <stdbool.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12
4
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
13 #define DS_NAME "Nintendo 3DS"
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 /* Not found these values... but it's not important! */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 #define DS_VENDOR 0xdead
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 #define DS_PRODUCT 0xbeef
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 #define DS_VERSION 0x00
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
22 /*
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 Create a new uinput device
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 Returns: file descriptor (-1 if error)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 int init_uinput_device(void){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 struct uinput_user_dev dev;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 int fd = -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 if(uinput_dev == NULL){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 fd = open("/dev/uinput", O_RDWR);
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
32
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 if(fd < 0)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 fd = open("/dev/misc/uinput", O_RDWR);
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
35
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 if(fd < 0)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 fd = open("/dev/input/uinput", O_RDWR);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 else fd = open(uinput_dev, O_RDWR); //from xml
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
40
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 if(fd < 0){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 fprintf(stderr, " [%d] Unable to open uinput device ; hint: 'modprobe uinput' ?!\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
45
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
46
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 memset(&dev, 0, sizeof(dev));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 strncpy(dev.name, DS_NAME, UINPUT_MAX_NAME_SIZE);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 dev.id.bustype = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 dev.id.vendor = DS_VENDOR;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 dev.id.product = DS_PRODUCT;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 dev.id.version = DS_VERSION;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54
6
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
55 // Circle pad
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
56 dev.absmax[ABS_X] = PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
57 dev.absmin[ABS_X] = -PAD_MAX;
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 dev.absfuzz[ABS_X] = 4;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
59 dev.absflat[ABS_X] = 2;
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
60
6
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
61 dev.absmax[ABS_Y] = PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
62 dev.absmin[ABS_Y] = -PAD_MAX;
4
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
63 dev.absfuzz[ABS_Y] = 4;
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
64 dev.absflat[ABS_Y] = 2;
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66
6
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
67 // C pad
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
68 dev.absmax[ABS_RX] = PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
69 dev.absmin[ABS_RX] = -PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
70 dev.absfuzz[ABS_RX] = 4;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
71 dev.absflat[ABS_RX] = 2;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
72
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
73 dev.absmax[ABS_RY] = PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
74 dev.absmin[ABS_RY] = -PAD_MAX;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
75 dev.absfuzz[ABS_RY] = 4;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
76 dev.absflat[ABS_RY] = 2;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
77
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
78
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 if(write(fd, &dev, sizeof(dev)) < (ssize_t)sizeof(dev)){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 fprintf(stderr, " [%d] Registering device at uinput failed\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
83
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 /* Keys [01] (found in <linux/input.h>) */
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
85 if( ioctl(fd, UI_SET_EVBIT, EV_KEY) ) return -1;
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 if( ioctl(fd, UI_SET_KEYBIT, BTN_A) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 if( ioctl(fd, UI_SET_KEYBIT, BTN_B) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88 if( ioctl(fd, UI_SET_KEYBIT, BTN_X) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 if( ioctl(fd, UI_SET_KEYBIT, BTN_Y) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 if( ioctl(fd, UI_SET_KEYBIT, BTN_TL) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 if( ioctl(fd, UI_SET_KEYBIT, BTN_TR) ) return -1;
4
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
92 if( ioctl(fd, UI_SET_KEYBIT, BTN_TL2) ) return -1;
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
93 if( ioctl(fd, UI_SET_KEYBIT, BTN_TR2) ) return -1;
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 if( ioctl(fd, UI_SET_KEYBIT, BTN_START) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 if( ioctl(fd, UI_SET_KEYBIT, BTN_SELECT)) return -1;
4
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
96 if( ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_UP)) return -1;
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
97 if( ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_DOWN)) return -1;
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
98 if( ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_LEFT)) return -1;
73c20831be0a Replace DS input with 3DS, for now disable axis input.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 2
diff changeset
99 if( ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_RIGHT)) return -1;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
100
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 /* D-Pad [-0xFFFF - 0xFFFF] */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 if( ioctl(fd, UI_SET_EVBIT, EV_ABS) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 if( ioctl(fd, UI_SET_ABSBIT, ABS_X) ) return -1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 if( ioctl(fd, UI_SET_ABSBIT, ABS_Y) ) return -1;
6
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
105 if( ioctl(fd, UI_SET_ABSBIT, ABS_RX) ) return -1;
eafcd170dc6d Add circle pad and c pad support, and provisional touch support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 4
diff changeset
106 if( ioctl(fd, UI_SET_ABSBIT, ABS_RY) ) return -1;
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 /* Register device */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 if( ioctl(fd, UI_DEV_CREATE) ) return -1;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
111
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 return fd;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 Send an event into the uinput device
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 Returns: TRUE, FALSE
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 int do_uinput(int fd, unsigned short key, int pressed, unsigned short event_type){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 struct input_event event;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 memset(&event, 0 , sizeof(event));
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
123
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 event.type = event_type;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 event.code = key;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 event.value = pressed;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
127
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 if(write(fd,&event,sizeof(event)) != sizeof(event)){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 fprintf(stderr, " [%d] Writing event to uinput driver failed ; Aborting\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 return false;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 return true;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
134
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 Synchonize events
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139 void flush_uinput(int fd){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140 struct input_event event;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141 memset(&event, 0 , sizeof(event));
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
142
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143 event.type = EV_SYN;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
144 event.code = SYN_REPORT;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
145
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
146 if(fd){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 if(write(fd, &event, sizeof(event) != sizeof(event)))
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
148 fprintf(stderr, " [%d] Flushing uinput failed\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
149 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
150 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
151
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
152
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
153
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
154
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
155