summaryrefslogtreecommitdiff
path: root/recipes/xorg-xserver/xserver-kdrive-xomap/calibrateext.patch
blob: c5997c2ffa470808d98fc28f00f4baeff380d05c (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
---
 configure    |38107 -----------------------------------------------------------
 configure.ac            |    2 -
 hw/kdrive/linux/tslib.c |   68 ++++++++++++++++++++++++++----------------------
 2 files changed, 39 insertions(+), 31 deletions(-)


Index: xorg-server-1.1.99.3/hw/kdrive/linux/tslib.c
===================================================================
--- xorg-server-1.1.99.3.orig/hw/kdrive/linux/tslib.c	2007-01-30 00:44:13.000000000 +0000
+++ xorg-server-1.1.99.3/hw/kdrive/linux/tslib.c	2007-01-30 21:55:52.000000000 +0000
@@ -47,6 +47,10 @@
 
 #define TSLIB_QUEUE_SIZE 3
 
+/* For XCalibrate extension */
+void (*tslib_raw_event_hook)(int x, int y, int pressure, void *closure);
+void *tslib_raw_event_closure;
+
 struct TslibPrivate {
     int fd;
     int lastx, lasty;
@@ -76,6 +80,19 @@ TsRead (int fd, void *closure)
     unsigned long       flags = 0;
     int                 discard = 0;
 
+    if (tslib_raw_event_hook)
+      {
+	/* XCalibrate Ext */
+	if (ts_read_raw(private->tsDev, &event, 1) == 1)
+	  {
+	    tslib_raw_event_hook (event.x, 
+				  event.y, 
+				  event.pressure, 
+				  tslib_raw_event_closure);
+	  }
+	return;
+      }
+
     if (!private->tsDev) {
         DebugF("[tslib] EXTREME BADNESS: TsRead called while tsDev is null!\n");
         return;
@@ -322,14 +339,14 @@ TsRead (int fd, void *closure)
     }
 }
 
-/* must always be NULL-terminated. */
-char *valid_ts_names[] = {
-    "ADS784x Touchscreen",
-    "omap-ts",
-    "TSC2301 touchscreen",
-    NULL
+static char *TsNames[] = {
+  NULL, 			/* set via TSLIB_TSDEVICE */
+  "/dev/ts",	
+  "/dev/touchscreen/0",
 };
 
+#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
+
 #define TS_NAME_SIZE 32
 
 static Status
@@ -383,11 +400,10 @@ TslibDisable (KdPointerInfo *pi)
     private->tsDev = NULL;
 }
 
-
 static Status
 TslibInit (KdPointerInfo *pi)
 {
-    int		        fd = 0, i = 0;
+    int		        fd = 0, i = 0, j = 0;
     char                devpath[PATH_MAX], devname[TS_NAME_SIZE];
     DIR                 *inputdir = NULL;
     struct dirent       *inputent = NULL;
@@ -397,33 +413,25 @@ TslibInit (KdPointerInfo *pi)
         return !Success;
     
     if (!pi->path || strcmp(pi->path, "auto") == 0) {
-        if (!(inputdir = opendir("/dev/input"))) {
-            ErrorF("[tslib/TslibInit]: couldn't open /dev/input!\n");
-            return BadMatch;
-        }
 
-        while ((inputent = readdir(inputdir))) {
-            if (strncmp(inputent->d_name, "event", 5) != 0)
-                continue;
+        if ((TsNames[0] = getenv("TSLIB_TSDEVICE")) == NULL)
+	  j++;
+      
+	  for (i = j; i < NUM_TS_NAMES; i++)    
+	    {
+              struct tsdev *tsDev;
 
-            snprintf(devpath, PATH_MAX, "/dev/input/%s", inputent->d_name);
-            fd = open(devpath, O_RDWR);
+              if(!(tsDev = ts_open(TsNames[i], 0)))
+                continue;
 
-            if (!ioctl(fd, EVIOCGNAME(sizeof(devname)), devname)) {
-                close(fd);
+              if (ts_config(tsDev))
                 continue;
-            }
-            close(fd);
 
-            for (i = 0; valid_ts_names[i]; i++) {
-                if (strcmp(devname, valid_ts_names[i]) == 0) {
-                    pi->path = KdSaveString(devpath);
-                    break;
-                }
-            }
-        }
-                
-        closedir(inputdir);
+              ts_close(tsDev);
+
+	      pi->path = KdSaveString(TsNames[i]);
+              break;
+	    }
     }
 
     if (!pi->path || strcmp(pi->path, "auto") == 0) {