summaryrefslogtreecommitdiff
path: root/src/multitouch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/multitouch.c')
-rw-r--r--src/multitouch.c103
1 files changed, 54 insertions, 49 deletions
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 };