annotate src/video/x11/SDL_x11keyboard.c @ 4871:81a6a9f396ba

The title is stored internally as NULL if it's empty, and returned as ""
author Sam Lantinga <slouken@libsdl.org>
date Sun, 29 Aug 2010 16:26:35 -0700
parents ce811c9247da
children 25d4feb7c127
rev   line source
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3667
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_x11video.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "../../events/SDL_keyboard_c.h"
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
27 #include "../../events/scancodes_darwin.h"
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
28 #include "../../events/scancodes_xfree86.h"
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
30 #include <X11/keysym.h>
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
31
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
32 #include "imKStoUCS.h"
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
33
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
34 /* *INDENT-OFF* */
3162
dc1eb82ffdaa Von: Thomas Zimmermann
Sam Lantinga <slouken@libsdl.org>
parents: 3001
diff changeset
35 static const struct {
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
36 KeySym keysym;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
37 SDLKey sdlkey;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
38 } KeySymToSDLKey[] = {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
39 { XK_Return, SDLK_RETURN },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
40 { XK_Escape, SDLK_ESCAPE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
41 { XK_BackSpace, SDLK_BACKSPACE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
42 { XK_Tab, SDLK_TAB },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
43 { XK_Caps_Lock, SDLK_CAPSLOCK },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
44 { XK_F1, SDLK_F1 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
45 { XK_F2, SDLK_F2 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
46 { XK_F3, SDLK_F3 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
47 { XK_F4, SDLK_F4 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
48 { XK_F5, SDLK_F5 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
49 { XK_F6, SDLK_F6 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
50 { XK_F7, SDLK_F7 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
51 { XK_F8, SDLK_F8 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
52 { XK_F9, SDLK_F9 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
53 { XK_F10, SDLK_F10 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
54 { XK_F11, SDLK_F11 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
55 { XK_F12, SDLK_F12 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
56 { XK_Print, SDLK_PRINTSCREEN },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
57 { XK_Scroll_Lock, SDLK_SCROLLLOCK },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
58 { XK_Pause, SDLK_PAUSE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
59 { XK_Insert, SDLK_INSERT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
60 { XK_Home, SDLK_HOME },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
61 { XK_Prior, SDLK_PAGEUP },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
62 { XK_Delete, SDLK_DELETE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
63 { XK_End, SDLK_END },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
64 { XK_Next, SDLK_PAGEDOWN },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
65 { XK_Right, SDLK_RIGHT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
66 { XK_Left, SDLK_LEFT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
67 { XK_Down, SDLK_DOWN },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
68 { XK_Up, SDLK_UP },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
69 { XK_Num_Lock, SDLK_NUMLOCKCLEAR },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
70 { XK_KP_Divide, SDLK_KP_DIVIDE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
71 { XK_KP_Multiply, SDLK_KP_MULTIPLY },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
72 { XK_KP_Subtract, SDLK_KP_MINUS },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
73 { XK_KP_Add, SDLK_KP_PLUS },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
74 { XK_KP_Enter, SDLK_KP_ENTER },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
75 { XK_KP_Delete, SDLK_KP_PERIOD },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
76 { XK_KP_End, SDLK_KP_1 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
77 { XK_KP_Down, SDLK_KP_2 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
78 { XK_KP_Next, SDLK_KP_3 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
79 { XK_KP_Left, SDLK_KP_4 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
80 { XK_KP_Begin, SDLK_KP_5 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
81 { XK_KP_Right, SDLK_KP_6 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
82 { XK_KP_Home, SDLK_KP_7 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
83 { XK_KP_Up, SDLK_KP_8 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
84 { XK_KP_Prior, SDLK_KP_9 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
85 { XK_KP_Insert, SDLK_KP_0 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
86 { XK_KP_Decimal, SDLK_KP_PERIOD },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
87 { XK_KP_1, SDLK_KP_1 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
88 { XK_KP_2, SDLK_KP_2 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
89 { XK_KP_3, SDLK_KP_3 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
90 { XK_KP_4, SDLK_KP_4 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
91 { XK_KP_5, SDLK_KP_5 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
92 { XK_KP_6, SDLK_KP_6 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
93 { XK_KP_7, SDLK_KP_7 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
94 { XK_KP_8, SDLK_KP_8 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
95 { XK_KP_9, SDLK_KP_9 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
96 { XK_KP_0, SDLK_KP_0 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
97 { XK_KP_Decimal, SDLK_KP_PERIOD },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
98 { XK_Hyper_R, SDLK_APPLICATION },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
99 { XK_KP_Equal, SDLK_KP_EQUALS },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
100 { XK_F13, SDLK_F13 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
101 { XK_F14, SDLK_F14 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
102 { XK_F15, SDLK_F15 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
103 { XK_F16, SDLK_F16 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
104 { XK_F17, SDLK_F17 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
105 { XK_F18, SDLK_F18 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
106 { XK_F19, SDLK_F19 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
107 { XK_F20, SDLK_F20 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
108 { XK_F21, SDLK_F21 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
109 { XK_F22, SDLK_F22 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
110 { XK_F23, SDLK_F23 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
111 { XK_F24, SDLK_F24 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
112 { XK_Execute, SDLK_EXECUTE },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
113 { XK_Help, SDLK_HELP },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
114 { XK_Menu, SDLK_MENU },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
115 { XK_Select, SDLK_SELECT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
116 { XK_Cancel, SDLK_STOP },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
117 { XK_Redo, SDLK_AGAIN },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
118 { XK_Undo, SDLK_UNDO },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
119 { XK_Find, SDLK_FIND },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
120 { XK_KP_Separator, SDLK_KP_COMMA },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
121 { XK_Sys_Req, SDLK_SYSREQ },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
122 { XK_Control_L, SDLK_LCTRL },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
123 { XK_Shift_L, SDLK_LSHIFT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
124 { XK_Alt_L, SDLK_LALT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
125 { XK_Meta_L, SDLK_LGUI },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
126 { XK_Super_L, SDLK_LGUI },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
127 { XK_Control_R, SDLK_RCTRL },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
128 { XK_Shift_R, SDLK_RSHIFT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
129 { XK_Alt_R, SDLK_RALT },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
130 { XK_Meta_R, SDLK_RGUI },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
131 { XK_Super_R, SDLK_RGUI },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
132 { XK_Mode_switch, SDLK_MODE },
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
133 };
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
134
3162
dc1eb82ffdaa Von: Thomas Zimmermann
Sam Lantinga <slouken@libsdl.org>
parents: 3001
diff changeset
135 static const struct
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
136 {
3162
dc1eb82ffdaa Von: Thomas Zimmermann
Sam Lantinga <slouken@libsdl.org>
parents: 3001
diff changeset
137 const SDL_scancode const *table;
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
138 int table_size;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
139 } scancode_set[] = {
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
140 { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
141 { xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
2825
620a91b6d263 Date: Tue, 02 Dec 2008 23:38:26 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2323
diff changeset
142 { xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
143 };
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
144 /* *INDENT-OFF* */
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
145
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
146 static SDLKey
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
147 X11_KeyCodeToSDLKey(Display *display, KeyCode keycode)
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
148 {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
149 KeySym keysym;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
150 unsigned int ucs4;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
151 int i;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
152
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
153 keysym = XKeycodeToKeysym(display, keycode, 0);
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
154 if (keysym == NoSymbol) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
155 return SDLK_UNKNOWN;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
156 }
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
157
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
158 ucs4 = X11_KeySymToUcs4(keysym);
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
159 if (ucs4) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
160 return (SDLKey) ucs4;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
161 }
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
162
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
163 for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
164 if (keysym == KeySymToSDLKey[i].keysym) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
165 return KeySymToSDLKey[i].sdlkey;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
166 }
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
167 }
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
168 return SDLK_UNKNOWN;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
169 }
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
170
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
171 int
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 X11_InitKeyboard(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
175 int i, j;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
176 int min_keycode, max_keycode;
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
177 struct {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
178 SDL_scancode scancode;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
179 KeySym keysym;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
180 int value;
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
181 } fingerprint[] = {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
182 { SDL_SCANCODE_HOME, XK_Home, 0 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
183 { SDL_SCANCODE_PAGEUP, XK_Prior, 0 },
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
184 { SDL_SCANCODE_PAGEDOWN, XK_Next, 0 },
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
185 };
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
186 SDL_bool fingerprint_detected;
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
187
2299
a7cbc25071b6 Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents: 2298
diff changeset
188 XAutoRepeatOn(data->display);
a7cbc25071b6 Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents: 2298
diff changeset
189
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
190 /* Try to determine which scancodes are being used based on fingerprint */
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
191 fingerprint_detected = SDL_FALSE;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
192 XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
193 for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
194 fingerprint[i].value =
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
195 XKeysymToKeycode(data->display, fingerprint[i].keysym) -
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
196 min_keycode;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
197 }
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
198 for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
199 /* Make sure the scancode set isn't too big */
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
200 if ((max_keycode - min_keycode + 1) <= scancode_set[i].table_size) {
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
201 continue;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
202 }
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
203 for (j = 0; j < SDL_arraysize(fingerprint); ++j) {
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
204 if (fingerprint[j].value < 0
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
205 || fingerprint[j].value >= scancode_set[i].table_size) {
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
206 break;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
207 }
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
208 if (scancode_set[i].table[fingerprint[j].value] !=
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
209 fingerprint[j].scancode) {
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
210 break;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
211 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
212 }
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
213 if (j == SDL_arraysize(fingerprint)) {
4535
ce811c9247da Added back in a little more debugging for the X11 keyboard code
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
214 #ifdef DEBUG_KEYBOARD
ce811c9247da Added back in a little more debugging for the X11 keyboard code
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
215 printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size);
ce811c9247da Added back in a little more debugging for the X11 keyboard code
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
216 #endif
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
217 SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
218 sizeof(SDL_scancode) * scancode_set[i].table_size);
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
219 fingerprint_detected = SDL_TRUE;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
220 break;
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
221 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
222 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
223
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
224 if (!fingerprint_detected) {
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
225 SDLKey keymap[SDL_NUM_SCANCODES];
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
226
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
227 printf
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
228 ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
229
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
230 /* Determine key_layout - only works on US QWERTY layout */
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
231 SDL_GetDefaultKeymap(keymap);
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
232 for (i = min_keycode; i <= max_keycode; ++i) {
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
233 KeySym sym;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
234 sym = XKeycodeToKeysym(data->display, i, 0);
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
235 if (sym != NoSymbol) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
236 SDLKey key;
3667
cc7eca3a4e13 Fixed compiler warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 3162
diff changeset
237 printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
cc7eca3a4e13 Fixed compiler warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 3162
diff changeset
238 (unsigned int) sym, XKeysymToString(sym));
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
239 key = X11_KeyCodeToSDLKey(data->display, i);
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
240 for (j = 0; j < SDL_arraysize(keymap); ++j) {
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
241 if (keymap[j] == key) {
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
242 data->key_layout[i] = (SDL_scancode) j;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
243 break;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
244 }
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
245 }
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
246 if (j == SDL_arraysize(keymap)) {
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
247 printf("scancode not found\n");
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
248 } else {
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
249 printf("scancode = %d (%s)\n", j, SDL_GetScancodeName(j));
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
250 }
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
251 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
252 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
253 }
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
254
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2305
diff changeset
255 X11_UpdateKeymap(_this);
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
256
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
257 SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
258
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
259 return 0;
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
260 }
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
261
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
262 void
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
263 X11_UpdateKeymap(_THIS)
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
264 {
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
265 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
266 int i;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
267 SDL_scancode scancode;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
268 SDLKey keymap[SDL_NUM_SCANCODES];
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
269
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
270 SDL_zero(keymap);
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
271
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
272 for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
273
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
274 /* Make sure this is a valid scancode */
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
275 scancode = data->key_layout[i];
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
276 if (scancode == SDL_SCANCODE_UNKNOWN) {
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
277 continue;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2299
diff changeset
278 }
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
279
3001
7b031c55aebc Fixed bug #669
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
280 keymap[scancode] = X11_KeyCodeToSDLKey(data->display, (KeyCode)i);
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 1950
diff changeset
281 }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
282 SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 X11_QuitKeyboard(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 /* vi: set ts=4 sw=4 expandtab: */