summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mtouch.c24
-rw-r--r--src/mtouch.h4
-rw-r--r--src/multitouch.c103
3 files changed, 80 insertions, 51 deletions
diff --git a/src/mtouch.c b/src/mtouch.c
index 2d05921..a74a1f6 100644
--- a/src/mtouch.c
+++ b/src/mtouch.c
@@ -14,9 +14,31 @@ int configure_mtouch(struct MTouch *mt, int fd)
14 14
15/******************************************************/ 15/******************************************************/
16 16
17int init_mtouch(struct MTouch *mt) 17int open_mtouch(struct MTouch *mt, int fd)
18{ 18{
19 int rc;
20 if (mt->grabbed)
21 return 0;
22 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1));
23 if (rc < 0) {
24 xf86Msg(X_WARNING, "multitouch: cannot grab device\n");
25 return rc;
26 }
27 mt->grabbed = 1;
19 return 0; 28 return 0;
20} 29}
21 30
22/******************************************************/ 31/******************************************************/
32
33void close_mtouch(struct MTouch *mt, int fd)
34{
35 int rc;
36 if (!mt->grabbed)
37 return 0;
38 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0));
39 if (rc < 0)
40 xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n");
41 mt->grabbed = 0;
42}
43
44/******************************************************/
diff --git a/src/mtouch.h b/src/mtouch.h
index a945162..d036a8f 100644
--- a/src/mtouch.h
+++ b/src/mtouch.h
@@ -9,12 +9,14 @@
9struct MTouch { 9struct MTouch {
10 struct Capabilities caps; 10 struct Capabilities caps;
11 struct HWData hw; 11 struct HWData hw;
12 bool grabbed;
12}; 13};
13 14
14//////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////
15 16
16int configure_mtouch(struct MTouch *mt, int fd); 17int configure_mtouch(struct MTouch *mt, int fd);
17int init_mtouch(struct MTouch *mt); 18int open_mtouch(struct MTouch *mt, int fd);
19void close_mtouch(struct MTouch *mt, int fd);
18 20
19//////////////////////////////////////////////////////// 21////////////////////////////////////////////////////////
20 22
diff --git a/src/multitouch.c b/src/multitouch.c
index 9fb6d82..73aaffd 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -27,39 +27,44 @@
27 27
28static int device_init(LocalDevicePtr local) 28static int device_init(LocalDevicePtr local)
29{ 29{
30 struct MTouch *mt = local->private; 30 struct MTouch *mt = local->private;
31 local->fd = xf86OpenSerial(local->options); 31 local->fd = xf86OpenSerial(local->options);
32 if (local->fd < 0) { 32 if (local->fd < 0) {
33 xf86Msg(X_ERROR, "multitouch: cannot configure device\n"); 33 xf86Msg(X_ERROR, "multitouch: cannot configure device\n");
34 return local->fd; 34 return local->fd;
35 } 35 }
36 if (configure_mtouch(mt, local->fd)) 36 if (configure_mtouch(mt, local->fd))
37 return -1; 37 return -1;
38 xf86CloseSerial(local->fd); 38 xf86CloseSerial(local->fd);
39 return 0; 39 return 0;
40} 40}
41 41
42//////////////////////////////////////////////////////////////////////////// 42////////////////////////////////////////////////////////////////////////////
43 43
44static int device_on(LocalDevicePtr local) 44static int device_on(LocalDevicePtr local)
45{ 45{
46 struct MTouch *mt = local->private; 46 struct MTouch *mt = local->private;
47 local->fd = xf86OpenSerial(local->options); 47 local->fd = xf86OpenSerial(local->options);
48 if (local->fd < 0) { 48 if (local->fd < 0) {
49 xf86Msg(X_ERROR, "multitouch: cannot open device\n"); 49 xf86Msg(X_ERROR, "multitouch: cannot open device\n");
50 return local->fd; 50 return local->fd;
51 } 51 }
52 if (init_mtouch(mt)) 52 if (open_mtouch(mt, local->fd))
53 return -1; 53 return -1;
54 return 0; 54 xf86AddEnabledDevice(local);
55 return 0;
55} 56}
56 57
57//////////////////////////////////////////////////////////////////////////// 58////////////////////////////////////////////////////////////////////////////
58 59
59static void device_off(LocalDevicePtr local) 60static void device_off(LocalDevicePtr local)
60{ 61{
61 if(local->fd >= 0) 62 struct MTouch *mt = local->private;
62 xf86CloseSerial(local->fd); 63 if(local->fd < 0)
64 return;
65 xf86RemoveEnabledDevice(local);
66 close_mtouch(mt, local->fd);
67 xf86CloseSerial(local->fd);
63} 68}
64 69
65//////////////////////////////////////////////////////////////////////////// 70////////////////////////////////////////////////////////////////////////////
@@ -73,15 +78,15 @@ static void device_close(LocalDevicePtr local)
73/* called for each full received packet from the touchpad */ 78/* called for each full received packet from the touchpad */
74static void read_input(LocalDevicePtr local) 79static void read_input(LocalDevicePtr local)
75{ 80{
76 struct MTouch *mt = local->private; 81 struct MTouch *mt = local->private;
77 82
78 xf86Msg(X_INFO, "read_input called\n"); 83 xf86Msg(X_INFO, "read_input called\n");
79 84
80 if (local->fd >= 0) { 85 if (local->fd >= 0) {
81 while (!read_hwdata(&mt->hw, local->fd)) { 86 while (!read_hwdata(&mt->hw, local->fd)) {
82 // do all the good stuff here 87 // do all the good stuff here
83 } 88 }
84 } 89 }
85} 90}
86 91
87//////////////////////////////////////////////////////////////////////////// 92////////////////////////////////////////////////////////////////////////////
@@ -154,32 +159,32 @@ static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags)
154//////////////////////////////////////////////////////////////////////////// 159////////////////////////////////////////////////////////////////////////////
155 160
156static InputDriverRec MULTITOUCH = { 161static InputDriverRec MULTITOUCH = {
157 1, 162 1,
158 "multitouch", 163 "multitouch",
159 NULL, 164 NULL,
160 preinit, 165 preinit,
161 uninit, 166 uninit,
162 NULL, 167 NULL,
163 0 168 0
164}; 169};
165 170
166static XF86ModuleVersionInfo VERSION = { 171static XF86ModuleVersionInfo VERSION = {
167 "multitouch", 172 "multitouch",
168 MODULEVENDORSTRING, 173 MODULEVENDORSTRING,
169 MODINFOSTRING1, 174 MODINFOSTRING1,
170 MODINFOSTRING2, 175 MODINFOSTRING2,
171 XORG_VERSION_CURRENT, 176 XORG_VERSION_CURRENT,
172 0, 1, 0, 177 0, 1, 0,
173 ABI_CLASS_XINPUT, 178 ABI_CLASS_XINPUT,
174 ABI_XINPUT_VERSION, 179 ABI_XINPUT_VERSION,
175 MOD_CLASS_XINPUT, 180 MOD_CLASS_XINPUT,
176 {0, 0, 0, 0} 181 {0, 0, 0, 0}
177}; 182};
178 183
179static pointer setup(pointer module, pointer options, int *errmaj, int *errmin) 184static pointer setup(pointer module, pointer options, int *errmaj, int *errmin)
180{ 185{
181 xf86AddInputDriver(&MULTITOUCH, module, 0); 186 xf86AddInputDriver(&MULTITOUCH, module, 0);
182 return module; 187 return module;
183} 188}
184 189
185XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL }; 190XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL };