annotate src/events/SDL_keyboard.c @ 4222:6823a52d06fa SDL-1.2

Fixed bug #714 fuzzyTew@gmail.com 2009-03-14 15:18:45 PDT Created an attachment (id=305) [details] patch to change HAVE_ICONV to HAVE_ICONV_H There are two separate iconv checks in configure -- one for the header file and one for the library. include/SDL_stdinc.h uses the library define to see whether or not it should reference the types defined in the header, which naturally breaks if the library exists and the header does not.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 21 Sep 2009 11:04:32 +0000
parents 3b7fc3416601
children 0ca47eaff9c9
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 4138
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1283
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 223
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 /* General keyboard handling code for SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
26 #include "SDL_timer.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include "SDL_sysevents.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 /* Global keystate information */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 static Uint8 SDL_KeyState[SDLK_LAST];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 static SDLMod SDL_ModState;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 int SDL_TranslateUNICODE = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36
1612
97d0966f4bf7 Fixed some ultra-pedantic gcc warnings
Sam Lantinga <slouken@libsdl.org>
parents: 1507
diff changeset
37 static const char *keynames[SDLK_LAST]; /* Array of keycode names */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 * jk 991215 - added
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 struct {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 int firsttime; /* if we check against the delay or repeat value */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 int delay; /* the delay before we start repeating */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 int interval; /* the delay between key repeat events */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 Uint32 timestamp; /* the time the first keydown event occurred */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 SDL_Event evt; /* the event we are supposed to repeat */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 } SDL_KeyRepeat;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
51 /* Global no-lock-keys support */
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
52 static Uint8 SDL_NoLockKeys;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
53
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
54 #define SDL_NLK_CAPS 0x01
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
55 #define SDL_NLK_NUM 0x02
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
56
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 /* Public functions */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 int SDL_KeyboardInit(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 {
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
60 const char* env;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 SDL_VideoDevice *video = current_video;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 SDL_VideoDevice *this = current_video;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 /* Set default mode of UNICODE translation */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 /* Initialize the tables */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 SDL_ModState = KMOD_NONE;
1760
a9be6a3a51d1 Patch from Dmitry Yakimov to fix building on WinCE
Sam Lantinga <slouken@libsdl.org>
parents: 1612
diff changeset
69 SDL_memset((void*)keynames, 0, sizeof(keynames));
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
70 SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 video->InitOSKeymap(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 SDL_EnableKeyRepeat(0, 0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
75 /* Allow environment override to disable special lock-key behavior */
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents: 4159
diff changeset
76 env = SDL_getenv("SDL_NO_LOCK_KEYS");
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
77 SDL_NoLockKeys = 0;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
78 if (env) {
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
79 switch (SDL_atoi(env)) {
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
80 case 1:
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
81 SDL_NoLockKeys = SDL_NLK_CAPS | SDL_NLK_NUM;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
82 break;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
83 case 2:
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
84 SDL_NoLockKeys = SDL_NLK_CAPS;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
85 break;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
86 case 3:
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
87 SDL_NoLockKeys = SDL_NLK_NUM;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
88 break;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
89 default:
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
90 break;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
91 }
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
92 }
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
93
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 /* Fill in the blanks in keynames */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 keynames[SDLK_BACKSPACE] = "backspace";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 keynames[SDLK_TAB] = "tab";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 keynames[SDLK_CLEAR] = "clear";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 keynames[SDLK_RETURN] = "return";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 keynames[SDLK_PAUSE] = "pause";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 keynames[SDLK_ESCAPE] = "escape";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 keynames[SDLK_SPACE] = "space";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 keynames[SDLK_EXCLAIM] = "!";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 keynames[SDLK_QUOTEDBL] = "\"";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 keynames[SDLK_HASH] = "#";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 keynames[SDLK_DOLLAR] = "$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 keynames[SDLK_AMPERSAND] = "&";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 keynames[SDLK_QUOTE] = "'";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 keynames[SDLK_LEFTPAREN] = "(";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 keynames[SDLK_RIGHTPAREN] = ")";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 keynames[SDLK_ASTERISK] = "*";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 keynames[SDLK_PLUS] = "+";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 keynames[SDLK_COMMA] = ",";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 keynames[SDLK_MINUS] = "-";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 keynames[SDLK_PERIOD] = ".";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 keynames[SDLK_SLASH] = "/";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 keynames[SDLK_0] = "0";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 keynames[SDLK_1] = "1";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 keynames[SDLK_2] = "2";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 keynames[SDLK_3] = "3";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 keynames[SDLK_4] = "4";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 keynames[SDLK_5] = "5";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 keynames[SDLK_6] = "6";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 keynames[SDLK_7] = "7";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 keynames[SDLK_8] = "8";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 keynames[SDLK_9] = "9";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 keynames[SDLK_COLON] = ":";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 keynames[SDLK_SEMICOLON] = ";";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 keynames[SDLK_LESS] = "<";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 keynames[SDLK_EQUALS] = "=";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 keynames[SDLK_GREATER] = ">";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 keynames[SDLK_QUESTION] = "?";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 keynames[SDLK_AT] = "@";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 keynames[SDLK_LEFTBRACKET] = "[";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 keynames[SDLK_BACKSLASH] = "\\";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 keynames[SDLK_RIGHTBRACKET] = "]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 keynames[SDLK_CARET] = "^";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 keynames[SDLK_UNDERSCORE] = "_";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 keynames[SDLK_BACKQUOTE] = "`";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 keynames[SDLK_a] = "a";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 keynames[SDLK_b] = "b";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 keynames[SDLK_c] = "c";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 keynames[SDLK_d] = "d";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 keynames[SDLK_e] = "e";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 keynames[SDLK_f] = "f";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 keynames[SDLK_g] = "g";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 keynames[SDLK_h] = "h";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 keynames[SDLK_i] = "i";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 keynames[SDLK_j] = "j";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 keynames[SDLK_k] = "k";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 keynames[SDLK_l] = "l";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 keynames[SDLK_m] = "m";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 keynames[SDLK_n] = "n";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 keynames[SDLK_o] = "o";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 keynames[SDLK_p] = "p";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 keynames[SDLK_q] = "q";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 keynames[SDLK_r] = "r";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 keynames[SDLK_s] = "s";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 keynames[SDLK_t] = "t";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 keynames[SDLK_u] = "u";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 keynames[SDLK_v] = "v";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 keynames[SDLK_w] = "w";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 keynames[SDLK_x] = "x";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 keynames[SDLK_y] = "y";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 keynames[SDLK_z] = "z";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 keynames[SDLK_DELETE] = "delete";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 keynames[SDLK_WORLD_0] = "world 0";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 keynames[SDLK_WORLD_1] = "world 1";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 keynames[SDLK_WORLD_2] = "world 2";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 keynames[SDLK_WORLD_3] = "world 3";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 keynames[SDLK_WORLD_4] = "world 4";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 keynames[SDLK_WORLD_5] = "world 5";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 keynames[SDLK_WORLD_6] = "world 6";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 keynames[SDLK_WORLD_7] = "world 7";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 keynames[SDLK_WORLD_8] = "world 8";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 keynames[SDLK_WORLD_9] = "world 9";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 keynames[SDLK_WORLD_10] = "world 10";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 keynames[SDLK_WORLD_11] = "world 11";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 keynames[SDLK_WORLD_12] = "world 12";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 keynames[SDLK_WORLD_13] = "world 13";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 keynames[SDLK_WORLD_14] = "world 14";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 keynames[SDLK_WORLD_15] = "world 15";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 keynames[SDLK_WORLD_16] = "world 16";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 keynames[SDLK_WORLD_17] = "world 17";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 keynames[SDLK_WORLD_18] = "world 18";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 keynames[SDLK_WORLD_19] = "world 19";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 keynames[SDLK_WORLD_20] = "world 20";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 keynames[SDLK_WORLD_21] = "world 21";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 keynames[SDLK_WORLD_22] = "world 22";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 keynames[SDLK_WORLD_23] = "world 23";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 keynames[SDLK_WORLD_24] = "world 24";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 keynames[SDLK_WORLD_25] = "world 25";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 keynames[SDLK_WORLD_26] = "world 26";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 keynames[SDLK_WORLD_27] = "world 27";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 keynames[SDLK_WORLD_28] = "world 28";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 keynames[SDLK_WORLD_29] = "world 29";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 keynames[SDLK_WORLD_30] = "world 30";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 keynames[SDLK_WORLD_31] = "world 31";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 keynames[SDLK_WORLD_32] = "world 32";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 keynames[SDLK_WORLD_33] = "world 33";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 keynames[SDLK_WORLD_34] = "world 34";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 keynames[SDLK_WORLD_35] = "world 35";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 keynames[SDLK_WORLD_36] = "world 36";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 keynames[SDLK_WORLD_37] = "world 37";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 keynames[SDLK_WORLD_38] = "world 38";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 keynames[SDLK_WORLD_39] = "world 39";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 keynames[SDLK_WORLD_40] = "world 40";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 keynames[SDLK_WORLD_41] = "world 41";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 keynames[SDLK_WORLD_42] = "world 42";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 keynames[SDLK_WORLD_43] = "world 43";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 keynames[SDLK_WORLD_44] = "world 44";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 keynames[SDLK_WORLD_45] = "world 45";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 keynames[SDLK_WORLD_46] = "world 46";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 keynames[SDLK_WORLD_47] = "world 47";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 keynames[SDLK_WORLD_48] = "world 48";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 keynames[SDLK_WORLD_49] = "world 49";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 keynames[SDLK_WORLD_50] = "world 50";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 keynames[SDLK_WORLD_51] = "world 51";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 keynames[SDLK_WORLD_52] = "world 52";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 keynames[SDLK_WORLD_53] = "world 53";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 keynames[SDLK_WORLD_54] = "world 54";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 keynames[SDLK_WORLD_55] = "world 55";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
223 keynames[SDLK_WORLD_56] = "world 56";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
224 keynames[SDLK_WORLD_57] = "world 57";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 keynames[SDLK_WORLD_58] = "world 58";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226 keynames[SDLK_WORLD_59] = "world 59";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 keynames[SDLK_WORLD_60] = "world 60";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228 keynames[SDLK_WORLD_61] = "world 61";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 keynames[SDLK_WORLD_62] = "world 62";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 keynames[SDLK_WORLD_63] = "world 63";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 keynames[SDLK_WORLD_64] = "world 64";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232 keynames[SDLK_WORLD_65] = "world 65";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233 keynames[SDLK_WORLD_66] = "world 66";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 keynames[SDLK_WORLD_67] = "world 67";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235 keynames[SDLK_WORLD_68] = "world 68";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
236 keynames[SDLK_WORLD_69] = "world 69";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
237 keynames[SDLK_WORLD_70] = "world 70";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 keynames[SDLK_WORLD_71] = "world 71";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239 keynames[SDLK_WORLD_72] = "world 72";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240 keynames[SDLK_WORLD_73] = "world 73";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 keynames[SDLK_WORLD_74] = "world 74";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 keynames[SDLK_WORLD_75] = "world 75";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 keynames[SDLK_WORLD_76] = "world 76";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 keynames[SDLK_WORLD_77] = "world 77";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 keynames[SDLK_WORLD_78] = "world 78";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 keynames[SDLK_WORLD_79] = "world 79";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 keynames[SDLK_WORLD_80] = "world 80";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 keynames[SDLK_WORLD_81] = "world 81";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 keynames[SDLK_WORLD_82] = "world 82";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 keynames[SDLK_WORLD_83] = "world 83";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 keynames[SDLK_WORLD_84] = "world 84";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 keynames[SDLK_WORLD_85] = "world 85";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 keynames[SDLK_WORLD_86] = "world 86";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 keynames[SDLK_WORLD_87] = "world 87";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 keynames[SDLK_WORLD_88] = "world 88";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 keynames[SDLK_WORLD_89] = "world 89";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 keynames[SDLK_WORLD_90] = "world 90";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 keynames[SDLK_WORLD_91] = "world 91";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 keynames[SDLK_WORLD_92] = "world 92";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 keynames[SDLK_WORLD_93] = "world 93";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 keynames[SDLK_WORLD_94] = "world 94";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 keynames[SDLK_WORLD_95] = "world 95";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 keynames[SDLK_KP0] = "[0]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 keynames[SDLK_KP1] = "[1]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 keynames[SDLK_KP2] = "[2]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 keynames[SDLK_KP3] = "[3]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268 keynames[SDLK_KP4] = "[4]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 keynames[SDLK_KP5] = "[5]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 keynames[SDLK_KP6] = "[6]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 keynames[SDLK_KP7] = "[7]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 keynames[SDLK_KP8] = "[8]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 keynames[SDLK_KP9] = "[9]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 keynames[SDLK_KP_PERIOD] = "[.]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 keynames[SDLK_KP_DIVIDE] = "[/]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 keynames[SDLK_KP_MULTIPLY] = "[*]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 keynames[SDLK_KP_MINUS] = "[-]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 keynames[SDLK_KP_PLUS] = "[+]";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 keynames[SDLK_KP_ENTER] = "enter";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 keynames[SDLK_KP_EQUALS] = "equals";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 keynames[SDLK_UP] = "up";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 keynames[SDLK_DOWN] = "down";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 keynames[SDLK_RIGHT] = "right";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 keynames[SDLK_LEFT] = "left";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 keynames[SDLK_DOWN] = "down";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 keynames[SDLK_INSERT] = "insert";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 keynames[SDLK_HOME] = "home";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 keynames[SDLK_END] = "end";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 keynames[SDLK_PAGEUP] = "page up";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 keynames[SDLK_PAGEDOWN] = "page down";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 keynames[SDLK_F1] = "f1";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 keynames[SDLK_F2] = "f2";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 keynames[SDLK_F3] = "f3";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 keynames[SDLK_F4] = "f4";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 keynames[SDLK_F5] = "f5";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 keynames[SDLK_F6] = "f6";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 keynames[SDLK_F7] = "f7";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 keynames[SDLK_F8] = "f8";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 keynames[SDLK_F9] = "f9";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 keynames[SDLK_F10] = "f10";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 keynames[SDLK_F11] = "f11";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 keynames[SDLK_F12] = "f12";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 keynames[SDLK_F13] = "f13";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 keynames[SDLK_F14] = "f14";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 keynames[SDLK_F15] = "f15";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 keynames[SDLK_NUMLOCK] = "numlock";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 keynames[SDLK_CAPSLOCK] = "caps lock";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 keynames[SDLK_SCROLLOCK] = "scroll lock";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 keynames[SDLK_RSHIFT] = "right shift";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 keynames[SDLK_LSHIFT] = "left shift";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 keynames[SDLK_RCTRL] = "right ctrl";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 keynames[SDLK_LCTRL] = "left ctrl";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 keynames[SDLK_RALT] = "right alt";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 keynames[SDLK_LALT] = "left alt";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 keynames[SDLK_RMETA] = "right meta";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 keynames[SDLK_LMETA] = "left meta";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 keynames[SDLK_LSUPER] = "left super"; /* "Windows" keys */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321 keynames[SDLK_RSUPER] = "right super";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 keynames[SDLK_MODE] = "alt gr";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323 keynames[SDLK_COMPOSE] = "compose";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 keynames[SDLK_HELP] = "help";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 keynames[SDLK_PRINT] = "print screen";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 keynames[SDLK_SYSREQ] = "sys req";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 keynames[SDLK_BREAK] = "break";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 keynames[SDLK_MENU] = "menu";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 keynames[SDLK_POWER] = "power";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 keynames[SDLK_EURO] = "euro";
184
3142d2ac11db Added the Undo key for the Atari keyboard
Sam Lantinga <slouken@libsdl.org>
parents: 122
diff changeset
332 keynames[SDLK_UNDO] = "undo";
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 /* Done. Whew. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 }
1123
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 1021
diff changeset
337 void SDL_KeyboardQuit(void)
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 1021
diff changeset
338 {
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 1021
diff changeset
339 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 /* We lost the keyboard, so post key up messages for all pressed keys */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 void SDL_ResetKeyboard(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 SDL_keysym keysym;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345 SDLKey key;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
347 SDL_memset(&keysym, 0, (sizeof keysym));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349 if ( SDL_KeyState[key] == SDL_PRESSED ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 keysym.sym = key;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351 SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 }
14
c3e9d4a623c1 Fixed stuck keys when changing the video mode
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
354 SDL_KeyRepeat.timestamp = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 int SDL_EnableUNICODE(int enable)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359 int old_mode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 old_mode = SDL_TranslateUNICODE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 if ( enable >= 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363 SDL_TranslateUNICODE = enable;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365 return(old_mode);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
367
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
368 Uint8 * SDL_GetKeyState (int *numkeys)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
369 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
370 if ( numkeys != (int *)0 )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
371 *numkeys = SDLK_LAST;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
372 return(SDL_KeyState);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
373 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374 SDLMod SDL_GetModState (void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
375 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
376 return(SDL_ModState);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
378 void SDL_SetModState (SDLMod modstate)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
379 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
380 SDL_ModState = modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
383 char *SDL_GetKeyName(SDLKey key)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
384 {
1612
97d0966f4bf7 Fixed some ultra-pedantic gcc warnings
Sam Lantinga <slouken@libsdl.org>
parents: 1507
diff changeset
385 const char *keyname;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
386
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
387 keyname = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
388 if ( key < SDLK_LAST ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
389 keyname = keynames[key];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
390 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
391 if ( keyname == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 keyname = "unknown key";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 }
1612
97d0966f4bf7 Fixed some ultra-pedantic gcc warnings
Sam Lantinga <slouken@libsdl.org>
parents: 1507
diff changeset
394 /* FIXME: make this function const in 1.3 */
97d0966f4bf7 Fixed some ultra-pedantic gcc warnings
Sam Lantinga <slouken@libsdl.org>
parents: 1507
diff changeset
395 return (char *)(keyname);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
396 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
397
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
398 /* These are global for SDL_eventloop.c */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
399 int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
400 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401 SDL_Event event;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
402 int posted, repeatable;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403 Uint16 modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
404
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
405 SDL_memset(&event, 0, sizeof(event));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
406
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
407 #if 0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
408 printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym),
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
409 state == SDL_PRESSED ? "pressed" : "released");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
410 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
411 /* Set up the keysym */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
412 modstate = (Uint16)SDL_ModState;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
413
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414 repeatable = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
415
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
416 if ( state == SDL_PRESSED ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
417 keysym->mod = (SDLMod)modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418 switch (keysym->sym) {
1327
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
419 case SDLK_UNKNOWN:
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
420 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
421 case SDLK_NUMLOCK:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
422 modstate ^= KMOD_NUM;
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
423 if ( SDL_NoLockKeys & SDL_NLK_NUM )
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
424 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
425 if ( ! (modstate&KMOD_NUM) )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
426 state = SDL_RELEASED;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
427 keysym->mod = (SDLMod)modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
428 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
429 case SDLK_CAPSLOCK:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
430 modstate ^= KMOD_CAPS;
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
431 if ( SDL_NoLockKeys & SDL_NLK_CAPS )
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
432 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
433 if ( ! (modstate&KMOD_CAPS) )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
434 state = SDL_RELEASED;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
435 keysym->mod = (SDLMod)modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
436 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
437 case SDLK_LCTRL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
438 modstate |= KMOD_LCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
439 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
440 case SDLK_RCTRL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441 modstate |= KMOD_RCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 case SDLK_LSHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
444 modstate |= KMOD_LSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446 case SDLK_RSHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
447 modstate |= KMOD_RSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
449 case SDLK_LALT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450 modstate |= KMOD_LALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 case SDLK_RALT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
453 modstate |= KMOD_RALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
454 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
455 case SDLK_LMETA:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
456 modstate |= KMOD_LMETA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
457 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
458 case SDLK_RMETA:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
459 modstate |= KMOD_RMETA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
460 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 case SDLK_MODE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 modstate |= KMOD_MODE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 repeatable = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
466 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469 switch (keysym->sym) {
1327
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
470 case SDLK_UNKNOWN:
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
471 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 case SDLK_NUMLOCK:
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
473 if ( SDL_NoLockKeys & SDL_NLK_NUM )
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
474 break;
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
475 /* Only send keydown events */
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
476 return(0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
477 case SDLK_CAPSLOCK:
4138
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
478 if ( SDL_NoLockKeys & SDL_NLK_CAPS )
b1fd24d62e55 Date: Tue, 05 Feb 2008 01:41:08 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 1760
diff changeset
479 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
480 /* Only send keydown events */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
481 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
482 case SDLK_LCTRL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
483 modstate &= ~KMOD_LCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
484 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
485 case SDLK_RCTRL:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486 modstate &= ~KMOD_RCTRL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
487 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
488 case SDLK_LSHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489 modstate &= ~KMOD_LSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
490 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
491 case SDLK_RSHIFT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
492 modstate &= ~KMOD_RSHIFT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
493 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
494 case SDLK_LALT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
495 modstate &= ~KMOD_LALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
496 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
497 case SDLK_RALT:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
498 modstate &= ~KMOD_RALT;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
499 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
500 case SDLK_LMETA:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
501 modstate &= ~KMOD_LMETA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
502 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
503 case SDLK_RMETA:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
504 modstate &= ~KMOD_RMETA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
505 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
506 case SDLK_MODE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
507 modstate &= ~KMOD_MODE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
508 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
509 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
510 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
511 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
512 keysym->mod = (SDLMod)modstate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
513 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
514
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
515 /* Figure out what type of event this is */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
516 switch (state) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
517 case SDL_PRESSED:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
518 event.type = SDL_KEYDOWN;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
519 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
520 case SDL_RELEASED:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
521 event.type = SDL_KEYUP;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
522 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
523 * jk 991215 - Added
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
524 */
1021
ddd058103e28 Date: Sun, 2 Jan 2005 18:36:09 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
525 if ( SDL_KeyRepeat.timestamp &&
ddd058103e28 Date: Sun, 2 Jan 2005 18:36:09 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
526 SDL_KeyRepeat.evt.key.keysym.sym == keysym->sym ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
527 SDL_KeyRepeat.timestamp = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
528 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
529 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
530 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
531 /* Invalid state -- bail */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
532 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
533 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
534
1327
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
535 if ( keysym->sym != SDLK_UNKNOWN ) {
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
536 /* Drop events that don't change state */
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
537 if ( SDL_KeyState[keysym->sym] == state ) {
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1123
diff changeset
538 #if 0
1283
f214b6fae45a Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 1282
diff changeset
539 printf("Keyboard event didn't change state - dropped!\n");
1282
217f5d5a49e5 Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents: 1123
diff changeset
540 #endif
1327
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
541 return(0);
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
542 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
543
1327
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
544 /* Update internal keyboard state */
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
545 SDL_ModState = (SDLMod)modstate;
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
546 SDL_KeyState[keysym->sym] = state;
d12a63a8d95a Resolved bug #130
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
547 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
548
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
549 /* Post the event, if desired */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
550 posted = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
551 if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
552 event.key.state = state;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
553 event.key.keysym = *keysym;
223
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
554 /*
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
555 * jk 991215 - Added
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
556 */
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
557 if (repeatable && (SDL_KeyRepeat.delay != 0)) {
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
558 SDL_KeyRepeat.evt = event;
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
559 SDL_KeyRepeat.firsttime = 1;
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
560 SDL_KeyRepeat.timestamp=SDL_GetTicks();
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
561 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
562 if ( (SDL_EventOK == NULL) || SDL_EventOK(&event) ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
563 posted = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
564 SDL_PushEvent(&event);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
565 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
566 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
567 return(posted);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
568 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
569
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
570 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
571 * jk 991215 - Added
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
572 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
573 void SDL_CheckKeyRepeat(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
574 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
575 if ( SDL_KeyRepeat.timestamp ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
576 Uint32 now, interval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
577
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
578 now = SDL_GetTicks();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
579 interval = (now - SDL_KeyRepeat.timestamp);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
580 if ( SDL_KeyRepeat.firsttime ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
581 if ( interval > (Uint32)SDL_KeyRepeat.delay ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
582 SDL_KeyRepeat.timestamp = now;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
583 SDL_KeyRepeat.firsttime = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
584 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
585 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
586 if ( interval > (Uint32)SDL_KeyRepeat.interval ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
587 SDL_KeyRepeat.timestamp = now;
223
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
588 if ( (SDL_EventOK == NULL) || SDL_EventOK(&SDL_KeyRepeat.evt) ) {
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
589 SDL_PushEvent(&SDL_KeyRepeat.evt);
8d370608ba0a Fixed key repeat interactions with event filters (thanks Elmar!)
Sam Lantinga <slouken@libsdl.org>
parents: 184
diff changeset
590 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
591 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
592 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
593 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
594 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
595
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
596 int SDL_EnableKeyRepeat(int delay, int interval)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
597 {
122
8f33e95b43b6 Don't worry about a minimum repeat rate - let the user hang themselves...
Sam Lantinga <slouken@libsdl.org>
parents: 14
diff changeset
598 if ( (delay < 0) || (interval < 0) ) {
8f33e95b43b6 Don't worry about a minimum repeat rate - let the user hang themselves...
Sam Lantinga <slouken@libsdl.org>
parents: 14
diff changeset
599 SDL_SetError("keyboard repeat value less than zero");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
600 return(-1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
601 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
602 SDL_KeyRepeat.firsttime = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
603 SDL_KeyRepeat.delay = delay;
122
8f33e95b43b6 Don't worry about a minimum repeat rate - let the user hang themselves...
Sam Lantinga <slouken@libsdl.org>
parents: 14
diff changeset
604 SDL_KeyRepeat.interval = interval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
605 SDL_KeyRepeat.timestamp = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
606 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
607 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
608
1507
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
609 void SDL_GetKeyRepeat(int *delay, int *interval)
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
610 {
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
611 *delay = SDL_KeyRepeat.delay;
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
612 *interval = SDL_KeyRepeat.interval;
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
613 }
1ff64ad478b2 Fixed bug #112
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
614