Index: /trunk/nv/lib/sdl12.hh
===================================================================
--- /trunk/nv/lib/sdl12.hh	(revision 168)
+++ /trunk/nv/lib/sdl12.hh	(revision 169)
@@ -269,5 +269,22 @@
 #endif
 
-typedef struct SDL_Surface {
+#if NV_SDL_VERSION == NV_SDL_20
+typedef struct SDL_Surface 
+{
+	Uint32 flags;
+	SDL_PixelFormat *format;
+	int w, h;
+	int pitch;
+	void *pixels;
+	void *userdata;
+	int locked;
+	void *lock_data;
+	SDL_Rect clip_rect;
+	struct SDL_BlitMap *map;
+	int refcount;
+} SDL_Surface;
+#else
+typedef struct SDL_Surface
+{
 	Uint32 flags;
 	SDL_PixelFormat *format;
@@ -284,5 +301,14 @@
 	int refcount;
 } SDL_Surface;
-
+#endif
+
+#if NV_SDL_VERSION == NV_SDL_20
+#define SDL_SWSURFACE       0         
+#define SDL_PREALLOC        0x00000001
+#define SDL_RLEACCEL        0x00000002
+#define SDL_DONTFREE        0x00000004
+
+#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
+#else
 #define SDL_SWSURFACE	0x00000000	
 #define SDL_HWSURFACE	0x00000001	
@@ -304,9 +330,13 @@
 
 #define SDL_MUSTLOCK(surface)	\
-  (surface->offset ||		\
-  ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
-
-typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, struct SDL_Surface *dst, SDL_Rect *dstrect);
-
+	(surface->offset ||		\
+	((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
+
+#endif
+
+typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, 
+                        struct SDL_Surface *dst, SDL_Rect *dstrect);
+
+#if NV_SDL_VERSION == NV_SDL_12
 typedef struct SDL_VideoInfo {
 	Uint32 hw_available :1;
@@ -327,4 +357,58 @@
 	int    current_h;
 } SDL_VideoInfo;
+#endif
+
+#if NV_SDL_VERSION == NV_SDL_20
+typedef enum
+{
+    SDL_WINDOW_FULLSCREEN = 0x00000001,
+    SDL_WINDOW_OPENGL = 0x00000002,
+    SDL_WINDOW_SHOWN = 0x00000004,
+    SDL_WINDOW_HIDDEN = 0x00000008,
+    SDL_WINDOW_BORDERLESS = 0x00000010,
+    SDL_WINDOW_RESIZABLE = 0x00000020,
+    SDL_WINDOW_MINIMIZED = 0x00000040,
+    SDL_WINDOW_MAXIMIZED = 0x00000080,
+    SDL_WINDOW_INPUT_GRABBED = 0x00000100,
+    SDL_WINDOW_INPUT_FOCUS = 0x00000200,
+    SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
+    SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
+    SDL_WINDOW_FOREIGN = 0x00000800 
+} SDL_WindowFlags;
+
+#define SDL_WINDOWPOS_UNDEFINED_MASK    0x1FFF0000
+#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X)  (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
+#define SDL_WINDOWPOS_UNDEFINED         SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
+#define SDL_WINDOWPOS_ISUNDEFINED(X)    \
+            (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
+
+#define SDL_WINDOWPOS_CENTERED_MASK    0x2FFF0000
+#define SDL_WINDOWPOS_CENTERED_DISPLAY(X)  (SDL_WINDOWPOS_CENTERED_MASK|(X))
+#define SDL_WINDOWPOS_CENTERED         SDL_WINDOWPOS_CENTERED_DISPLAY(0)
+#define SDL_WINDOWPOS_ISCENTERED(X)    \
+            (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
+
+typedef enum
+{
+    SDL_WINDOWEVENT_NONE,
+    SDL_WINDOWEVENT_SHOWN,
+    SDL_WINDOWEVENT_HIDDEN,
+    SDL_WINDOWEVENT_EXPOSED,
+    SDL_WINDOWEVENT_MOVED,
+    SDL_WINDOWEVENT_RESIZED,
+    SDL_WINDOWEVENT_SIZE_CHANGED,
+    SDL_WINDOWEVENT_MINIMIZED,
+    SDL_WINDOWEVENT_MAXIMIZED,
+    SDL_WINDOWEVENT_RESTORED,
+    SDL_WINDOWEVENT_ENTER,
+    SDL_WINDOWEVENT_LEAVE,
+    SDL_WINDOWEVENT_FOCUS_GAINED,
+    SDL_WINDOWEVENT_FOCUS_LOST,
+    SDL_WINDOWEVENT_CLOSE
+} SDL_WindowEventID;
+
+typedef void *SDL_GLContext;
+#endif
+
 
 typedef enum {
@@ -345,10 +429,35 @@
     SDL_GL_MULTISAMPLESAMPLES,
     SDL_GL_ACCELERATED_VISUAL,
+#if NV_SDL_VERSION == NV_SDL_12
     SDL_GL_SWAP_CONTROL
+#else
+	SDL_GL_RETAINED_BACKING,
+	SDL_GL_CONTEXT_MAJOR_VERSION,
+	SDL_GL_CONTEXT_MINOR_VERSION,
+	SDL_GL_CONTEXT_EGL,
+	SDL_GL_CONTEXT_FLAGS,
+	SDL_GL_CONTEXT_PROFILE_MASK,
+	SDL_GL_SHARE_WITH_CURRENT_CONTEXT
+#endif
 } SDL_GLattr;
 
-#define SDL_LOGPAL 0x01
-#define SDL_PHYSPAL 0x02
-
+#if NV_SDL_VERSION == NV_SDL_20
+typedef enum
+{
+	SDL_GL_CONTEXT_PROFILE_CORE           = 0x0001,
+	SDL_GL_CONTEXT_PROFILE_COMPATIBILITY  = 0x0002,
+	SDL_GL_CONTEXT_PROFILE_ES             = 0x0004
+} SDL_GLprofile;
+
+typedef enum
+{
+	SDL_GL_CONTEXT_DEBUG_FLAG              = 0x0001,
+	SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
+	SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG      = 0x0004,
+	SDL_GL_CONTEXT_RESET_ISOLATION_FLAG    = 0x0008
+} SDL_GLcontextFlag;
+#endif
+
+#if NV_SDL_VERSION == NV_SDL_12
 typedef enum {
 	SDL_GRAB_QUERY = -1,
@@ -357,18 +466,7 @@
 	SDL_GRAB_FULLSCREEN	/**< Used internally */
 } SDL_GrabMode;
+#endif
 
 /* SDL_audio.h defines */
-typedef struct SDL_AudioSpec {
-	int freq;
-	Uint16 format;
-	Uint8  channels;
-	Uint8  silence;
-	Uint16 samples;
-	Uint16 padding;
-	Uint32 size;
-	void (NV_SDL_APIENTRY *callback)(void *userdata, Uint8 *stream, int len);
-	void  *userdata;
-} SDL_AudioSpec;
-
 #define AUDIO_U8	0x0008
 #define AUDIO_S8	0x8008
@@ -380,22 +478,53 @@
 #define AUDIO_S16	AUDIO_S16LSB
 
+#if NV_SDL_VERSION == NV_SDL_20
+#define AUDIO_S32LSB    0x8020 
+#define AUDIO_S32MSB    0x9020 
+#define AUDIO_S32       AUDIO_S32LSB
+#define AUDIO_F32LSB    0x8120 
+#define AUDIO_F32MSB    0x9120 
+#define AUDIO_F32       AUDIO_F32LSB
+#endif
+
 /* NOTE : assuming LSB! */
 #define AUDIO_U16SYS	AUDIO_U16LSB
 #define AUDIO_S16SYS	AUDIO_S16LSB
+#if NV_SDL_VERSION == NV_SDL_20
+#define AUDIO_S32SYS    AUDIO_S32LSB
+#define AUDIO_F32SYS    AUDIO_F32LSB
+#endif
+
+typedef Uint16 SDL_AudioFormat;
+typedef void (NV_SDL_APIENTRY * SDL_AudioCallback) (void *userdata, Uint8 * stream, int len);
+struct SDL_AudioCVT;
+typedef void (NV_SDL_APIENTRY * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, SDL_AudioFormat format);
+
+typedef struct SDL_AudioSpec
+{
+	int freq;
+	SDL_AudioFormat format;
+	Uint8 channels;
+	Uint8 silence;
+	Uint16 samples;
+	Uint16 padding;
+	Uint32 size;
+	SDL_AudioCallback callback;
+	void *userdata;
+} SDL_AudioSpec;
 
 typedef struct SDL_AudioCVT {
 	int needed;
-	Uint16 src_format;
-	Uint16 dst_format;
+	SDL_AudioFormat src_format;
+	SDL_AudioFormat dst_format;
 	double rate_incr;
-	Uint8 *buf;		
-	int    len;		
-	int    len_cvt;	
-	int    len_mult;
+	Uint8 *buf;
+	int len;
+	int len_cvt;
+	int len_mult;
 	double len_ratio;
-	void (NV_SDL_APIENTRY *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+	SDL_AudioFilter filters[10];
 	int filter_index;
 } SDL_AudioCVT; 
-	
+
 typedef enum {
 	SDL_AUDIO_STOPPED = 0,
@@ -404,248 +533,28 @@
 } SDL_audiostatus;
 
+typedef SDL_audiostatus SDL_AudioStatus;
+
+#if NV_SDL_VERSION == NV_SDL_20
+#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE    0x00000001
+#define SDL_AUDIO_ALLOW_FORMAT_CHANGE       0x00000002
+#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE     0x00000004
+#define SDL_AUDIO_ALLOW_ANY_CHANGE          (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
+#endif
+
 #define SDL_MIX_MAXVOLUME 128
 
 /* SDL_active.h defines */
+#if NV_SDL_VERSION == NV_SDL_12
 #define SDL_APPMOUSEFOCUS	0x01
 #define SDL_APPINPUTFOCUS	0x02
 #define SDL_APPACTIVE		0x04
+#endif
 
 /* SDL_keyboard.h defines */
-typedef enum {
-	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,
-	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,
-	SDLK_WORLD_0		= 160,
-	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,
-	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,
-	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,
-	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,
-	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,
-	SDLK_RSUPER		= 312,
-	SDLK_MODE		= 313,
-	SDLK_COMPOSE		= 314,
-	SDLK_HELP		= 315,
-	SDLK_PRINT		= 316,
-	SDLK_SYSREQ		= 317,
-	SDLK_BREAK		= 318,
-	SDLK_MENU		= 319,
-	SDLK_POWER		= 320,
-	SDLK_EURO		= 321,
-	SDLK_UNDO		= 322,
-	SDLK_LAST
-} SDLKey;
+#if NV_SDL_VERSION == NV_SDL_20
+#include <nv/lib/detail/sdl_keys_20.inc>
+#else
+#include <nv/lib/detail/sdl_keys_12.inc>
+#endif
 
 typedef enum {
@@ -659,4 +568,6 @@
 	KMOD_LMETA = 0x0400,
 	KMOD_RMETA = 0x0800,
+	KMOD_LGUI  = 0x0400,
+	KMOD_RGUI  = 0x0800,
 	KMOD_NUM   = 0x1000,
 	KMOD_CAPS  = 0x2000,
@@ -669,8 +580,10 @@
 #define KMOD_ALT	(KMOD_LALT|KMOD_RALT)
 #define KMOD_META	(KMOD_LMETA|KMOD_RMETA)
+#define KMOD_GUI	(KMOD_LGUI|KMOD_RGUI)
 
 #define SDL_DEFAULT_REPEAT_DELAY	500
 #define SDL_DEFAULT_REPEAT_INTERVAL	30
 
+#if NV_SDL_VERSION == NV_SDL_12
 typedef struct SDL_keysym {
 	Uint8 scancode;
@@ -681,6 +594,34 @@
 
 #define SDL_ALL_HOTKEYS		0xFFFFFFFF
+#else
+typedef struct SDL_Keysym
+{
+	SDL_Scancode scancode;
+	SDL_Keycode sym;
+	Uint16 mod;
+	Uint32 unused;
+} SDL_Keysym;
+#endif
 
 /* SDL_mouse.h defines */
+#if NV_SDL_VERSION == NV_SDL_20
+typedef enum
+{
+	SDL_SYSTEM_CURSOR_ARROW,
+	SDL_SYSTEM_CURSOR_IBEAM,
+	SDL_SYSTEM_CURSOR_WAIT,
+	SDL_SYSTEM_CURSOR_CROSSHAIR,
+	SDL_SYSTEM_CURSOR_WAITARROW,
+	SDL_SYSTEM_CURSOR_SIZENWSE,
+	SDL_SYSTEM_CURSOR_SIZENESW,
+	SDL_SYSTEM_CURSOR_SIZEWE,
+	SDL_SYSTEM_CURSOR_SIZENS,
+	SDL_SYSTEM_CURSOR_SIZEALL,
+	SDL_SYSTEM_CURSOR_NO,
+	SDL_SYSTEM_CURSOR_HAND,
+	SDL_NUM_SYSTEM_CURSORS
+} SDL_SystemCursor;
+#endif
+
 typedef struct WMcursor WMcursor;
 typedef struct SDL_Cursor {
@@ -697,8 +638,13 @@
 #define SDL_BUTTON_MIDDLE	2
 #define SDL_BUTTON_RIGHT	3
+#if NV_SDL_VERSION == NV_SDL_20
+#define SDL_BUTTON_X1		4
+#define SDL_BUTTON_X2		5
+#else
 #define SDL_BUTTON_WHEELUP	4
 #define SDL_BUTTON_WHEELDOWN	5
 #define SDL_BUTTON_X1		6
 #define SDL_BUTTON_X2		7
+#endif
 #define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
 #define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
@@ -708,6 +654,16 @@
 
 /* SDL_joystick.h defines */
+
 struct _SDL_Joystick;
 typedef struct _SDL_Joystick SDL_Joystick; 
+
+#if NV_SDL_VERSION == NV_SDL_20
+typedef struct {
+	Uint8 data[16];
+} SDL_JoystickGUID;
+
+typedef Sint32 SDL_JoystickID;
+#endif
+
 
 #define SDL_HAT_CENTERED	0x00
@@ -722,177 +678,14 @@
 
 /* SDL_event.h defines */
+
 #define SDL_RELEASED	0
 #define SDL_PRESSED	1
 
-typedef enum {
-       SDL_NOEVENT = 0,
-       SDL_ACTIVEEVENT,
-       SDL_KEYDOWN,
-       SDL_KEYUP,
-       SDL_MOUSEMOTION,
-       SDL_MOUSEBUTTONDOWN,
-       SDL_MOUSEBUTTONUP,
-       SDL_JOYAXISMOTION,
-       SDL_JOYBALLMOTION,
-       SDL_JOYHATMOTION,
-       SDL_JOYBUTTONDOWN,
-       SDL_JOYBUTTONUP,
-       SDL_QUIT,
-       SDL_SYSWMEVENT,
-       SDL_EVENT_RESERVEDA,
-       SDL_EVENT_RESERVEDB,
-       SDL_VIDEORESIZE,
-       SDL_VIDEOEXPOSE,
-       SDL_EVENT_RESERVED2,
-       SDL_EVENT_RESERVED3,
-       SDL_EVENT_RESERVED4,
-       SDL_EVENT_RESERVED5,
-       SDL_EVENT_RESERVED6,
-       SDL_EVENT_RESERVED7,
-       SDL_USEREVENT = 24,
-       SDL_NUMEVENTS = 32
-} SDL_EventType;
-
-#define SDL_EVENTMASK(X)	(1<<(X))
-typedef enum {
-	SDL_ACTIVEEVENTMASK	= SDL_EVENTMASK(SDL_ACTIVEEVENT),
-	SDL_KEYDOWNMASK		= SDL_EVENTMASK(SDL_KEYDOWN),
-	SDL_KEYUPMASK		= SDL_EVENTMASK(SDL_KEYUP),
-	SDL_KEYEVENTMASK	= SDL_EVENTMASK(SDL_KEYDOWN)|
-	                          SDL_EVENTMASK(SDL_KEYUP),
-	SDL_MOUSEMOTIONMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION),
-	SDL_MOUSEBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
-	SDL_MOUSEBUTTONUPMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
-	SDL_MOUSEEVENTMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION)|
-	                          SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
-	                          SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
-	SDL_JOYAXISMOTIONMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION),
-	SDL_JOYBALLMOTIONMASK	= SDL_EVENTMASK(SDL_JOYBALLMOTION),
-	SDL_JOYHATMOTIONMASK	= SDL_EVENTMASK(SDL_JOYHATMOTION),
-	SDL_JOYBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
-	SDL_JOYBUTTONUPMASK	= SDL_EVENTMASK(SDL_JOYBUTTONUP),
-	SDL_JOYEVENTMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION)|
-	                          SDL_EVENTMASK(SDL_JOYBALLMOTION)|
-	                          SDL_EVENTMASK(SDL_JOYHATMOTION)|
-	                          SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
-	                          SDL_EVENTMASK(SDL_JOYBUTTONUP),
-	SDL_VIDEORESIZEMASK	= SDL_EVENTMASK(SDL_VIDEORESIZE),
-	SDL_VIDEOEXPOSEMASK	= SDL_EVENTMASK(SDL_VIDEOEXPOSE),
-	SDL_QUITMASK		= SDL_EVENTMASK(SDL_QUIT),
-	SDL_SYSWMEVENTMASK	= SDL_EVENTMASK(SDL_SYSWMEVENT)
-} SDL_EventMask ;
-#define SDL_ALLEVENTS		0xFFFFFFFF
-
-typedef struct SDL_ActiveEvent {
-	Uint8 type;
-	Uint8 gain;
-	Uint8 state;
-} SDL_ActiveEvent;
-
-typedef struct SDL_KeyboardEvent {
-	Uint8 type;	
-	Uint8 which;
-	Uint8 state;
-	SDL_keysym keysym;
-} SDL_KeyboardEvent;
-
-typedef struct SDL_MouseMotionEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 state;
-	Uint16 x, y;
-	Sint16 xrel;
-	Sint16 yrel;
-} SDL_MouseMotionEvent;
-
-typedef struct SDL_MouseButtonEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 button;
-	Uint8 state;
-	Uint16 x, y;
-} SDL_MouseButtonEvent;
-
-typedef struct SDL_JoyAxisEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 axis;
-	Sint16 value;
-} SDL_JoyAxisEvent;
-
-typedef struct SDL_JoyBallEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 ball;
-	Sint16 xrel;
-	Sint16 yrel;
-} SDL_JoyBallEvent;
-
-typedef struct SDL_JoyHatEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 hat;
-	Uint8 value;
-} SDL_JoyHatEvent;
-
-typedef struct SDL_JoyButtonEvent {
-	Uint8 type;
-	Uint8 which;
-	Uint8 button;
-	Uint8 state;
-} SDL_JoyButtonEvent;
-
-typedef struct SDL_ResizeEvent {
-	Uint8 type;
-	int w;
-	int h;
-} SDL_ResizeEvent;
-
-typedef struct SDL_ExposeEvent {
-	Uint8 type;
-} SDL_ExposeEvent;
-
-typedef struct SDL_QuitEvent {
-	Uint8 type;
-} SDL_QuitEvent;
-
-typedef struct SDL_UserEvent {
-	Uint8 type;
-	int code;
-	void *data1;
-	void *data2;
-} SDL_UserEvent;
-
-struct SDL_SysWMmsg;
-typedef struct SDL_SysWMmsg SDL_SysWMmsg;
-typedef struct SDL_SysWMEvent {
-	Uint8 type;
-	SDL_SysWMmsg *msg;
-} SDL_SysWMEvent;
-
-typedef union SDL_Event {
-	Uint8 type;
-	SDL_ActiveEvent active;
-	SDL_KeyboardEvent key;
-	SDL_MouseMotionEvent motion;
-	SDL_MouseButtonEvent button;
-	SDL_JoyAxisEvent jaxis;
-	SDL_JoyBallEvent jball;
-	SDL_JoyHatEvent jhat;
-	SDL_JoyButtonEvent jbutton;
-	SDL_ResizeEvent resize;
-	SDL_ExposeEvent expose;
-	SDL_QuitEvent quit;
-	SDL_UserEvent user;
-	SDL_SysWMEvent syswm;
-} SDL_Event;
-
-typedef enum {
-	SDL_ADDEVENT,
-	SDL_PEEKEVENT,
-	SDL_GETEVENT
-} SDL_eventaction;
-
-typedef int (NV_SDL_APIENTRY *SDL_EventFilter)(const SDL_Event *event);
+#if NV_SDL_VERSION == NV_SDL_12
+#include <nv/lib/detail/sdl_events_12.inc>
+#else
+#include <nv/lib/detail/sdl_events_20.inc>
+#endif
+
 
 #define SDL_QUERY	-1
@@ -902,4 +695,8 @@
 
 /* SDL_timer.h defines */
+#if  NV_SDL_VERSION == NV_SDL_20
+typedef Uint32 (NV_SDL_APIENTRY *SDL_TimerCallback)(Uint32 interval, void *param);
+typedef int SDL_TimerID;
+#else
 #define SDL_TIMESLICE		10
 #define TIMER_RESOLUTION	10
@@ -907,10 +704,7 @@
 typedef Uint32 (NV_SDL_APIENTRY *SDL_NewTimerCallback)(Uint32 interval, void *param);
 typedef struct _SDL_TimerID *SDL_TimerID;
+#endif
 
 /* SDL_version.h defines */
-#define SDL_MAJOR_VERSION	1
-#define SDL_MINOR_VERSION	2
-#define SDL_PATCHLEVEL		15 
-
 typedef struct SDL_version {
 	Uint8 major;
@@ -918,4 +712,14 @@
 	Uint8 patch;
 } SDL_version;
+
+#if  NV_SDL_VERSION == NV_SDL_20
+#define SDL_MAJOR_VERSION   2
+#define SDL_MINOR_VERSION   0
+#define SDL_PATCHLEVEL      0 
+#else
+#define SDL_MAJOR_VERSION   1
+#define SDL_MINOR_VERSION   2
+#define SDL_PATCHLEVEL      15 
+#endif
 
 #if defined(NV_SDL_DYNAMIC)
@@ -947,4 +751,10 @@
  
 }
+#define SDL_VERSIONNUM(X, Y, Z)                     \
+	((X)*1000 + (Y)*100 + (Z)) 
+#define SDL_COMPILEDVERSION \
+	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
+#define SDL_VERSION_ATLEAST(X, Y, Z) \
+	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
 
 namespace nv {
