about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 17:47:42 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 17:47:42 +0000
commit8404143afe48c04e0c84a9bbde08ebf400b7f7fb (patch)
tree555522478fb9ea05bbd4a9dd65c5124874252f13
parent2b9688f3c3085e4fb07906a71bbedb8a6b916a59 (diff)
downloadzcatch-8404143afe48c04e0c84a9bbde08ebf400b7f7fb.tar.gz
zcatch-8404143afe48c04e0c84a9bbde08ebf400b7f7fb.zip
added SDL support
-rw-r--r--default.bam139
-rw-r--r--scripts/SDL_keysym.h311
-rw-r--r--scripts/gen_keys.py49
-rw-r--r--src/engine/client/ec_gfx.c144
-rw-r--r--src/engine/client/ec_inp.c120
-rw-r--r--src/engine/client/ec_snd.c52
-rw-r--r--src/engine/e_keynames.c516
-rw-r--r--src/engine/e_keys.h253
-rw-r--r--src/game/client/components/binds.cpp14
-rw-r--r--src/game/client/components/console.cpp2
10 files changed, 1520 insertions, 80 deletions
diff --git a/default.bam b/default.bam
index 2e9692b1..6fc03da1 100644
--- a/default.bam
+++ b/default.bam
@@ -5,6 +5,7 @@ config:add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-p
 config:add(OptFindLibrary("zlib", "zlib.h", false))
 config:add(OptFindLibrary("glfw", "glfw.h", false))
 config:add(OptFindLibrary("portaudio", "portaudio.h_FAIL", false))
+config:add(OptFindLibrary("sdl", "SDL/SDL.h", false))
 
 config:add(OptFindLibrary("coreaudio", "AudioUnit/AudioUnit.h", false))
 config:add(OptFindLibrary("alsa", "alsa/asoundlib.h", false))
@@ -125,7 +126,10 @@ end
 function build(settings)
 	settings.objdir = Path("objs")
 	settings.cc.output = intermediate_output_func
-
+	
+	use_sdl = 1
+	if config.sdl.value == 0 then use_sdl = nil end
+	
 	if config.compiler.value == "cl" then
 		settings.cc.flags = "/wd4244"
 		settings.linker.flags = ""
@@ -164,76 +168,84 @@ function build(settings)
 		settings.linker.libs:add("shell32")
 	end
 	
-	-- build glfw if needed (not tested)
-	if config.glfw.value == 1 then
-		settings.linker.libs:add("glfw")
-		if config.glfw.include_path then
-			settings.cc.includes:add(config.glfw.include_path)
-		end
+	if use_sdl then
 		glfw = {}
+		portaudio = {}
 	else
-		glfw_settings = settings:copy()
-		glfw_settings.cc.includes:add("src/external/glfw/include")
-		glfw_settings.cc.includes:add("src/engine/external/glfw/lib")
-		glfw_settings.cc.includes:add("src/engine/external/glfw/lib/" .. glfw_platform)
-
-		glfw = Compile(glfw_settings, Collect(
-			"src/engine/external/glfw/lib/*.c",
-			"src/engine/external/glfw/lib/" .. glfw_platform .. "/*.c"))
-		
-		settings.cc.includes:add("src/engine/external/glfw/include")
-	end
+		settings.cc.defines:add("CONFIG_NO_SDL")
 		
-	-- build portaudio
-	if config.portaudio.value == 1 then
-		settings.linker.libs:add("portaudio")
-		if config.portaudio.include_path then
-			settings.cc.includes:add(config.portaudio.include_path)
+		-- build glfw if needed (not tested)
+		if config.glfw.value == 1 then
+			settings.linker.libs:add("glfw")
+			if config.glfw.include_path then
+				settings.cc.includes:add(config.glfw.include_path)
+			end
+			glfw = {}
+		else
+			glfw_settings = settings:copy()
+			glfw_settings.cc.includes:add("src/external/glfw/include")
+			glfw_settings.cc.includes:add("src/engine/external/glfw/lib")
+			glfw_settings.cc.includes:add("src/engine/external/glfw/lib/" .. glfw_platform)
+
+			glfw = Compile(glfw_settings, Collect(
+				"src/engine/external/glfw/lib/*.c",
+				"src/engine/external/glfw/lib/" .. glfw_platform .. "/*.c"))
+			
+			settings.cc.includes:add("src/engine/external/glfw/include")
 		end
-		portaudio = {}
-	else
-		pa_settings = settings:copy()
 
-		pa_hostapis = {}		
-		if config.alsa.value == 1 then pa_hostapis["alsa"] = 1 end
-		if config.dsound.value == 1 then
-			pa_hostapis["dsound"] = 1
+		-- build portaudio
+		if config.portaudio.value == 1 then
+			settings.linker.libs:add("portaudio")
+			if config.portaudio.include_path then
+				settings.cc.includes:add(config.portaudio.include_path)
+			end
+			portaudio = {}
 		else
-			pa_settings.cc.defines:add("PA_NO_DS")
-		end
-		if config.coreaudio.value == 1 then pa_hostapis["coreaudio"] = 1 end
-		
-		if config.oss_sys.value == 1 then
-			pa_hostapis["oss"] = 1
-			pa_settings.cc.defines:add("HAVE_SYS_SOUNDCARD_H")
-		elseif config.oss_linux.value == 1 then
-			pa_hostapis["oss"] = 1
-			pa_settings.cc.defines:add("HAVE_LINUX_SOUNDCARD_H")
-		elseif config.oss_machine.value == 1 then
-			pa_hostapis["oss"] = 1
-			pa_settings.cc.defines:add("HAVE_MACHINE_SOUNDCARD_H")
-		end
-		
-		pa_settings.cc.defines:add("PA_NO_WMME")
-		pa_settings.cc.defines:add("PA_NO_ASIO")
-		pa_settings.cc.includes:add("src/engine/external/portaudio/include")
-		pa_settings.cc.includes:add("src/engine/external/portaudio/src/common")
-		pa_settings.cc.includes:add("src/engine/external/portaudio/src/os/" .. pa_platform)
-		
-		pa_api_files = {}
-		for api,v in pa_hostapis do
-			pa_settings.cc.defines:add("PA_USE_"..string.upper(api))
-			pa_api_files[api] = Collect("src/engine/external/portaudio/src/hostapi/" .. api .. "/*.c")
-		end
-		
-		portaudio = Compile(pa_settings,
-			Collect("src/engine/external/portaudio/src/common/*.c"),
-			Collect("src/engine/external/portaudio/src/os/" .. pa_platform .. "/*.c"),
-			pa_api_files)
-		
-		settings.cc.includes:add("src/engine/external/portaudio/include")
+			pa_settings = settings:copy()
+
+			pa_hostapis = {}		
+			if config.alsa.value == 1 then pa_hostapis["alsa"] = 1 end
+			if config.dsound.value == 1 then
+				pa_hostapis["dsound"] = 1
+			else
+				pa_settings.cc.defines:add("PA_NO_DS")
+			end
+			if config.coreaudio.value == 1 then pa_hostapis["coreaudio"] = 1 end
+			
+			if config.oss_sys.value == 1 then
+				pa_hostapis["oss"] = 1
+				pa_settings.cc.defines:add("HAVE_SYS_SOUNDCARD_H")
+			elseif config.oss_linux.value == 1 then
+				pa_hostapis["oss"] = 1
+				pa_settings.cc.defines:add("HAVE_LINUX_SOUNDCARD_H")
+			elseif config.oss_machine.value == 1 then
+				pa_hostapis["oss"] = 1
+				pa_settings.cc.defines:add("HAVE_MACHINE_SOUNDCARD_H")
+			end
+			
+			pa_settings.cc.defines:add("PA_NO_WMME")
+			pa_settings.cc.defines:add("PA_NO_ASIO")
+			pa_settings.cc.includes:add("src/engine/external/portaudio/include")
+			pa_settings.cc.includes:add("src/engine/external/portaudio/src/common")
+			pa_settings.cc.includes:add("src/engine/external/portaudio/src/os/" .. pa_platform)
+			
+			pa_api_files = {}
+			for api,v in pa_hostapis do
+				pa_settings.cc.defines:add("PA_USE_"..string.upper(api))
+				pa_api_files[api] = Collect("src/engine/external/portaudio/src/hostapi/" .. api .. "/*.c")
+			end
+			
+			portaudio = Compile(pa_settings,
+				Collect("src/engine/external/portaudio/src/common/*.c"),
+				Collect("src/engine/external/portaudio/src/os/" .. pa_platform .. "/*.c"),
+				pa_api_files)
+			
+			settings.cc.includes:add("src/engine/external/portaudio/include")
+		end		
 	end
 	
+	
 	-- compile zlib if needed
 	if config.zlib.value == 1 then
 		settings.linker.libs:add("z")
@@ -291,6 +303,7 @@ function build(settings)
 			client_settings.linker.libs:add("X11")
 			client_settings.linker.libs:add("GL")
 			client_settings.linker.libs:add("GLU")
+			if use_sdl then client_settings.linker.libs:add("SDL") end
 		end
 	elseif family == "windows" then
 		client_settings.linker.libs:add("opengl32")
diff --git a/scripts/SDL_keysym.h b/scripts/SDL_keysym.h
new file mode 100644
index 00000000..ff44a035
--- /dev/null
+++ b/scripts/SDL_keysym.h
@@ -0,0 +1,311 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#ifndef _SDL_keysym_h
+#define _SDL_keysym_h
+
+/* What we really want is a mapping of every raw key on the keyboard.
+   To support international keyboards, we use the range 0xA1 - 0xFF
+   as international virtual keycodes.  We'll follow in the footsteps of X11...
+   The names of the keys
+ */
+ 
+typedef enum {
+	/* The keyboard syms have been cleverly chosen to map to ASCII */
+	SDLK_UNKNOWN		= 0,
+	SDLK_FIRST		= 0,
+	SDLK_BACKSPACE		= 8,
+	SDLK_TAB		= 9,
+	SDLK_CLEAR		= 12,
+	SDLK_RETURN		= 13,
+	SDLK_PAUSE		= 19,
+	SDLK_ESCAPE		= 27,
+	SDLK_SPACE		= 32,
+	SDLK_EXCLAIM		= 33,
+	SDLK_QUOTEDBL		= 34,
+	SDLK_HASH		= 35,
+	SDLK_DOLLAR		= 36,
+	SDLK_AMPERSAND		= 38,
+	SDLK_QUOTE		= 39,
+	SDLK_LEFTPAREN		= 40,
+	SDLK_RIGHTPAREN		= 41,
+	SDLK_ASTERISK		= 42,
+	SDLK_PLUS		= 43,
+	SDLK_COMMA		= 44,
+	SDLK_MINUS		= 45,
+	SDLK_PERIOD		= 46,
+	SDLK_SLASH		= 47,
+	SDLK_0			= 48,
+	SDLK_1			= 49,
+	SDLK_2			= 50,
+	SDLK_3			= 51,
+	SDLK_4			= 52,
+	SDLK_5			= 53,
+	SDLK_6			= 54,
+	SDLK_7			= 55,
+	SDLK_8			= 56,
+	SDLK_9			= 57,
+	SDLK_COLON		= 58,
+	SDLK_SEMICOLON		= 59,
+	SDLK_LESS		= 60,
+	SDLK_EQUALS		= 61,
+	SDLK_GREATER		= 62,
+	SDLK_QUESTION		= 63,
+	SDLK_AT			= 64,
+	/* 
+	   Skip uppercase letters
+	 */
+	SDLK_LEFTBRACKET	= 91,
+	SDLK_BACKSLASH		= 92,
+	SDLK_RIGHTBRACKET	= 93,
+	SDLK_CARET		= 94,
+	SDLK_UNDERSCORE		= 95,
+	SDLK_BACKQUOTE		= 96,
+	SDLK_a			= 97,
+	SDLK_b			= 98,
+	SDLK_c			= 99,
+	SDLK_d			= 100,
+	SDLK_e			= 101,
+	SDLK_f			= 102,
+	SDLK_g			= 103,
+	SDLK_h			= 104,
+	SDLK_i			= 105,
+	SDLK_j			= 106,
+	SDLK_k			= 107,
+	SDLK_l			= 108,
+	SDLK_m			= 109,
+	SDLK_n			= 110,
+	SDLK_o			= 111,
+	SDLK_p			= 112,
+	SDLK_q			= 113,
+	SDLK_r			= 114,
+	SDLK_s			= 115,
+	SDLK_t			= 116,
+	SDLK_u			= 117,
+	SDLK_v			= 118,
+	SDLK_w			= 119,
+	SDLK_x			= 120,
+	SDLK_y			= 121,
+	SDLK_z			= 122,
+	SDLK_DELETE		= 127,
+	/* End of ASCII mapped keysyms */
+
+	/* International keyboard syms */
+	SDLK_WORLD_0		= 160,		/* 0xA0 */
+	SDLK_WORLD_1		= 161,
+	SDLK_WORLD_2		= 162,
+	SDLK_WORLD_3		= 163,
+	SDLK_WORLD_4		= 164,
+	SDLK_WORLD_5		= 165,
+	SDLK_WORLD_6		= 166,
+	SDLK_WORLD_7		= 167,
+	SDLK_WORLD_8		= 168,
+	SDLK_WORLD_9		= 169,
+	SDLK_WORLD_10		= 170,
+	SDLK_WORLD_11		= 171,
+	SDLK_WORLD_12		= 172,
+	SDLK_WORLD_13		= 173,
+	SDLK_WORLD_14		= 174,
+	SDLK_WORLD_15		= 175,
+	SDLK_WORLD_16		= 176,
+	SDLK_WORLD_17		= 177,
+	SDLK_WORLD_18		= 178,
+	SDLK_WORLD_19		= 179,
+	SDLK_WORLD_20		= 180,
+	SDLK_WORLD_21		= 181,
+	SDLK_WORLD_22		= 182,
+	SDLK_WORLD_23		= 183,
+	SDLK_WORLD_24		= 184,
+	SDLK_WORLD_25		= 185,
+	SDLK_WORLD_26		= 186,
+	SDLK_WORLD_27		= 187,
+	SDLK_WORLD_28		= 188,
+	SDLK_WORLD_29		= 189,
+	SDLK_WORLD_30		= 190,
+	SDLK_WORLD_31		= 191,
+	SDLK_WORLD_32		= 192,
+	SDLK_WORLD_33		= 193,
+	SDLK_WORLD_34		= 194,
+	SDLK_WORLD_35		= 195,
+	SDLK_WORLD_36		= 196,
+	SDLK_WORLD_37		= 197,
+	SDLK_WORLD_38		= 198,
+	SDLK_WORLD_39		= 199,
+	SDLK_WORLD_40		= 200,
+	SDLK_WORLD_41		= 201,
+	SDLK_WORLD_42		= 202,
+	SDLK_WORLD_43		= 203,
+	SDLK_WORLD_44		= 204,
+	SDLK_WORLD_45		= 205,
+	SDLK_WORLD_46		= 206,
+	SDLK_WORLD_47		= 207,
+	SDLK_WORLD_48		= 208,
+	SDLK_WORLD_49		= 209,
+	SDLK_WORLD_50		= 210,
+	SDLK_WORLD_51		= 211,
+	SDLK_WORLD_52		= 212,
+	SDLK_WORLD_53		= 213,
+	SDLK_WORLD_54		= 214,
+	SDLK_WORLD_55		= 215,
+	SDLK_WORLD_56		= 216,
+	SDLK_WORLD_57		= 217,
+	SDLK_WORLD_58		= 218,
+	SDLK_WORLD_59		= 219,
+	SDLK_WORLD_60		= 220,
+	SDLK_WORLD_61		= 221,
+	SDLK_WORLD_62		= 222,
+	SDLK_WORLD_63		= 223,
+	SDLK_WORLD_64		= 224,
+	SDLK_WORLD_65		= 225,
+	SDLK_WORLD_66		= 226,
+	SDLK_WORLD_67		= 227,
+	SDLK_WORLD_68		= 228,
+	SDLK_WORLD_69		= 229,
+	SDLK_WORLD_70		= 230,
+	SDLK_WORLD_71		= 231,
+	SDLK_WORLD_72		= 232,
+	SDLK_WORLD_73		= 233,
+	SDLK_WORLD_74		= 234,
+	SDLK_WORLD_75		= 235,
+	SDLK_WORLD_76		= 236,
+	SDLK_WORLD_77		= 237,
+	SDLK_WORLD_78		= 238,
+	SDLK_WORLD_79		= 239,
+	SDLK_WORLD_80		= 240,
+	SDLK_WORLD_81		= 241,
+	SDLK_WORLD_82		= 242,
+	SDLK_WORLD_83		= 243,
+	SDLK_WORLD_84		= 244,
+	SDLK_WORLD_85		= 245,
+	SDLK_WORLD_86		= 246,
+	SDLK_WORLD_87		= 247,
+	SDLK_WORLD_88		= 248,
+	SDLK_WORLD_89		= 249,
+	SDLK_WORLD_90		= 250,
+	SDLK_WORLD_91		= 251,
+	SDLK_WORLD_92		= 252,
+	SDLK_WORLD_93		= 253,
+	SDLK_WORLD_94		= 254,
+	SDLK_WORLD_95		= 255,		/* 0xFF */
+
+	/* Numeric keypad */
+	SDLK_KP0		= 256,
+	SDLK_KP1		= 257,
+	SDLK_KP2		= 258,
+	SDLK_KP3		= 259,
+	SDLK_KP4		= 260,
+	SDLK_KP5		= 261,
+	SDLK_KP6		= 262,
+	SDLK_KP7		= 263,
+	SDLK_KP8		= 264,
+	SDLK_KP9		= 265,
+	SDLK_KP_PERIOD		= 266,
+	SDLK_KP_DIVIDE		= 267,
+	SDLK_KP_MULTIPLY	= 268,
+	SDLK_KP_MINUS		= 269,
+	SDLK_KP_PLUS		= 270,
+	SDLK_KP_ENTER		= 271,
+	SDLK_KP_EQUALS		= 272,
+
+	/* Arrows + Home/End pad */
+	SDLK_UP			= 273,
+	SDLK_DOWN		= 274,
+	SDLK_RIGHT		= 275,
+	SDLK_LEFT		= 276,
+	SDLK_INSERT		= 277,
+	SDLK_HOME		= 278,
+	SDLK_END		= 279,
+	SDLK_PAGEUP		= 280,
+	SDLK_PAGEDOWN		= 281,
+
+	/* Function keys */
+	SDLK_F1			= 282,
+	SDLK_F2			= 283,
+	SDLK_F3			= 284,
+	SDLK_F4			= 285,
+	SDLK_F5			= 286,
+	SDLK_F6			= 287,
+	SDLK_F7			= 288,
+	SDLK_F8			= 289,
+	SDLK_F9			= 290,
+	SDLK_F10		= 291,
+	SDLK_F11		= 292,
+	SDLK_F12		= 293,
+	SDLK_F13		= 294,
+	SDLK_F14		= 295,
+	SDLK_F15		= 296,
+
+	/* Key state modifier keys */
+	SDLK_NUMLOCK		= 300,
+	SDLK_CAPSLOCK		= 301,
+	SDLK_SCROLLOCK		= 302,
+	SDLK_RSHIFT		= 303,
+	SDLK_LSHIFT		= 304,
+	SDLK_RCTRL		= 305,
+	SDLK_LCTRL		= 306,
+	SDLK_RALT		= 307,
+	SDLK_LALT		= 308,
+	SDLK_RMETA		= 309,
+	SDLK_LMETA		= 310,
+	SDLK_LSUPER		= 311,		/* Left "Windows" key */
+	SDLK_RSUPER		= 312,		/* Right "Windows" key */
+	SDLK_MODE		= 313,		/* "Alt Gr" key */
+	SDLK_COMPOSE		= 314,		/* Multi-key compose key */
+
+	/* Miscellaneous function keys */
+	SDLK_HELP		= 315,
+	SDLK_PRINT		= 316,
+	SDLK_SYSREQ		= 317,
+	SDLK_BREAK		= 318,
+	SDLK_MENU		= 319,
+	SDLK_POWER		= 320,		/* Power Macintosh power key */
+	SDLK_EURO		= 321,		/* Some european keyboards */
+	SDLK_UNDO		= 322,		/* Atari keyboard has Undo */
+
+	/* Add any other keys here */
+
+	SDLK_LAST
+} SDLKey;
+
+/* Enumeration of valid key mods (possibly OR'd together) */
+typedef enum {
+	KMOD_NONE  = 0x0000,
+	KMOD_LSHIFT= 0x0001,
+	KMOD_RSHIFT= 0x0002,
+	KMOD_LCTRL = 0x0040,
+	KMOD_RCTRL = 0x0080,
+	KMOD_LALT  = 0x0100,
+	KMOD_RALT  = 0x0200,
+	KMOD_LMETA = 0x0400,
+	KMOD_RMETA = 0x0800,
+	KMOD_NUM   = 0x1000,
+	KMOD_CAPS  = 0x2000,
+	KMOD_MODE  = 0x4000,
+	KMOD_RESERVED = 0x8000
+} SDLMod;
+
+#define KMOD_CTRL	(KMOD_LCTRL|KMOD_RCTRL)
+#define KMOD_SHIFT	(KMOD_LSHIFT|KMOD_RSHIFT)
+#define KMOD_ALT	(KMOD_LALT|KMOD_RALT)
+#define KMOD_META	(KMOD_LMETA|KMOD_RMETA)
+
+#endif /* _SDL_keysym_h */
diff --git a/scripts/gen_keys.py b/scripts/gen_keys.py
index 5a2e8f7f..e8f206c3 100644
--- a/scripts/gen_keys.py
+++ b/scripts/gen_keys.py
@@ -7,6 +7,10 @@ lines = [line.strip() for line in file(glfw).readlines()]
 # genereate keys.h file
 f = file("src/engine/e_keys.h", "w")
 
+keynames_sdl = []
+for i in range(0, 512):
+	keynames_sdl += ["&%d"%i]
+	
 keynames = {}
 KEY_MOUSE_FIRST = 256+128
 KEY_MOUSE_WHEEL_DOWN = KEY_MOUSE_FIRST-2
@@ -15,9 +19,9 @@ KEY_MOUSE_WHEEL_UP = KEY_MOUSE_FIRST-1
 print >>f, "#ifndef ENGINE_KEYS_H"
 print >>f, "#define ENGINE_KEYS_H"
 print >>f, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
-print >>f, ""
 print >>f, "enum"
 print >>f, "{"
+print >>f, "#ifdef CONFIG_NO_SDL"
 
 # do keys
 for line in lines:
@@ -60,12 +64,45 @@ for line in lines:
 			# add to keynames
 			exec("%s = %s" % (key, value))
 			exec("keynames[%s] = '%s'" % (value, key))
-
 print >>f, "\tKEY_LAST"
+
+print >>f, "#else"
+
+highestid = 0
+for line in open("scripts/SDL_keysym.h"):
+	l = line.strip().split("=")
+	if len(l) == 2 and "SDLK_" in line:
+		key = l[0].strip().replace("SDLK_", "KEY_")
+		value = int(l[1].split(",")[0].strip())
+		print >>f, "\t%s = %d,"%(key, value)
+		
+		keynames_sdl[value] = key.replace("KEY_", "").lower()
+		
+		if value > highestid:
+			highestid =value
+
+print >>f, "\tKEY_MOUSE_1 = %d,"%(highestid+1); keynames_sdl[highestid+1] = "mouse1"
+print >>f, "\tKEY_MOUSE_2 = %d,"%(highestid+2); keynames_sdl[highestid+2] = "mouse2"
+print >>f, "\tKEY_MOUSE_3 = %d,"%(highestid+3); keynames_sdl[highestid+3] = "mouse3"
+print >>f, "\tKEY_MOUSE_4 = %d,"%(highestid+4); keynames_sdl[highestid+4] = "mouse4"
+print >>f, "\tKEY_MOUSE_5 = %d,"%(highestid+5); keynames_sdl[highestid+5] = "mouse5"
+print >>f, "\tKEY_MOUSE_6 = %d,"%(highestid+6); keynames_sdl[highestid+6] = "mouse6"
+print >>f, "\tKEY_MOUSE_7 = %d,"%(highestid+7); keynames_sdl[highestid+7] = "mouse7"
+print >>f, "\tKEY_MOUSE_8 = %d,"%(highestid+8); keynames_sdl[highestid+8] = "mouse8"
+print >>f, "\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid+9); keynames_sdl[highestid+9] = "mousewheelup"
+print >>f, "\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid+10); keynames_sdl[highestid+10] = "mousewheeldown"
+print >>f, "\tKEY_LAST,"
+
+print >>f, "\tKEY_DEL=KEY_DELETE,"
+print >>f, "\tKEY_ENTER=KEY_RETURN,"
+print >>f, "\tKEY_KP_SUBTRACT=KEY_KP_MINUS,"
+print >>f, "\tKEY_KP_ADD=KEY_KP_PLUS,"
+print >>f, "\tKEY_ESC=KEY_ESCAPE"
+
+print >>f, "#endif"
 print >>f, "};"
 print >>f, ""
 print >>f, "#endif"
-f.close()
 
 
 # generate keynames.c file
@@ -76,6 +113,7 @@ print >>f, "#include <string.h>"
 print >>f, ""
 print >>f, "static const char key_strings[512][16] ="
 print >>f, "{"
+print >>f, "#ifdef CONFIG_NO_SDL"
 for i in range(0, 512):
 	n = "&%d"%i
 	if i >= 48 and i <= 57 or i >= 65 and i <= 90:
@@ -83,7 +121,12 @@ for i in range(0, 512):
 	elif i in keynames:
 		n = keynames[i][4:].lower().replace("_", "")
 	print >>f, "\t\"%s\"," % n
+print >>f, "#else"
+print >>f, ""
+for n in keynames_sdl:
+	print >>f, '\t"%s",'%n
 
+print >>f, "#endif"
 print >>f, "};"
 print >>f, ""
 print >>f, "const char *inp_key_name(int k) { if (k >= 0 && k < 512) return key_strings[k]; else return key_strings[0]; }"
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index 9a1e70bf..6a760be7 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -1,5 +1,13 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <GL/glfw.h>
+
+#ifdef CONFIG_NO_SDL
+	#include <GL/glfw.h>
+#else
+	#include <SDL/SDL.h>
+	#include <GL/gl.h>
+	#include <GL/glu.h>
+#endif
+
 #include <engine/external/pnglite/pnglite.h>
 
 #include <base/system.h>
@@ -77,6 +85,11 @@ static TEXTURE textures[MAX_TEXTURES];
 static int first_free_texture;
 static int memory_usage = 0;
 
+#ifdef CONFIG_NO_SDL
+#else
+	SDL_Surface *screen_surface;
+#endif
+
 
 #if 0
 typedef struct { unsigned char r, g, b, a; } PIXEL;
@@ -289,12 +302,14 @@ static void draw_quad()
 		flush();
 }
 
+#ifdef CONFIG_NO_SDL
 static void screen_resize(int width, int height)
 {
 	screen_width = width;
 	screen_height = height;
 	glViewport(0, 0, screen_width, screen_height);
 }
+#endif
 
 int gfx_init()
 {
@@ -303,7 +318,6 @@ int gfx_init()
 	screen_width = config.gfx_screen_width;
 	screen_height = config.gfx_screen_height;
 
-	glfwInit();
 
 	if(config.dbg_stress)
 	{
@@ -311,6 +325,10 @@ int gfx_init()
 		screen_height = 240;
 	}
 
+
+#ifdef CONFIG_NO_SDL
+	glfwInit();
+
 	/* set antialiasing	*/
 	if(config.gfx_fsaa_samples)
 		glfwOpenWindowHint(GLFW_FSAA_SAMPLES, config.gfx_fsaa_samples);
@@ -357,6 +375,62 @@ int gfx_init()
 	/* We don't want to see the window when we run the stress testing */
 	if(config.dbg_stress)
 		glfwIconifyWindow();
+#else
+	if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0)
+	{
+        dbg_msg("gfx", "Unable to init SDL: %s\n", SDL_GetError());
+        return -1;
+    }
+	
+    atexit(SDL_Quit);
+
+	{
+		const SDL_VideoInfo *info;
+		int flags = SDL_OPENGL;
+		
+		info = SDL_GetVideoInfo();
+
+		/* set flags */
+		flags  = SDL_OPENGL;
+		flags |= SDL_GL_DOUBLEBUFFER;
+		flags |= SDL_HWPALETTE;
+		flags |= SDL_RESIZABLE;
+
+		if(info->hw_available)
+			flags |= SDL_HWSURFACE;
+		else
+			flags |= SDL_SWSURFACE;
+
+		if(info->blit_hw)
+			flags |= SDL_HWACCEL;
+
+		if(config.gfx_fullscreen)
+			flags |= SDL_FULLSCREEN;
+
+		/* set gl attributes */
+		if(config.gfx_fsaa_samples)
+		{
+			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, config.gfx_fsaa_samples);
+		}
+
+		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+		/* set caption */
+		SDL_WM_SetCaption("Teeworlds", "Teeworlds");
+		
+		/* create window */
+		screen_surface = SDL_SetVideoMode(screen_width, screen_height, 0, flags);
+		if(screen_surface == NULL)
+		{
+	        dbg_msg("gfx", "Unable to set video mode: %s\n", SDL_GetError());
+    	    return -1;
+		}
+	}
+	
+	SDL_ShowCursor(0);
+
+#endif
 	
 	/* Init vertices */
 	if (vertices)
@@ -447,12 +521,20 @@ void gfx_mask_op(int mask, int write)
 
 int gfx_window_active()
 {
+#ifdef CONFIG_NO_SDL
 	return glfwGetWindowParam(GLFW_ACTIVE) == GL_TRUE ? 1 : 0;
+#else
+	return 1; /* TODO: SDL*/
+#endif
 }
 
 int gfx_window_open()
 {
+#ifdef CONFIG_NO_SDL
 	return glfwGetWindowParam(GLFW_OPENED) == GL_TRUE ? 1 : 0;
+#else
+	return 1; /* TODO: SDL*/
+#endif
 }
 
 VIDEO_MODE fakemodes[] = {
@@ -490,12 +572,52 @@ int gfx_get_video_modes(VIDEO_MODE *list, int maxcount)
 		return count;
 	}
 	
+#ifdef CONFIG_NO_SDL
 	return glfwGetVideoModes((GLFWvidmode *)list, maxcount);
+#else
+	{
+		/* TODO: fix this code on osx or windows */
+		int num_modes = 0;
+		SDL_Rect **modes;
+			
+		modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
+		if(modes == NULL)
+		{
+			/* no modes */
+		}
+		else if(modes == (SDL_Rect**)-1)
+		{
+			/* all modes */
+		}
+		else
+		{
+			int i;
+			for(i = 0; modes[i]; ++i)
+			{
+				if(num_modes == maxcount)
+					break;
+				list[num_modes].width = modes[i]->w;
+				list[num_modes].height = modes[i]->h;
+				list[num_modes].red = 8;
+				list[num_modes].green = 8;
+				list[num_modes].blue = 8;
+				num_modes++;
+			}
+		}
+	}
+	
+
+	return 1; /* TODO: SDL*/
+#endif	
 }
 
 void gfx_set_vsync(int val)
 {
+#ifdef CONFIG_NO_SDL
 	glfwSwapInterval(val);
+#else
+	/* TODO: SDL*/
+#endif	
 }
 
 int gfx_unload_texture(int index)
@@ -697,8 +819,13 @@ void gfx_shutdown()
 {
 	if (vertices)
 		mem_free(vertices);
+#ifdef CONFIG_NO_SDL
 	glfwCloseWindow();
 	glfwTerminate();
+#else
+	/* TODO: SDL, is this correct? */
+	SDL_Quit();
+#endif	
 }
 
 void gfx_screenshot()
@@ -783,19 +910,26 @@ void gfx_swap()
 	{
 		static PERFORMACE_INFO pscope = {"glfwSwapBuffers", 0};
 		perf_start(&pscope);
+#ifdef CONFIG_NO_SDL
 		glfwSwapBuffers();
+#else
+		SDL_GL_SwapBuffers();
+#endif
 		perf_end();
 	}
 	
 	if(render_enable && config.gfx_finish)
 		glFinish();
 
+#ifdef CONFIG_NO_SDL
 	{
 		static PERFORMACE_INFO pscope = {"glfwPollEvents", 0};
 		perf_start(&pscope);
 		glfwPollEvents();
 		perf_end();
 	}
+#else
+#endif
 }
 
 void gfx_screenshot_direct(const char *filename)
@@ -1350,10 +1484,16 @@ void gfx_clip_disable()
 
 void gfx_minimize()
 {
+#ifdef CONFIG_NO_SDL
 	glfwIconifyWindow();
+#else
+#endif
 }
 
 void gfx_maximize()
 {
+#ifdef CONFIG_NO_SDL
 	glfwRestoreWindow();
+#else
+#endif
 }
diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c
index 00468434..f033ee70 100644
--- a/src/engine/client/ec_inp.c
+++ b/src/engine/client/ec_inp.c
@@ -1,14 +1,25 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <string.h>
-#include <GL/glfw.h>
+#ifdef CONFIG_NO_SDL
+	#include <GL/glfw.h>
+#else
+	#include <SDL/SDL.h>
+#endif
 
 #include <base/system.h>
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 
-static int keyboard_state[2][1024]; /* TODO: fix this!! */
+#ifdef CONFIG_NO_SDL
+static int keyboard_state[2][1024] = {{0}}; /* TODO: fix this!! */
+#else
+static unsigned char keyboard_state[2][1024] = {{0}}; /* TODO: fix this!! */
+#endif
 static int keyboard_current = 0;
+
+#ifdef CONFIG_NO_SDL
 static int keyboard_first = 1;
+#endif
 
 
 static struct
@@ -20,14 +31,16 @@ static struct
 static unsigned char input_state[2][1024] = {{0}, {0}};
 
 static int input_current = 0;
+#ifdef CONFIG_NO_SDL
 static unsigned int last_release = 0;
+#endif
 static unsigned int release_delta = -1;
 
 void inp_mouse_relative(int *x, int *y)
 {
 	static int last_x = 0, last_y = 0;
 	static int last_sens = 100.0f;
-	int nx, ny;
+	int nx = 0, ny = 0;
 	float sens = config.inp_mousesens/100.0f;
 	
 	if(last_sens != config.inp_mousesens)
@@ -37,8 +50,9 @@ void inp_mouse_relative(int *x, int *y)
 		last_sens = config.inp_mousesens;
 	}
 	
-	
+#ifdef CONFIG_NO_SDL
 	glfwGetMousePos(&nx, &ny);
+
 	nx *= sens;
 	ny *= sens;
 	
@@ -46,6 +60,12 @@ void inp_mouse_relative(int *x, int *y)
 	*y = ny-last_y;
 	last_x = nx;
 	last_y = ny;
+#else
+	SDL_GetRelativeMouseState(&nx, &ny);
+
+	*x = nx*sens;
+	*y = ny*sens;
+#endif
 }
 
 enum
@@ -88,6 +108,7 @@ INPUT_EVENT inp_get_event(int index)
 	return input_events[index];
 }
 
+#ifdef CONFIG_NO_SDL
 static void char_callback(int character, int action)
 {
 	if(action == GLFW_PRESS && character < 256)
@@ -177,6 +198,25 @@ void inp_mouse_mode_relative()
 	/*if (!config.gfx_debug_resizable)*/
 	glfwDisable(GLFW_MOUSE_CURSOR);
 }
+#else
+
+void inp_init()
+{
+	SDL_EnableUNICODE(1);
+}
+
+void inp_mouse_mode_absolute()
+{
+	SDL_ShowCursor(1);
+	SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
+void inp_mouse_mode_relative()
+{
+	SDL_ShowCursor(0);
+	SDL_WM_GrabInput(SDL_GRAB_ON);
+}
+#endif
 
 int inp_mouse_doubleclick()
 {
@@ -211,8 +251,9 @@ int inp_button_pressed(int button) { return keyboard_state[keyboard_current][but
 
 void inp_update()
 {
+#ifdef CONFIG_NO_SDL
     int i, v;
-    
+
 	/* clear and begin count on the other one */
 	mem_zero(&input_count[input_current], sizeof(input_count[input_current]));
 	mem_copy(input_state[input_current], input_state[input_current^1], sizeof(input_state[input_current]));
@@ -234,6 +275,75 @@ void inp_update()
 			v = glfwGetKey(i) == GLFW_PRESS ? 1 : 0;
         keyboard_state[keyboard_current][i] = v;
     }
+#else
+	int i;
+	
+	/* clear and begin count on the other one */
+	mem_zero(&input_count[input_current], sizeof(input_count[input_current]));
+	mem_copy(input_state[input_current], input_state[input_current^1], sizeof(input_state[input_current]));
+	input_current^=1;
+	
+	{
+		Uint8 *state = SDL_GetKeyState(&i);
+		if(i >= KEY_LAST)
+			i = KEY_LAST-1;
+		mem_copy(keyboard_state[keyboard_current], state, i);
+	}
+	
+	keyboard_state[keyboard_current][KEY_MOUSE_1] = 0;
+	keyboard_state[keyboard_current][KEY_MOUSE_2] = 0;
+	keyboard_state[keyboard_current][KEY_MOUSE_3] = 0;
+	i = SDL_GetMouseState(NULL, NULL);
+	if(i&SDL_BUTTON(1)) keyboard_state[keyboard_current][KEY_MOUSE_1] = 1;
+	if(i&SDL_BUTTON(2)) keyboard_state[keyboard_current][KEY_MOUSE_2] = 1;
+	if(i&SDL_BUTTON(3)) keyboard_state[keyboard_current][KEY_MOUSE_3] = 1;
+	
+	{
+		SDL_Event event;
+	
+		while(SDL_PollEvent(&event))
+		{
+			int key = -1;
+			int action = INPFLAG_PRESS;
+			switch (event.type)
+			{
+				/* handle keys */
+				case SDL_KEYDOWN:
+					if(event.key.keysym.unicode < 255)
+						add_event(event.key.keysym.unicode, 0, 0);
+					key = event.key.keysym.sym;
+					break;
+				case SDL_KEYUP:
+					action = INPFLAG_RELEASE;
+					key = event.key.keysym.sym;
+					break;
+				
+				/* handle mouse buttons */
+				case SDL_MOUSEBUTTONUP:
+					action = INPFLAG_RELEASE;
+				case SDL_MOUSEBUTTONDOWN:
+					key = KEY_MOUSE_1+event.button.button-1;
+					break;
+					
+				/* other messages */
+				case SDL_QUIT:
+					exit(0);
+			}
+			
+			/* */
+			if(key != -1)
+			{
+				input_count[input_current^1][key].presses++;
+				input_state[input_current^1][key] = 1;
+				add_event(0, key, action);
+			}
+
+		}
+	}
+#endif
+
+	if(inp_key_pressed('q'))
+		exit(1);
 
 	/* handle mouse wheel */
 	/*
diff --git a/src/engine/client/ec_snd.c b/src/engine/client/ec_snd.c
index 9dcbafaa..c3563863 100644
--- a/src/engine/client/ec_snd.c
+++ b/src/engine/client/ec_snd.c
@@ -3,8 +3,14 @@
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 
+#ifdef CONFIG_NO_SDL
+	#include <portaudio.h>
+#else
+	#include <SDL/SDL.h>
+#endif
+
+
 #include <engine/external/wavpack/wavpack.h>
-#include <portaudio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -232,16 +238,24 @@ static void mix(short *final_out, unsigned frames)
 	}
 }
 
+#ifdef CONFIG_NO_SDL
+static PaStream *stream;
 static int pacallback(const void *in, void *out, unsigned long frames, const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags status, void *user)
 {
 	mix(out, frames);
 	return 0;
 }
+#else
+static void sdlcallback(void *unused, Uint8 *stream, int len)
+{
+	mix((short *)stream, len/2/2);
+}
+#endif
 
-static PaStream *stream;
 
 int snd_init()
 {
+#ifdef CONFIG_NO_SDL
 	PaStreamParameters params;
 	PaError err = Pa_Initialize();
 	
@@ -293,7 +307,36 @@ int snd_init()
 			pacallback,             /* specify our custom callback */
 			0x0); /* pass our data through to callback */
 	err = Pa_StartStream(stream);
+#else
+    SDL_AudioSpec format;
+	
+	sound_lock = lock_create();
+	
+	if(!config.snd_enable)
+		return 0;
+	
+	mixing_rate = config.snd_rate;
+
+    /* Set 16-bit stereo audio at 22Khz */
+    format.freq = config.snd_rate;
+    format.format = AUDIO_S16;
+    format.channels = 2;
+    format.samples = 512;        /* A good value for games */
+    format.callback = sdlcallback;
+    format.userdata = NULL;
+
+    /* Open the audio device and start playing sound! */
+    if(SDL_OpenAudio(&format, NULL) < 0)
+	{
+        dbg_msg("client/sound", "unable to open audio: %s", SDL_GetError());
+		return -1;
+    }
+	else
+        dbg_msg("client/sound", "sound init successful");
 
+	SDL_PauseAudio(0);
+	
+#endif
 	sound_enabled = 1;
 	snd_update(); /* update the volume */
 	return 0;
@@ -319,9 +362,12 @@ int snd_update()
 
 int snd_shutdown()
 {
+#ifdef CONFIG_NO_SDL	
 	Pa_StopStream(stream);
 	Pa_Terminate();
-
+#else
+	SDL_CloseAudio();
+#endif
 	lock_destroy(sound_lock);
 
 	return 0;
diff --git a/src/engine/e_keynames.c b/src/engine/e_keynames.c
index 64ac7642..500a28ad 100644
--- a/src/engine/e_keynames.c
+++ b/src/engine/e_keynames.c
@@ -4,6 +4,7 @@
 
 static const char key_strings[512][16] =
 {
+#ifdef CONFIG_NO_SDL
 	"&0",
 	"&1",
 	"&2",
@@ -516,6 +517,521 @@ static const char key_strings[512][16] =
 	"&509",
 	"&510",
 	"&511",
+#else
+
+	"first",
+	"&1",
+	"&2",
+	"&3",
+	"&4",
+	"&5",
+	"&6",
+	"&7",
+	"backspace",
+	"tab",
+	"&10",
+	"&11",
+	"clear",
+	"return",
+	"&14",
+	"&15",
+	"&16",
+	"&17",
+	"&18",
+	"pause",
+	"&20",
+	"&21",
+	"&22",
+	"&23",
+	"&24",
+	"&25",
+	"&26",
+	"escape",
+	"&28",
+	"&29",
+	"&30",
+	"&31",
+	"space",
+	"exclaim",
+	"quotedbl",
+	"hash",
+	"dollar",
+	"&37",
+	"ampersand",
+	"quote",
+	"leftparen",
+	"rightparen",
+	"asterisk",
+	"plus",
+	"comma",
+	"minus",
+	"period",
+	"slash",
+	"0",
+	"1",
+	"2",
+	"3",
+	"4",
+	"5",
+	"6",
+	"7",
+	"8",
+	"9",
+	"colon",
+	"semicolon",
+	"less",
+	"equals",
+	"greater",
+	"question",
+	"at",
+	"&65",
+	"&66",
+	"&67",
+	"&68",
+	"&69",
+	"&70",
+	"&71",
+	"&72",
+	"&73",
+	"&74",
+	"&75",
+	"&76",
+	"&77",
+	"&78",
+	"&79",
+	"&80",
+	"&81",
+	"&82",
+	"&83",
+	"&84",
+	"&85",
+	"&86",
+	"&87",
+	"&88",
+	"&89",
+	"&90",
+	"leftbracket",
+	"backslash",
+	"rightbracket",
+	"caret",
+	"underscore",
+	"backquote",
+	"a",
+	"b",
+	"c",
+	"d",
+	"e",
+	"f",
+	"g",
+	"h",
+	"i",
+	"j",
+	"k",
+	"l",
+	"m",
+	"n",
+	"o",
+	"p",
+	"q",
+	"r",
+	"s",
+	"t",
+	"u",
+	"v",
+	"w",
+	"x",
+	"y",
+	"z",
+	"&123",
+	"&124",
+	"&125",
+	"&126",
+	"delete",
+	"&128",
+	"&129",
+	"&130",
+	"&131",
+	"&132",
+	"&133",
+	"&134",
+	"&135",
+	"&136",
+	"&137",
+	"&138",
+	"&139",
+	"&140",
+	"&141",
+	"&142",
+	"&143",
+	"&144",
+	"&145",
+	"&146",
+	"&147",
+	"&148",
+	"&149",
+	"&150",
+	"&151",
+	"&152",
+	"&153",
+	"&154",
+	"&155",
+	"&156",
+	"&157",
+	"&158",
+	"&159",
+	"world_0",
+	"world_1",
+	"world_2",
+	"world_3",
+	"world_4",
+	"world_5",
+	"world_6",
+	"world_7",
+	"world_8",
+	"world_9",
+	"world_10",
+	"world_11",
+	"world_12",
+	"world_13",
+	"world_14",
+	"world_15",
+	"world_16",
+	"world_17",
+	"world_18",
+	"world_19",
+	"world_20",
+	"world_21",
+	"world_22",
+	"world_23",
+	"world_24",
+	"world_25",
+	"world_26",
+	"world_27",
+	"world_28",
+	"world_29",
+	"world_30",
+	"world_31",
+	"world_32",
+	"world_33",
+	"world_34",
+	"world_35",
+	"world_36",
+	"world_37",
+	"world_38",
+	"world_39",
+	"world_40",
+	"world_41",
+	"world_42",
+	"world_43",
+	"world_44",
+	"world_45",
+	"world_46",
+	"world_47",
+	"world_48",
+	"world_49",
+	"world_50",
+	"world_51",
+	"world_52",
+	"world_53",
+	"world_54",
+	"world_55",
+	"world_56",
+	"world_57",
+	"world_58",
+	"world_59",
+	"world_60",
+	"world_61",
+	"world_62",
+	"world_63",
+	"world_64",
+	"world_65",
+	"world_66",
+	"world_67",
+	"world_68",
+	"world_69",
+	"world_70",
+	"world_71",
+	"world_72",
+	"world_73",
+	"world_74",
+	"world_75",
+	"world_76",
+	"world_77",
+	"world_78",
+	"world_79",
+	"world_80",
+	"world_81",
+	"world_82",
+	"world_83",
+	"world_84",
+	"world_85",
+	"world_86",
+	"world_87",
+	"world_88",
+	"world_89",
+	"world_90",
+	"world_91",
+	"world_92",
+	"world_93",
+	"world_94",
+	"world_95",
+	"kp0",
+	"kp1",
+	"kp2",
+	"kp3",
+	"kp4",
+	"kp5",
+	"kp6",
+	"kp7",
+	"kp8",
+	"kp9",
+	"kp_period",
+	"kp_divide",
+	"kp_multiply",
+	"kp_minus",
+	"kp_plus",
+	"kp_enter",
+	"kp_equals",
+	"up",
+	"down",
+	"right",
+	"left",
+	"insert",
+	"home",
+	"end",
+	"pageup",
+	"pagedown",
+	"f1",
+	"f2",
+	"f3",
+	"f4",
+	"f5",
+	"f6",
+	"f7",
+	"f8",
+	"f9",
+	"f10",
+	"f11",
+	"f12",
+	"f13",
+	"f14",
+	"f15",
+	"&297",
+	"&298",
+	"&299",
+	"numlock",
+	"capslock",
+	"scrollock",
+	"rshift",
+	"lshift",
+	"rctrl",
+	"lctrl",
+	"ralt",
+	"lalt",
+	"rmeta",
+	"lmeta",
+	"lsuper",
+	"rsuper",
+	"mode",
+	"compose",
+	"help",
+	"print",
+	"sysreq",
+	"break",
+	"menu",
+	"power",
+	"euro",
+	"undo",
+	"mouse1",
+	"mouse2",
+	"mouse3",
+	"mouse4",
+	"mouse5",
+	"mouse6",
+	"mouse7",
+	"mouse8",
+	"mousewheelup",
+	"mousewheeldown",
+	"&333",
+	"&334",
+	"&335",
+	"&336",
+	"&337",
+	"&338",
+	"&339",
+	"&340",
+	"&341",
+	"&342",
+	"&343",
+	"&344",
+	"&345",
+	"&346",
+	"&347",
+	"&348",
+	"&349",
+	"&350",
+	"&351",
+	"&352",
+	"&353",
+	"&354",
+	"&355",
+	"&356",
+	"&357",
+	"&358",
+	"&359",
+	"&360",
+	"&361",
+	"&362",
+	"&363",
+	"&364",
+	"&365",
+	"&366",
+	"&367",
+	"&368",
+	"&369",
+	"&370",
+	"&371",
+	"&372",
+	"&373",
+	"&374",
+	"&375",
+	"&376",
+	"&377",
+	"&378",
+	"&379",
+	"&380",
+	"&381",
+	"&382",
+	"&383",
+	"&384",
+	"&385",
+	"&386",
+	"&387",
+	"&388",
+	"&389",
+	"&390",
+	"&391",
+	"&392",
+	"&393",
+	"&394",
+	"&395",
+	"&396",
+	"&397",
+	"&398",
+	"&399",
+	"&400",
+	"&401",
+	"&402",
+	"&403",
+	"&404",
+	"&405",
+	"&406",
+	"&407",
+	"&408",
+	"&409",
+	"&410",
+	"&411",
+	"&412",
+	"&413",
+	"&414",
+	"&415",
+	"&416",
+	"&417",
+	"&418",
+	"&419",
+	"&420",
+	"&421",
+	"&422",
+	"&423",
+	"&424",
+	"&425",
+	"&426",
+	"&427",
+	"&428",
+	"&429",
+	"&430",
+	"&431",
+	"&432",
+	"&433",
+	"&434",
+	"&435",
+	"&436",
+	"&437",
+	"&438",
+	"&439",
+	"&440",
+	"&441",
+	"&442",
+	"&443",
+	"&444",
+	"&445",
+	"&446",
+	"&447",
+	"&448",
+	"&449",
+	"&450",
+	"&451",
+	"&452",
+	"&453",
+	"&454",
+	"&455",
+	"&456",
+	"&457",
+	"&458",
+	"&459",
+	"&460",
+	"&461",
+	"&462",
+	"&463",
+	"&464",
+	"&465",
+	"&466",
+	"&467",
+	"&468",
+	"&469",
+	"&470",
+	"&471",
+	"&472",
+	"&473",
+	"&474",
+	"&475",
+	"&476",
+	"&477",
+	"&478",
+	"&479",
+	"&480",
+	"&481",
+	"&482",
+	"&483",
+	"&484",
+	"&485",
+	"&486",
+	"&487",
+	"&488",
+	"&489",
+	"&490",
+	"&491",
+	"&492",
+	"&493",
+	"&494",
+	"&495",
+	"&496",
+	"&497",
+	"&498",
+	"&499",
+	"&500",
+	"&501",
+	"&502",
+	"&503",
+	"&504",
+	"&505",
+	"&506",
+	"&507",
+	"&508",
+	"&509",
+	"&510",
+	"&511",
+#endif
 };
 
 const char *inp_key_name(int k) { if (k >= 0 && k < 512) return key_strings[k]; else return key_strings[0]; }
diff --git a/src/engine/e_keys.h b/src/engine/e_keys.h
index 9670f1a0..bb51ead6 100644
--- a/src/engine/e_keys.h
+++ b/src/engine/e_keys.h
@@ -1,9 +1,9 @@
 #ifndef ENGINE_KEYS_H
 #define ENGINE_KEYS_H
 /* AUTO GENERATED! DO NOT EDIT MANUALLY! */
-
 enum
 {
+#ifdef CONFIG_NO_SDL
 	KEY_UNKNOWN = -1,
 	KEY_SPACE = 32,
 	KEY_SPECIAL = 256,
@@ -82,6 +82,257 @@ enum
 	KEY_MOUSE_7 = KEY_MOUSE_FIRST+6,
 	KEY_MOUSE_8 = KEY_MOUSE_FIRST+7,
 	KEY_LAST
+#else
+	KEY_UNKNOWN = 0,
+	KEY_FIRST = 0,
+	KEY_BACKSPACE = 8,
+	KEY_TAB = 9,
+	KEY_CLEAR = 12,
+	KEY_RETURN = 13,
+	KEY_PAUSE = 19,
+	KEY_ESCAPE = 27,
+	KEY_SPACE = 32,
+	KEY_EXCLAIM = 33,
+	KEY_QUOTEDBL = 34,
+	KEY_HASH = 35,
+	KEY_DOLLAR = 36,
+	KEY_AMPERSAND = 38,
+	KEY_QUOTE = 39,
+	KEY_LEFTPAREN = 40,
+	KEY_RIGHTPAREN = 41,
+	KEY_ASTERISK = 42,
+	KEY_PLUS = 43,
+	KEY_COMMA = 44,
+	KEY_MINUS = 45,
+	KEY_PERIOD = 46,
+	KEY_SLASH = 47,
+	KEY_0 = 48,
+	KEY_1 = 49,
+	KEY_2 = 50,
+	KEY_3 = 51,
+	KEY_4 = 52,
+	KEY_5 = 53,
+	KEY_6 = 54,
+	KEY_7 = 55,
+	KEY_8 = 56,
+	KEY_9 = 57,
+	KEY_COLON = 58,
+	KEY_SEMICOLON = 59,
+	KEY_LESS = 60,
+	KEY_EQUALS = 61,
+	KEY_GREATER = 62,
+	KEY_QUESTION = 63,
+	KEY_AT = 64,
+	KEY_LEFTBRACKET = 91,
+	KEY_BACKSLASH = 92,
+	KEY_RIGHTBRACKET = 93,
+	KEY_CARET = 94,
+	KEY_UNDERSCORE = 95,
+	KEY_BACKQUOTE = 96,
+	KEY_a = 97,
+	KEY_b = 98,
+	KEY_c = 99,
+	KEY_d = 100,
+	KEY_e = 101,
+	KEY_f = 102,
+	KEY_g = 103,
+	KEY_h = 104,
+	KEY_i = 105,
+	KEY_j = 106,
+	KEY_k = 107,
+	KEY_l = 108,
+	KEY_m = 109,
+	KEY_n = 110,
+	KEY_o = 111,
+	KEY_p = 112,
+	KEY_q = 113,
+	KEY_r = 114,
+	KEY_s = 115,
+	KEY_t = 116,
+	KEY_u = 117,
+	KEY_v = 118,
+	KEY_w = 119,
+	KEY_x = 120,
+	KEY_y = 121,
+	KEY_z = 122,
+	KEY_DELETE = 127,
+	KEY_WORLD_0 = 160,
+	KEY_WORLD_1 = 161,
+	KEY_WORLD_2 = 162,
+	KEY_WORLD_3 = 163,
+	KEY_WORLD_4 = 164,
+	KEY_WORLD_5 = 165,
+	KEY_WORLD_6 = 166,
+	KEY_WORLD_7 = 167,
+	KEY_WORLD_8 = 168,
+	KEY_WORLD_9 = 169,
+	KEY_WORLD_10 = 170,
+	KEY_WORLD_11 = 171,
+	KEY_WORLD_12 = 172,
+	KEY_WORLD_13 = 173,
+	KEY_WORLD_14 = 174,
+	KEY_WORLD_15 = 175,
+	KEY_WORLD_16 = 176,
+	KEY_WORLD_17 = 177,
+	KEY_WORLD_18 = 178,
+	KEY_WORLD_19 = 179,
+	KEY_WORLD_20 = 180,
+	KEY_WORLD_21 = 181,
+	KEY_WORLD_22 = 182,
+	KEY_WORLD_23 = 183,
+	KEY_WORLD_24 = 184,
+	KEY_WORLD_25 = 185,
+	KEY_WORLD_26 = 186,
+	KEY_WORLD_27 = 187,
+	KEY_WORLD_28 = 188,
+	KEY_WORLD_29 = 189,
+	KEY_WORLD_30 = 190,
+	KEY_WORLD_31 = 191,
+	KEY_WORLD_32 = 192,
+	KEY_WORLD_33 = 193,
+	KEY_WORLD_34 = 194,
+	KEY_WORLD_35 = 195,
+	KEY_WORLD_36 = 196,
+	KEY_WORLD_37 = 197,
+	KEY_WORLD_38 = 198,
+	KEY_WORLD_39 = 199,
+	KEY_WORLD_40 = 200,
+	KEY_WORLD_41 = 201,
+	KEY_WORLD_42 = 202,
+	KEY_WORLD_43 = 203,
+	KEY_WORLD_44 = 204,
+	KEY_WORLD_45 = 205,
+	KEY_WORLD_46 = 206,
+	KEY_WORLD_47 = 207,
+	KEY_WORLD_48 = 208,
+	KEY_WORLD_49 = 209,
+	KEY_WORLD_50 = 210,
+	KEY_WORLD_51 = 211,
+	KEY_WORLD_52 = 212,
+	KEY_WORLD_53 = 213,
+	KEY_WORLD_54 = 214,
+	KEY_WORLD_55 = 215,
+	KEY_WORLD_56 = 216,
+	KEY_WORLD_57 = 217,
+	KEY_WORLD_58 = 218,
+	KEY_WORLD_59 = 219,
+	KEY_WORLD_60 = 220,
+	KEY_WORLD_61 = 221,
+	KEY_WORLD_62 = 222,
+	KEY_WORLD_63 = 223,
+	KEY_WORLD_64 = 224,
+	KEY_WORLD_65 = 225,
+	KEY_WORLD_66 = 226,
+	KEY_WORLD_67 = 227,
+	KEY_WORLD_68 = 228,
+	KEY_WORLD_69 = 229,
+	KEY_WORLD_70 = 230,
+	KEY_WORLD_71 = 231,
+	KEY_WORLD_72 = 232,
+	KEY_WORLD_73 = 233,
+	KEY_WORLD_74 = 234,
+	KEY_WORLD_75 = 235,
+	KEY_WORLD_76 = 236,
+	KEY_WORLD_77 = 237,
+	KEY_WORLD_78 = 238,
+	KEY_WORLD_79 = 239,
+	KEY_WORLD_80 = 240,
+	KEY_WORLD_81 = 241,
+	KEY_WORLD_82 = 242,
+	KEY_WORLD_83 = 243,
+	KEY_WORLD_84 = 244,
+	KEY_WORLD_85 = 245,
+	KEY_WORLD_86 = 246,
+	KEY_WORLD_87 = 247,
+	KEY_WORLD_88 = 248,
+	KEY_WORLD_89 = 249,
+	KEY_WORLD_90 = 250,
+	KEY_WORLD_91 = 251,
+	KEY_WORLD_92 = 252,
+	KEY_WORLD_93 = 253,
+	KEY_WORLD_94 = 254,
+	KEY_WORLD_95 = 255,
+	KEY_KP0 = 256,
+	KEY_KP1 = 257,
+	KEY_KP2 = 258,
+	KEY_KP3 = 259,
+	KEY_KP4 = 260,
+	KEY_KP5 = 261,
+	KEY_KP6 = 262,
+	KEY_KP7 = 263,
+	KEY_KP8 = 264,
+	KEY_KP9 = 265,
+	KEY_KP_PERIOD = 266,
+	KEY_KP_DIVIDE = 267,
+	KEY_KP_MULTIPLY = 268,
+	KEY_KP_MINUS = 269,
+	KEY_KP_PLUS = 270,
+	KEY_KP_ENTER = 271,
+	KEY_KP_EQUALS = 272,
+	KEY_UP = 273,
+	KEY_DOWN = 274,
+	KEY_RIGHT = 275,
+	KEY_LEFT = 276,
+	KEY_INSERT = 277,
+	KEY_HOME = 278,
+	KEY_END = 279,
+	KEY_PAGEUP = 280,
+	KEY_PAGEDOWN = 281,
+	KEY_F1 = 282,
+	KEY_F2 = 283,
+	KEY_F3 = 284,
+	KEY_F4 = 285,
+	KEY_F5 = 286,
+	KEY_F6 = 287,
+	KEY_F7 = 288,
+	KEY_F8 = 289,
+	KEY_F9 = 290,
+	KEY_F10 = 291,
+	KEY_F11 = 292,
+	KEY_F12 = 293,
+	KEY_F13 = 294,
+	KEY_F14 = 295,
+	KEY_F15 = 296,
+	KEY_NUMLOCK = 300,
+	KEY_CAPSLOCK = 301,
+	KEY_SCROLLOCK = 302,
+	KEY_RSHIFT = 303,
+	KEY_LSHIFT = 304,
+	KEY_RCTRL = 305,
+	KEY_LCTRL = 306,
+	KEY_RALT = 307,
+	KEY_LALT = 308,
+	KEY_RMETA = 309,
+	KEY_LMETA = 310,
+	KEY_LSUPER = 311,
+	KEY_RSUPER = 312,
+	KEY_MODE = 313,
+	KEY_COMPOSE = 314,
+	KEY_HELP = 315,
+	KEY_PRINT = 316,
+	KEY_SYSREQ = 317,
+	KEY_BREAK = 318,
+	KEY_MENU = 319,
+	KEY_POWER = 320,
+	KEY_EURO = 321,
+	KEY_UNDO = 322,
+	KEY_MOUSE_1 = 323,
+	KEY_MOUSE_2 = 324,
+	KEY_MOUSE_3 = 325,
+	KEY_MOUSE_4 = 326,
+	KEY_MOUSE_5 = 327,
+	KEY_MOUSE_6 = 328,
+	KEY_MOUSE_7 = 329,
+	KEY_MOUSE_8 = 330,
+	KEY_MOUSE_WHEEL_UP = 331,
+	KEY_MOUSE_WHEEL_DOWN = 332,
+	KEY_LAST,
+	KEY_DEL=KEY_DELETE,
+	KEY_ENTER=KEY_RETURN,
+	KEY_KP_SUBTRACT=KEY_KP_MINUS,
+	KEY_KP_ADD=KEY_KP_PLUS,
+	KEY_ESC=KEY_ESCAPE
+#endif
 };
 
 #endif
diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp
index b55e7333..de5f4f05 100644
--- a/src/game/client/components/binds.cpp
+++ b/src/game/client/components/binds.cpp
@@ -6,7 +6,7 @@
 bool BINDS::BINDS_SPECIAL::on_input(INPUT_EVENT e)
 {
 	// don't handle invalid events and keys that arn't set to anything
-	if(e.key >= KEY_F1 && e.key <= KEY_F25 && binds->keybindings[e.key][0] != 0)
+	if(e.key >= KEY_F1 && e.key <= KEY_F15 && binds->keybindings[e.key][0] != 0)
 	{
 		int stroke = 0;
 		if(e.flags&INPFLAG_PRESS)
@@ -86,9 +86,14 @@ void BINDS::set_defaults()
 	bind(KEY_F2, "toggle_remote_console");
 	bind(KEY_TAB, "+scoreboard");
 	bind(KEY_F10, "screenshot");
-	
+
+#ifdef CONFIG_NO_SDL
 	bind('A', "+left");
 	bind('D', "+right");
+#else
+	bind('a', "+left");
+	bind('d', "+right");
+#endif
 	bind(KEY_SPACE, "+jump");
 	bind(KEY_MOUSE_1, "+fire");
 	bind(KEY_MOUSE_2, "+hook");
@@ -103,8 +108,13 @@ void BINDS::set_defaults()
 	bind(KEY_MOUSE_WHEEL_UP, "+prevweapon");
 	bind(KEY_MOUSE_WHEEL_DOWN, "+nextweapon");
 	
+#ifdef CONFIG_NO_SDL
 	bind('T', "chat all");
 	bind('Y', "chat team");	
+#else
+	bind('t', "chat all");
+	bind('y', "chat team");	
+#endif
 
 	bind(KEY_F3, "vote yes");
 	bind(KEY_F4, "vote no");	
diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp
index c8fe018e..71653fdf 100644
--- a/src/game/client/components/console.cpp
+++ b/src/game/client/components/console.cpp
@@ -295,7 +295,7 @@ bool CONSOLE::on_input(INPUT_EVENT e)
 {
 	if(console_state == CONSOLE_CLOSED)
 		return false;
-	if(e.key >= KEY_F1 && e.key <= KEY_F25)
+	if(e.key >= KEY_F1 && e.key <= KEY_F15)
 		return false;
 
 	if(e.key == KEY_ESC && (e.flags&INPFLAG_PRESS))