summaryrefslogtreecommitdiff
path: root/packages/xorg-xserver/xserver-kdrive-1.3.0.0/linux-keyboard-mediumraw.patch
blob: 997028ad8d63cf503ec8d781bb03169efafd7b7f (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
Index: xorg-server-1.3.0.0/hw/kdrive/linux/keyboard.c
===================================================================
--- xorg-server-1.3.0.0.orig/hw/kdrive/linux/keyboard.c	2006-11-16 18:01:23.000000000 +0000
+++ xorg-server-1.3.0.0/hw/kdrive/linux/keyboard.c	2007-08-12 12:14:29.000000000 +0000
@@ -384,14 +384,35 @@
 LinuxKeyboardRead (int fd, void *closure)
 {
     unsigned char   buf[256], *b;
-    int		    n;
+    int		    n, mediumraw_data, mediumraw_event;
+    static enum { LOWKEY, BYTE1, BYTE2 } mediumraw_state = LOWKEY;
 
     while ((n = read (fd, buf, sizeof (buf))) > 0)
     {
 	b = buf;
 	while (n--)
 	{
-	    KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
+	    switch (mediumraw_state)
+	    {
+	    case LOWKEY:
+		if ( (b[0] & 0x7f) == 0)
+		{
+		    mediumraw_state = BYTE1;
+		    mediumraw_event = b[0] & 0x80;
+		}
+		else
+		    KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
+		break;
+	    case BYTE1:
+		mediumraw_data = (b[0] & 0x7f) << 7;
+		mediumraw_state = BYTE2;
+		break;
+	    case BYTE2:
+		/* FIXME: KdEnqueueKeyboardEvent should accept word size */
+		KdEnqueueKeyboardEvent ( mediumraw_data | (b[0] & 0x7f), mediumraw_event);
+		mediumraw_state = LOWKEY;
+		break;
+	    }
 	    b++;
 	}
     }
Index: xorg-server-1.3.0.0/hw/xfree86/os-support/linux/lnx_kbd.c
===================================================================
--- xorg-server-1.3.0.0.orig/hw/xfree86/os-support/linux/lnx_kbd.c	2006-11-16 18:01:25.000000000 +0000
+++ xorg-server-1.3.0.0/hw/xfree86/os-support/linux/lnx_kbd.c	2007-08-12 12:14:29.000000000 +0000
@@ -430,12 +430,32 @@
 {
     KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
     unsigned char rBuf[64];
-    int nBytes, i;
+    int nBytes, i, mediumraw_data, mediumraw_event;
+    static enum { LOWKEY, BYTE1, BYTE2 } mediumraw_state = LOWKEY;
     if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-       for (i = 0; i < nBytes; i++)
-           pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
-                           rBuf[i] & 0x80 ? FALSE : TRUE);
+       for (i = 0; i < nBytes; i++) {
+           switch (mediumraw_state) {
+           case LOWKEY:
+               if ( (rBuf[i] & 0x7f) == 0) {
+                   mediumraw_state = BYTE1;
+                   mediumraw_event = rBuf[i] & 0x80;
+               }
+               else
+                   pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
+                                   rBuf[i] & 0x80 ? FALSE : TRUE);
+               break;
+           case BYTE1:
+               mediumraw_data = (rBuf[i] & 0x7f) << 7;
+               mediumraw_state = BYTE2;
+               break;
+           case BYTE2:
+               pKbd->PostEvent(pInfo, mediumraw_data | (rBuf[i] & 0x7f),
+                               mediumraw_event ? FALSE : TRUE);
+               mediumraw_state = LOWKEY;
+               break;
+           }
        }
+    }
 }
 
 static Bool