source: trunk/dports/emulators/pearpc/files/patch-sysx11.cc @ 21479

Last change on this file since 21479 was 21479, checked in by eridius@…, 13 years ago

Massive update to svn properties on files:
All patchfiles have svn:eol-style removed.
All files that are not in fact able to be executed have svn:executable removed
All binary files have svn:eol-style removed (and are probably corrupt)
All binary files have svn:mime-type set to application/octet-stream
All files which are not patchfiles or binary files have svn:eol-style set to native
All Portfiles have svn:eol-style set to native and svn:executable removed

File size: 6.1 KB
Line 
1--- src/system/ui/x11/sysx11.cc 17 Oct 2004 09:53:57 -0000      1.17
2+++ src/system/ui/x11/sysx11.cc 24 Dec 2004 19:36:23 -0000
3@@ -4,6 +4,7 @@
4  *
5  *     Copyright (C) 1999-2002 Stefan Weyergraf
6  *     Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net)
7+ *      Portions Copyright (C) 2004 Apple Computer, Inc.
8  *
9  *     This program is free software; you can redistribute it and/or modify
10  *     it under the terms of the GNU General Public License version 2 as
11@@ -42,24 +43,46 @@
12 Display *      gX11Display = NULL;
13 Window         gX11Window;
14 
15-static uint8 x11_key_to_adb_key[256] = {
16-       // 0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
17-       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x35,0x12,0x13,0x14,0x15,0x17,0x16,
18-       0x1a,0x1c,0x19,0x1d,0x1b,0x18,0x33,0x30,0x0c,0x0d,0x0e,0x0f,0x11,0x10,0x20,0x22,
19-       0x1f,0x23,0x21,0x1e,0x24,0x36,0x00,0x01,0x02,0x03,0x05,0x04,0x26,0x28,0x25,0x29,
20-       0x27,0x32,0x38,0x2a,0x06,0x07,0x08,0x09,0x0b,0x2d,0x2e,0x2b,0x2f,0x2c,0x38,0x43,
21-       0x37,0x31,0xff,0x7a,0x78,0x63,0x76,0x60,0x61,0x62,0x64,0x65,0x6d,0x47,0xff,0x59,
22-       0x5b,0x5c,0x4e,0x56,0x57,0x58,0x45,0x53,0x54,0x55,0x52,0x41,0xff,0xff,0x0a,0x67,
23-       0x6f,0x73,0x3e,0x74,0x3b,0xff,0x3c,0x77,0x3d,0x79,0x72,0x75,0x4c,0x36,0xff,0xff,
24-       0x4b,0x3a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
25+static uint8 x11_latin1_keysym_to_adb_key[256] = {
26+       // Latin 1   Upper Byte = 0x00
27+       // 0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
28        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
29        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
30+       0x31,0xff,0xff,0xff,0xff,0xff,0xff,0x27,0xff,0xff,0xff,0xff,0x2b,0x1b,0x2f,0x2c,
31+       0x1d,0x12,0x13,0x14,0x15,0x17,0x16,0x1a,0x1c,0x19,0xff,0x29,0xff,0x18,0xff,0xff,
32        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
33+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x21,0x2a,0x1e,0xff,0xff,
34+       0x32,0x00,0x0b,0x08,0x02,0x0e,0x03,0x05,0x04,0x22,0x26,0x28,0x25,0x2e,0x2d,0x1f,
35+       0x23,0x0c,0x0f,0x01,0x11,0x20,0x09,0x0d,0x07,0x10,0x06,0xff,0xff,0xff,0xff,0xff,
36        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
37        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
38        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
39        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
40        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
41+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
42+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
43+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
44+};
45+
46+static uint8 x11_function_keysym_to_adb_key[256] = {
47+       // Upper byte = 0xff
48+       // 0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
49+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x33,0x30,0xff,0xff,0xff,0x24,0xff,0xff,
50+       0xff,0xff,0xff,0x71,0x6b,0xff,0xff,0xff,0xff,0xff,0xff,0x35,0xff,0xff,0xff,0xff,
51+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
52+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
53+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
54+       0x73,0x3b,0x3e,0x3c,0x3d,0x74,0x79,0x77,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
55+       0xff,0xff,0xff,0x72,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
56+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47,
57+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4c,0xff,0xff,
58+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
59+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x43,0x45,0xff,0x4e,0x41,0x4b,
60+       0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5b,0x5c,0xff,0xff,0xff,0xff,0x7a,0x78,
61+       0x63,0x76,0x60,0x61,0x62,0x64,0x65,0x6d,0x67,0x6f,0x69,0xff,0xff,0xff,0xff,0xff,
62+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
63+       0xff,0x38,0x38,0x36,0x36,0x39,0xff,0xff,0xff,0x37,0x37,0xff,0xff,0xff,0xff,0xff,
64+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
65 };
66 
67 static void handleX11Event(const XEvent &event)
68@@ -76,40 +99,45 @@
69                gDisplay->displayShow();
70                break;
71        case KeyRelease: {
72-               char buffer[4];
73                SystemEvent ev;
74-               XComposeStatus compose;
75                KeySym keysym;
76 
77-               ev.key.keycode = x11_key_to_adb_key[event.xkey.keycode];
78+               sys_lock_mutex(gX11Mutex);
79+               keysym = XLookupKeysym((XKeyEvent*)&event, 0);
80+               sys_unlock_mutex(gX11Mutex);
81+               if ((keysym & 0xff00) == 0xff00) {
82+                       ev.key.keycode = x11_function_keysym_to_adb_key[keysym & 0x00ff];
83+               } else if ((keysym & 0xff00) == 0x0000) {
84+                       ev.key.keycode = x11_latin1_keysym_to_adb_key[keysym & 0x00ff];
85+               } else {
86+                       ev.key.keycode = 0xff;
87+               }
88+
89                if ((ev.key.keycode & 0xff) == 0xff) break;
90                ev.type = sysevKey;
91                ev.key.pressed = false;
92 
93-               sys_lock_mutex(gX11Mutex);
94-               XLookupString((XKeyEvent*)&event, buffer, sizeof buffer, &keysym, &compose);
95-               sys_unlock_mutex(gX11Mutex);
96-               ev.key.chr = buffer[0];
97-
98                gKeyboard->handleEvent(ev);
99                break;
100        }
101        case KeyPress: {
102-               char buffer[4];
103-               XComposeStatus compose;
104                KeySym keysym;
105-
106                SystemEvent ev;
107-               ev.key.keycode = x11_key_to_adb_key[event.xkey.keycode];
108-               if ((ev.key.keycode & 0xff) == 0xff) break;
109-               ev.type = sysevKey;
110-               ev.key.pressed = true;
111-               ev.key.keycode = x11_key_to_adb_key[event.xkey.keycode];
112 
113                sys_lock_mutex(gX11Mutex);
114-               XLookupString((XKeyEvent*)&event, buffer, sizeof buffer, &keysym, &compose);
115+               keysym = XLookupKeysym((XKeyEvent*)&event, 0);
116                sys_unlock_mutex(gX11Mutex);
117-               ev.key.chr = buffer[0];
118+               if ((keysym & 0xff00) == 0xff00) {
119+                       ev.key.keycode = x11_function_keysym_to_adb_key[keysym & 0x00ff];
120+               } else if ((keysym & 0xff00) == 0x0000) {
121+                       ev.key.keycode = x11_latin1_keysym_to_adb_key[keysym & 0x00ff];
122+               } else {
123+                       ev.key.keycode = 0xff;
124+               }
125+
126+               if ((ev.key.keycode & 0xff) == 0xff) break;
127+               ev.type = sysevKey;
128+               ev.key.pressed = true;
129 
130                gKeyboard->handleEvent(ev);
131                break;
Note: See TracBrowser for help on using the repository browser.