src/SDL12_compat.c
changeset 77 ce9a1f04bb36
parent 76 76970160f0fb
child 78 faf3d269ede6
     1.1 --- a/src/SDL12_compat.c	Wed Feb 20 11:56:40 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Wed Feb 20 23:56:10 2019 -0500
     1.3 @@ -249,6 +249,269 @@
     1.4  
     1.5  typedef enum
     1.6  {
     1.7 +    SDLK12_UNKNOWN = 0,
     1.8 +    SDLK12_FIRST = 0,
     1.9 +    SDLK12_BACKSPACE = 8,
    1.10 +    SDLK12_TAB = 9,
    1.11 +    SDLK12_CLEAR = 12,
    1.12 +    SDLK12_RETURN = 13,
    1.13 +    SDLK12_PAUSE = 19,
    1.14 +    SDLK12_ESCAPE = 27,
    1.15 +    SDLK12_SPACE = 32,
    1.16 +    SDLK12_EXCLAIM = 33,
    1.17 +    SDLK12_QUOTEDBL = 34,
    1.18 +    SDLK12_HASH = 35,
    1.19 +    SDLK12_DOLLAR = 36,
    1.20 +    SDLK12_AMPERSAND = 38,
    1.21 +    SDLK12_QUOTE = 39,
    1.22 +    SDLK12_LEFTPAREN = 40,
    1.23 +    SDLK12_RIGHTPAREN = 41,
    1.24 +    SDLK12_ASTERISK = 42,
    1.25 +    SDLK12_PLUS = 43,
    1.26 +    SDLK12_COMMA = 44,
    1.27 +    SDLK12_MINUS = 45,
    1.28 +    SDLK12_PERIOD = 46,
    1.29 +    SDLK12_SLASH = 47,
    1.30 +    SDLK12_0 = 48,
    1.31 +    SDLK12_1 = 49,
    1.32 +    SDLK12_2 = 50,
    1.33 +    SDLK12_3 = 51,
    1.34 +    SDLK12_4 = 52,
    1.35 +    SDLK12_5 = 53,
    1.36 +    SDLK12_6 = 54,
    1.37 +    SDLK12_7 = 55,
    1.38 +    SDLK12_8 = 56,
    1.39 +    SDLK12_9 = 57,
    1.40 +    SDLK12_COLON = 58,
    1.41 +    SDLK12_SEMICOLON = 59,
    1.42 +    SDLK12_LESS = 60,
    1.43 +    SDLK12_EQUALS = 61,
    1.44 +    SDLK12_GREATER = 62,
    1.45 +    SDLK12_QUESTION = 63,
    1.46 +    SDLK12_AT = 64,
    1.47 +    SDLK12_LEFTBRACKET = 91,
    1.48 +    SDLK12_BACKSLASH = 92,
    1.49 +    SDLK12_RIGHTBRACKET = 93,
    1.50 +    SDLK12_CARET = 94,
    1.51 +    SDLK12_UNDERSCORE = 95,
    1.52 +    SDLK12_BACKQUOTE = 96,
    1.53 +    SDLK12_a = 97,
    1.54 +    SDLK12_b = 98,
    1.55 +    SDLK12_c = 99,
    1.56 +    SDLK12_d = 100,
    1.57 +    SDLK12_e = 101,
    1.58 +    SDLK12_f = 102,
    1.59 +    SDLK12_g = 103,
    1.60 +    SDLK12_h = 104,
    1.61 +    SDLK12_i = 105,
    1.62 +    SDLK12_j = 106,
    1.63 +    SDLK12_k = 107,
    1.64 +    SDLK12_l = 108,
    1.65 +    SDLK12_m = 109,
    1.66 +    SDLK12_n = 110,
    1.67 +    SDLK12_o = 111,
    1.68 +    SDLK12_p = 112,
    1.69 +    SDLK12_q = 113,
    1.70 +    SDLK12_r = 114,
    1.71 +    SDLK12_s = 115,
    1.72 +    SDLK12_t = 116,
    1.73 +    SDLK12_u = 117,
    1.74 +    SDLK12_v = 118,
    1.75 +    SDLK12_w = 119,
    1.76 +    SDLK12_x = 120,
    1.77 +    SDLK12_y = 121,
    1.78 +    SDLK12_z = 122,
    1.79 +    SDLK12_DELETE = 127,
    1.80 +    SDLK12_WORLD_0 = 160,
    1.81 +    SDLK12_WORLD_1 = 161,
    1.82 +    SDLK12_WORLD_2 = 162,
    1.83 +    SDLK12_WORLD_3 = 163,
    1.84 +    SDLK12_WORLD_4 = 164,
    1.85 +    SDLK12_WORLD_5 = 165,
    1.86 +    SDLK12_WORLD_6 = 166,
    1.87 +    SDLK12_WORLD_7 = 167,
    1.88 +    SDLK12_WORLD_8 = 168,
    1.89 +    SDLK12_WORLD_9 = 169,
    1.90 +    SDLK12_WORLD_10 = 170,
    1.91 +    SDLK12_WORLD_11 = 171,
    1.92 +    SDLK12_WORLD_12 = 172,
    1.93 +    SDLK12_WORLD_13 = 173,
    1.94 +    SDLK12_WORLD_14 = 174,
    1.95 +    SDLK12_WORLD_15 = 175,
    1.96 +    SDLK12_WORLD_16 = 176,
    1.97 +    SDLK12_WORLD_17 = 177,
    1.98 +    SDLK12_WORLD_18 = 178,
    1.99 +    SDLK12_WORLD_19 = 179,
   1.100 +    SDLK12_WORLD_20 = 180,
   1.101 +    SDLK12_WORLD_21 = 181,
   1.102 +    SDLK12_WORLD_22 = 182,
   1.103 +    SDLK12_WORLD_23 = 183,
   1.104 +    SDLK12_WORLD_24 = 184,
   1.105 +    SDLK12_WORLD_25 = 185,
   1.106 +    SDLK12_WORLD_26 = 186,
   1.107 +    SDLK12_WORLD_27 = 187,
   1.108 +    SDLK12_WORLD_28 = 188,
   1.109 +    SDLK12_WORLD_29 = 189,
   1.110 +    SDLK12_WORLD_30 = 190,
   1.111 +    SDLK12_WORLD_31 = 191,
   1.112 +    SDLK12_WORLD_32 = 192,
   1.113 +    SDLK12_WORLD_33 = 193,
   1.114 +    SDLK12_WORLD_34 = 194,
   1.115 +    SDLK12_WORLD_35 = 195,
   1.116 +    SDLK12_WORLD_36 = 196,
   1.117 +    SDLK12_WORLD_37 = 197,
   1.118 +    SDLK12_WORLD_38 = 198,
   1.119 +    SDLK12_WORLD_39 = 199,
   1.120 +    SDLK12_WORLD_40 = 200,
   1.121 +    SDLK12_WORLD_41 = 201,
   1.122 +    SDLK12_WORLD_42 = 202,
   1.123 +    SDLK12_WORLD_43 = 203,
   1.124 +    SDLK12_WORLD_44 = 204,
   1.125 +    SDLK12_WORLD_45 = 205,
   1.126 +    SDLK12_WORLD_46 = 206,
   1.127 +    SDLK12_WORLD_47 = 207,
   1.128 +    SDLK12_WORLD_48 = 208,
   1.129 +    SDLK12_WORLD_49 = 209,
   1.130 +    SDLK12_WORLD_50 = 210,
   1.131 +    SDLK12_WORLD_51 = 211,
   1.132 +    SDLK12_WORLD_52 = 212,
   1.133 +    SDLK12_WORLD_53 = 213,
   1.134 +    SDLK12_WORLD_54 = 214,
   1.135 +    SDLK12_WORLD_55 = 215,
   1.136 +    SDLK12_WORLD_56 = 216,
   1.137 +    SDLK12_WORLD_57 = 217,
   1.138 +    SDLK12_WORLD_58 = 218,
   1.139 +    SDLK12_WORLD_59 = 219,
   1.140 +    SDLK12_WORLD_60 = 220,
   1.141 +    SDLK12_WORLD_61 = 221,
   1.142 +    SDLK12_WORLD_62 = 222,
   1.143 +    SDLK12_WORLD_63 = 223,
   1.144 +    SDLK12_WORLD_64 = 224,
   1.145 +    SDLK12_WORLD_65 = 225,
   1.146 +    SDLK12_WORLD_66 = 226,
   1.147 +    SDLK12_WORLD_67 = 227,
   1.148 +    SDLK12_WORLD_68 = 228,
   1.149 +    SDLK12_WORLD_69 = 229,
   1.150 +    SDLK12_WORLD_70 = 230,
   1.151 +    SDLK12_WORLD_71 = 231,
   1.152 +    SDLK12_WORLD_72 = 232,
   1.153 +    SDLK12_WORLD_73 = 233,
   1.154 +    SDLK12_WORLD_74 = 234,
   1.155 +    SDLK12_WORLD_75 = 235,
   1.156 +    SDLK12_WORLD_76 = 236,
   1.157 +    SDLK12_WORLD_77 = 237,
   1.158 +    SDLK12_WORLD_78 = 238,
   1.159 +    SDLK12_WORLD_79 = 239,
   1.160 +    SDLK12_WORLD_80 = 240,
   1.161 +    SDLK12_WORLD_81 = 241,
   1.162 +    SDLK12_WORLD_82 = 242,
   1.163 +    SDLK12_WORLD_83 = 243,
   1.164 +    SDLK12_WORLD_84 = 244,
   1.165 +    SDLK12_WORLD_85 = 245,
   1.166 +    SDLK12_WORLD_86 = 246,
   1.167 +    SDLK12_WORLD_87 = 247,
   1.168 +    SDLK12_WORLD_88 = 248,
   1.169 +    SDLK12_WORLD_89 = 249,
   1.170 +    SDLK12_WORLD_90 = 250,
   1.171 +    SDLK12_WORLD_91 = 251,
   1.172 +    SDLK12_WORLD_92 = 252,
   1.173 +    SDLK12_WORLD_93 = 253,
   1.174 +    SDLK12_WORLD_94 = 254,
   1.175 +    SDLK12_WORLD_95 = 255,
   1.176 +    SDLK12_KP0 = 256,
   1.177 +    SDLK12_KP1 = 257,
   1.178 +    SDLK12_KP2 = 258,
   1.179 +    SDLK12_KP3 = 259,
   1.180 +    SDLK12_KP4 = 260,
   1.181 +    SDLK12_KP5 = 261,
   1.182 +    SDLK12_KP6 = 262,
   1.183 +    SDLK12_KP7 = 263,
   1.184 +    SDLK12_KP8 = 264,
   1.185 +    SDLK12_KP9 = 265,
   1.186 +    SDLK12_KP_PERIOD = 266,
   1.187 +    SDLK12_KP_DIVIDE = 267,
   1.188 +    SDLK12_KP_MULTIPLY = 268,
   1.189 +    SDLK12_KP_MINUS = 269,
   1.190 +    SDLK12_KP_PLUS = 270,
   1.191 +    SDLK12_KP_ENTER = 271,
   1.192 +    SDLK12_KP_EQUALS = 272,
   1.193 +    SDLK12_UP = 273,
   1.194 +    SDLK12_DOWN = 274,
   1.195 +    SDLK12_RIGHT = 275,
   1.196 +    SDLK12_LEFT = 276,
   1.197 +    SDLK12_INSERT = 277,
   1.198 +    SDLK12_HOME = 278,
   1.199 +    SDLK12_END = 279,
   1.200 +    SDLK12_PAGEUP = 280,
   1.201 +    SDLK12_PAGEDOWN = 281,
   1.202 +    SDLK12_F1 = 282,
   1.203 +    SDLK12_F2 = 283,
   1.204 +    SDLK12_F3 = 284,
   1.205 +    SDLK12_F4 = 285,
   1.206 +    SDLK12_F5 = 286,
   1.207 +    SDLK12_F6 = 287,
   1.208 +    SDLK12_F7 = 288,
   1.209 +    SDLK12_F8 = 289,
   1.210 +    SDLK12_F9 = 290,
   1.211 +    SDLK12_F10 = 291,
   1.212 +    SDLK12_F11 = 292,
   1.213 +    SDLK12_F12 = 293,
   1.214 +    SDLK12_F13 = 294,
   1.215 +    SDLK12_F14 = 295,
   1.216 +    SDLK12_F15 = 296,
   1.217 +    SDLK12_NUMLOCK = 300,
   1.218 +    SDLK12_CAPSLOCK = 301,
   1.219 +    SDLK12_SCROLLOCK = 302,
   1.220 +    SDLK12_RSHIFT = 303,
   1.221 +    SDLK12_LSHIFT = 304,
   1.222 +    SDLK12_RCTRL = 305,
   1.223 +    SDLK12_LCTRL = 306,
   1.224 +    SDLK12_RALT = 307,
   1.225 +    SDLK12_LALT = 308,
   1.226 +    SDLK12_RMETA = 309,
   1.227 +    SDLK12_LMETA = 310,
   1.228 +    SDLK12_LSUPER = 311,
   1.229 +    SDLK12_RSUPER = 312,
   1.230 +    SDLK12_MODE = 313,
   1.231 +    SDLK12_COMPOSE = 314,
   1.232 +    SDLK12_HELP = 315,
   1.233 +    SDLK12_PRINT = 316,
   1.234 +    SDLK12_SYSREQ = 317,
   1.235 +    SDLK12_BREAK = 318,
   1.236 +    SDLK12_MENU = 319,
   1.237 +    SDLK12_POWER = 320,
   1.238 +    SDLK12_EURO = 321,
   1.239 +    SDLK12_UNDO = 322,
   1.240 +    SDLK12_LAST
   1.241 +} SDL12Key;
   1.242 +
   1.243 +typedef enum
   1.244 +{
   1.245 +    KMOD12_NONE  = 0x0000,
   1.246 +    KMOD12_LSHIFT = 0x0001,
   1.247 +    KMOD12_RSHIFT = 0x0002,
   1.248 +    KMOD12_LCTRL = 0x0040,
   1.249 +    KMOD12_RCTRL = 0x0080,
   1.250 +    KMOD12_LALT = 0x0100,
   1.251 +    KMOD12_RALT = 0x0200,
   1.252 +    KMOD12_LMETA = 0x0400,
   1.253 +    KMOD12_RMETA = 0x0800,
   1.254 +    KMOD12_NUM = 0x1000,
   1.255 +    KMOD12_CAPS = 0x2000,
   1.256 +    KMOD12_MODE = 0x4000,
   1.257 +    KMOD12_RESERVED = 0x8000
   1.258 +} SDL12Mod;
   1.259 +
   1.260 +typedef struct SDL12_keysym
   1.261 +{
   1.262 +    Uint8 scancode;
   1.263 +    SDL12Key sym;
   1.264 +    SDL12Mod mod;
   1.265 +    Uint16 unicode;
   1.266 +} SDL12_keysym;
   1.267 +
   1.268 +typedef enum
   1.269 +{
   1.270      SDL12_NOEVENT = 0,
   1.271      SDL12_ACTIVEEVENT,
   1.272      SDL12_KEYDOWN,
   1.273 @@ -288,7 +551,7 @@
   1.274      Uint8 type;
   1.275      Uint8 which;
   1.276      Uint8 state;
   1.277 -    //FIXME: SDL12_keysym keysym;
   1.278 +    SDL12_keysym keysym;
   1.279  } SDL12_KeyboardEvent;
   1.280  
   1.281  typedef struct
   1.282 @@ -1076,6 +1339,342 @@
   1.283      return retval;
   1.284  }
   1.285  
   1.286 +DECLSPEC char * SDLCALL
   1.287 +SDL_GetKeyName(SDL12Key key)
   1.288 +{
   1.289 +    switch (key) {
   1.290 +        #define CASESDLK12TONAME(k, n) case k: return (char *) n
   1.291 +	    CASESDLK12TONAME(SDLK12_BACKSPACE, "backspace");
   1.292 +	    CASESDLK12TONAME(SDLK12_TAB, "tab");
   1.293 +	    CASESDLK12TONAME(SDLK12_CLEAR, "clear");
   1.294 +	    CASESDLK12TONAME(SDLK12_RETURN, "return");
   1.295 +	    CASESDLK12TONAME(SDLK12_PAUSE, "pause");
   1.296 +	    CASESDLK12TONAME(SDLK12_ESCAPE, "escape");
   1.297 +	    CASESDLK12TONAME(SDLK12_SPACE, "space");
   1.298 +	    CASESDLK12TONAME(SDLK12_EXCLAIM, "!");
   1.299 +	    CASESDLK12TONAME(SDLK12_QUOTEDBL, "\"");
   1.300 +	    CASESDLK12TONAME(SDLK12_HASH, "#");
   1.301 +	    CASESDLK12TONAME(SDLK12_DOLLAR, "$");
   1.302 +	    CASESDLK12TONAME(SDLK12_AMPERSAND, "&");
   1.303 +	    CASESDLK12TONAME(SDLK12_QUOTE, "'");
   1.304 +	    CASESDLK12TONAME(SDLK12_LEFTPAREN, "(");
   1.305 +	    CASESDLK12TONAME(SDLK12_RIGHTPAREN, ")");
   1.306 +	    CASESDLK12TONAME(SDLK12_ASTERISK, "*");
   1.307 +	    CASESDLK12TONAME(SDLK12_PLUS, "+");
   1.308 +	    CASESDLK12TONAME(SDLK12_COMMA, ",");
   1.309 +	    CASESDLK12TONAME(SDLK12_MINUS, "-");
   1.310 +	    CASESDLK12TONAME(SDLK12_PERIOD, ".");
   1.311 +	    CASESDLK12TONAME(SDLK12_SLASH, "/");
   1.312 +	    CASESDLK12TONAME(SDLK12_0, "0");
   1.313 +	    CASESDLK12TONAME(SDLK12_1, "1");
   1.314 +	    CASESDLK12TONAME(SDLK12_2, "2");
   1.315 +	    CASESDLK12TONAME(SDLK12_3, "3");
   1.316 +	    CASESDLK12TONAME(SDLK12_4, "4");
   1.317 +	    CASESDLK12TONAME(SDLK12_5, "5");
   1.318 +	    CASESDLK12TONAME(SDLK12_6, "6");
   1.319 +	    CASESDLK12TONAME(SDLK12_7, "7");
   1.320 +	    CASESDLK12TONAME(SDLK12_8, "8");
   1.321 +	    CASESDLK12TONAME(SDLK12_9, "9");
   1.322 +	    CASESDLK12TONAME(SDLK12_COLON, ":");
   1.323 +	    CASESDLK12TONAME(SDLK12_SEMICOLON, ");");
   1.324 +	    CASESDLK12TONAME(SDLK12_LESS, "<");
   1.325 +	    CASESDLK12TONAME(SDLK12_EQUALS, "=");
   1.326 +	    CASESDLK12TONAME(SDLK12_GREATER, ">");
   1.327 +	    CASESDLK12TONAME(SDLK12_QUESTION, "?");
   1.328 +	    CASESDLK12TONAME(SDLK12_AT, "@");
   1.329 +	    CASESDLK12TONAME(SDLK12_LEFTBRACKET, "[");
   1.330 +	    CASESDLK12TONAME(SDLK12_BACKSLASH, "\\");
   1.331 +	    CASESDLK12TONAME(SDLK12_RIGHTBRACKET, "]");
   1.332 +	    CASESDLK12TONAME(SDLK12_CARET, "^");
   1.333 +	    CASESDLK12TONAME(SDLK12_UNDERSCORE, "_");
   1.334 +	    CASESDLK12TONAME(SDLK12_BACKQUOTE, "`");
   1.335 +	    CASESDLK12TONAME(SDLK12_a, "a");
   1.336 +	    CASESDLK12TONAME(SDLK12_b, "b");
   1.337 +	    CASESDLK12TONAME(SDLK12_c, "c");
   1.338 +	    CASESDLK12TONAME(SDLK12_d, "d");
   1.339 +	    CASESDLK12TONAME(SDLK12_e, "e");
   1.340 +	    CASESDLK12TONAME(SDLK12_f, "f");
   1.341 +	    CASESDLK12TONAME(SDLK12_g, "g");
   1.342 +	    CASESDLK12TONAME(SDLK12_h, "h");
   1.343 +	    CASESDLK12TONAME(SDLK12_i, "i");
   1.344 +	    CASESDLK12TONAME(SDLK12_j, "j");
   1.345 +	    CASESDLK12TONAME(SDLK12_k, "k");
   1.346 +	    CASESDLK12TONAME(SDLK12_l, "l");
   1.347 +	    CASESDLK12TONAME(SDLK12_m, "m");
   1.348 +	    CASESDLK12TONAME(SDLK12_n, "n");
   1.349 +	    CASESDLK12TONAME(SDLK12_o, "o");
   1.350 +	    CASESDLK12TONAME(SDLK12_p, "p");
   1.351 +	    CASESDLK12TONAME(SDLK12_q, "q");
   1.352 +	    CASESDLK12TONAME(SDLK12_r, "r");
   1.353 +	    CASESDLK12TONAME(SDLK12_s, "s");
   1.354 +	    CASESDLK12TONAME(SDLK12_t, "t");
   1.355 +	    CASESDLK12TONAME(SDLK12_u, "u");
   1.356 +	    CASESDLK12TONAME(SDLK12_v, "v");
   1.357 +	    CASESDLK12TONAME(SDLK12_w, "w");
   1.358 +	    CASESDLK12TONAME(SDLK12_x, "x");
   1.359 +	    CASESDLK12TONAME(SDLK12_y, "y");
   1.360 +	    CASESDLK12TONAME(SDLK12_z, "z");
   1.361 +	    CASESDLK12TONAME(SDLK12_DELETE, "delete");
   1.362 +
   1.363 +	    CASESDLK12TONAME(SDLK12_WORLD_0, "world 0");
   1.364 +	    CASESDLK12TONAME(SDLK12_WORLD_1, "world 1");
   1.365 +	    CASESDLK12TONAME(SDLK12_WORLD_2, "world 2");
   1.366 +	    CASESDLK12TONAME(SDLK12_WORLD_3, "world 3");
   1.367 +	    CASESDLK12TONAME(SDLK12_WORLD_4, "world 4");
   1.368 +	    CASESDLK12TONAME(SDLK12_WORLD_5, "world 5");
   1.369 +	    CASESDLK12TONAME(SDLK12_WORLD_6, "world 6");
   1.370 +	    CASESDLK12TONAME(SDLK12_WORLD_7, "world 7");
   1.371 +	    CASESDLK12TONAME(SDLK12_WORLD_8, "world 8");
   1.372 +	    CASESDLK12TONAME(SDLK12_WORLD_9, "world 9");
   1.373 +	    CASESDLK12TONAME(SDLK12_WORLD_10, "world 10");
   1.374 +	    CASESDLK12TONAME(SDLK12_WORLD_11, "world 11");
   1.375 +	    CASESDLK12TONAME(SDLK12_WORLD_12, "world 12");
   1.376 +	    CASESDLK12TONAME(SDLK12_WORLD_13, "world 13");
   1.377 +	    CASESDLK12TONAME(SDLK12_WORLD_14, "world 14");
   1.378 +	    CASESDLK12TONAME(SDLK12_WORLD_15, "world 15");
   1.379 +	    CASESDLK12TONAME(SDLK12_WORLD_16, "world 16");
   1.380 +	    CASESDLK12TONAME(SDLK12_WORLD_17, "world 17");
   1.381 +	    CASESDLK12TONAME(SDLK12_WORLD_18, "world 18");
   1.382 +	    CASESDLK12TONAME(SDLK12_WORLD_19, "world 19");
   1.383 +	    CASESDLK12TONAME(SDLK12_WORLD_20, "world 20");
   1.384 +	    CASESDLK12TONAME(SDLK12_WORLD_21, "world 21");
   1.385 +	    CASESDLK12TONAME(SDLK12_WORLD_22, "world 22");
   1.386 +	    CASESDLK12TONAME(SDLK12_WORLD_23, "world 23");
   1.387 +	    CASESDLK12TONAME(SDLK12_WORLD_24, "world 24");
   1.388 +	    CASESDLK12TONAME(SDLK12_WORLD_25, "world 25");
   1.389 +	    CASESDLK12TONAME(SDLK12_WORLD_26, "world 26");
   1.390 +	    CASESDLK12TONAME(SDLK12_WORLD_27, "world 27");
   1.391 +	    CASESDLK12TONAME(SDLK12_WORLD_28, "world 28");
   1.392 +	    CASESDLK12TONAME(SDLK12_WORLD_29, "world 29");
   1.393 +	    CASESDLK12TONAME(SDLK12_WORLD_30, "world 30");
   1.394 +	    CASESDLK12TONAME(SDLK12_WORLD_31, "world 31");
   1.395 +	    CASESDLK12TONAME(SDLK12_WORLD_32, "world 32");
   1.396 +	    CASESDLK12TONAME(SDLK12_WORLD_33, "world 33");
   1.397 +	    CASESDLK12TONAME(SDLK12_WORLD_34, "world 34");
   1.398 +	    CASESDLK12TONAME(SDLK12_WORLD_35, "world 35");
   1.399 +	    CASESDLK12TONAME(SDLK12_WORLD_36, "world 36");
   1.400 +	    CASESDLK12TONAME(SDLK12_WORLD_37, "world 37");
   1.401 +	    CASESDLK12TONAME(SDLK12_WORLD_38, "world 38");
   1.402 +	    CASESDLK12TONAME(SDLK12_WORLD_39, "world 39");
   1.403 +	    CASESDLK12TONAME(SDLK12_WORLD_40, "world 40");
   1.404 +	    CASESDLK12TONAME(SDLK12_WORLD_41, "world 41");
   1.405 +	    CASESDLK12TONAME(SDLK12_WORLD_42, "world 42");
   1.406 +	    CASESDLK12TONAME(SDLK12_WORLD_43, "world 43");
   1.407 +	    CASESDLK12TONAME(SDLK12_WORLD_44, "world 44");
   1.408 +	    CASESDLK12TONAME(SDLK12_WORLD_45, "world 45");
   1.409 +	    CASESDLK12TONAME(SDLK12_WORLD_46, "world 46");
   1.410 +	    CASESDLK12TONAME(SDLK12_WORLD_47, "world 47");
   1.411 +	    CASESDLK12TONAME(SDLK12_WORLD_48, "world 48");
   1.412 +	    CASESDLK12TONAME(SDLK12_WORLD_49, "world 49");
   1.413 +	    CASESDLK12TONAME(SDLK12_WORLD_50, "world 50");
   1.414 +	    CASESDLK12TONAME(SDLK12_WORLD_51, "world 51");
   1.415 +	    CASESDLK12TONAME(SDLK12_WORLD_52, "world 52");
   1.416 +	    CASESDLK12TONAME(SDLK12_WORLD_53, "world 53");
   1.417 +	    CASESDLK12TONAME(SDLK12_WORLD_54, "world 54");
   1.418 +	    CASESDLK12TONAME(SDLK12_WORLD_55, "world 55");
   1.419 +	    CASESDLK12TONAME(SDLK12_WORLD_56, "world 56");
   1.420 +	    CASESDLK12TONAME(SDLK12_WORLD_57, "world 57");
   1.421 +	    CASESDLK12TONAME(SDLK12_WORLD_58, "world 58");
   1.422 +	    CASESDLK12TONAME(SDLK12_WORLD_59, "world 59");
   1.423 +	    CASESDLK12TONAME(SDLK12_WORLD_60, "world 60");
   1.424 +	    CASESDLK12TONAME(SDLK12_WORLD_61, "world 61");
   1.425 +	    CASESDLK12TONAME(SDLK12_WORLD_62, "world 62");
   1.426 +	    CASESDLK12TONAME(SDLK12_WORLD_63, "world 63");
   1.427 +	    CASESDLK12TONAME(SDLK12_WORLD_64, "world 64");
   1.428 +	    CASESDLK12TONAME(SDLK12_WORLD_65, "world 65");
   1.429 +	    CASESDLK12TONAME(SDLK12_WORLD_66, "world 66");
   1.430 +	    CASESDLK12TONAME(SDLK12_WORLD_67, "world 67");
   1.431 +	    CASESDLK12TONAME(SDLK12_WORLD_68, "world 68");
   1.432 +	    CASESDLK12TONAME(SDLK12_WORLD_69, "world 69");
   1.433 +	    CASESDLK12TONAME(SDLK12_WORLD_70, "world 70");
   1.434 +	    CASESDLK12TONAME(SDLK12_WORLD_71, "world 71");
   1.435 +	    CASESDLK12TONAME(SDLK12_WORLD_72, "world 72");
   1.436 +	    CASESDLK12TONAME(SDLK12_WORLD_73, "world 73");
   1.437 +	    CASESDLK12TONAME(SDLK12_WORLD_74, "world 74");
   1.438 +	    CASESDLK12TONAME(SDLK12_WORLD_75, "world 75");
   1.439 +	    CASESDLK12TONAME(SDLK12_WORLD_76, "world 76");
   1.440 +	    CASESDLK12TONAME(SDLK12_WORLD_77, "world 77");
   1.441 +	    CASESDLK12TONAME(SDLK12_WORLD_78, "world 78");
   1.442 +	    CASESDLK12TONAME(SDLK12_WORLD_79, "world 79");
   1.443 +	    CASESDLK12TONAME(SDLK12_WORLD_80, "world 80");
   1.444 +	    CASESDLK12TONAME(SDLK12_WORLD_81, "world 81");
   1.445 +	    CASESDLK12TONAME(SDLK12_WORLD_82, "world 82");
   1.446 +	    CASESDLK12TONAME(SDLK12_WORLD_83, "world 83");
   1.447 +	    CASESDLK12TONAME(SDLK12_WORLD_84, "world 84");
   1.448 +	    CASESDLK12TONAME(SDLK12_WORLD_85, "world 85");
   1.449 +	    CASESDLK12TONAME(SDLK12_WORLD_86, "world 86");
   1.450 +	    CASESDLK12TONAME(SDLK12_WORLD_87, "world 87");
   1.451 +	    CASESDLK12TONAME(SDLK12_WORLD_88, "world 88");
   1.452 +	    CASESDLK12TONAME(SDLK12_WORLD_89, "world 89");
   1.453 +	    CASESDLK12TONAME(SDLK12_WORLD_90, "world 90");
   1.454 +	    CASESDLK12TONAME(SDLK12_WORLD_91, "world 91");
   1.455 +	    CASESDLK12TONAME(SDLK12_WORLD_92, "world 92");
   1.456 +	    CASESDLK12TONAME(SDLK12_WORLD_93, "world 93");
   1.457 +	    CASESDLK12TONAME(SDLK12_WORLD_94, "world 94");
   1.458 +	    CASESDLK12TONAME(SDLK12_WORLD_95, "world 95");
   1.459 +
   1.460 +	    CASESDLK12TONAME(SDLK12_KP0, "[0]");
   1.461 +	    CASESDLK12TONAME(SDLK12_KP1, "[1]");
   1.462 +	    CASESDLK12TONAME(SDLK12_KP2, "[2]");
   1.463 +	    CASESDLK12TONAME(SDLK12_KP3, "[3]");
   1.464 +	    CASESDLK12TONAME(SDLK12_KP4, "[4]");
   1.465 +	    CASESDLK12TONAME(SDLK12_KP5, "[5]");
   1.466 +	    CASESDLK12TONAME(SDLK12_KP6, "[6]");
   1.467 +	    CASESDLK12TONAME(SDLK12_KP7, "[7]");
   1.468 +	    CASESDLK12TONAME(SDLK12_KP8, "[8]");
   1.469 +	    CASESDLK12TONAME(SDLK12_KP9, "[9]");
   1.470 +	    CASESDLK12TONAME(SDLK12_KP_PERIOD, "[.]");
   1.471 +	    CASESDLK12TONAME(SDLK12_KP_DIVIDE, "[/]");
   1.472 +	    CASESDLK12TONAME(SDLK12_KP_MULTIPLY, "[*]");
   1.473 +	    CASESDLK12TONAME(SDLK12_KP_MINUS, "[-]");
   1.474 +	    CASESDLK12TONAME(SDLK12_KP_PLUS, "[+]");
   1.475 +	    CASESDLK12TONAME(SDLK12_KP_ENTER, "enter");
   1.476 +	    CASESDLK12TONAME(SDLK12_KP_EQUALS, "equals");
   1.477 +
   1.478 +	    CASESDLK12TONAME(SDLK12_UP, "up");
   1.479 +	    CASESDLK12TONAME(SDLK12_DOWN, "down");
   1.480 +	    CASESDLK12TONAME(SDLK12_RIGHT, "right");
   1.481 +	    CASESDLK12TONAME(SDLK12_LEFT, "left");
   1.482 +	    CASESDLK12TONAME(SDLK12_INSERT, "insert");
   1.483 +	    CASESDLK12TONAME(SDLK12_HOME, "home");
   1.484 +	    CASESDLK12TONAME(SDLK12_END, "end");
   1.485 +	    CASESDLK12TONAME(SDLK12_PAGEUP, "page up");
   1.486 +	    CASESDLK12TONAME(SDLK12_PAGEDOWN, "page down");
   1.487 +
   1.488 +	    CASESDLK12TONAME(SDLK12_F1, "f1");
   1.489 +	    CASESDLK12TONAME(SDLK12_F2, "f2");
   1.490 +	    CASESDLK12TONAME(SDLK12_F3, "f3");
   1.491 +	    CASESDLK12TONAME(SDLK12_F4, "f4");
   1.492 +	    CASESDLK12TONAME(SDLK12_F5, "f5");
   1.493 +	    CASESDLK12TONAME(SDLK12_F6, "f6");
   1.494 +	    CASESDLK12TONAME(SDLK12_F7, "f7");
   1.495 +	    CASESDLK12TONAME(SDLK12_F8, "f8");
   1.496 +	    CASESDLK12TONAME(SDLK12_F9, "f9");
   1.497 +	    CASESDLK12TONAME(SDLK12_F10, "f10");
   1.498 +	    CASESDLK12TONAME(SDLK12_F11, "f11");
   1.499 +	    CASESDLK12TONAME(SDLK12_F12, "f12");
   1.500 +	    CASESDLK12TONAME(SDLK12_F13, "f13");
   1.501 +	    CASESDLK12TONAME(SDLK12_F14, "f14");
   1.502 +	    CASESDLK12TONAME(SDLK12_F15, "f15");
   1.503 +
   1.504 +	    CASESDLK12TONAME(SDLK12_NUMLOCK, "numlock");
   1.505 +	    CASESDLK12TONAME(SDLK12_CAPSLOCK, "caps lock");
   1.506 +	    CASESDLK12TONAME(SDLK12_SCROLLOCK, "scroll lock");
   1.507 +	    CASESDLK12TONAME(SDLK12_RSHIFT, "right shift");
   1.508 +	    CASESDLK12TONAME(SDLK12_LSHIFT, "left shift");
   1.509 +	    CASESDLK12TONAME(SDLK12_RCTRL, "right ctrl");
   1.510 +	    CASESDLK12TONAME(SDLK12_LCTRL, "left ctrl");
   1.511 +	    CASESDLK12TONAME(SDLK12_RALT, "right alt");
   1.512 +	    CASESDLK12TONAME(SDLK12_LALT, "left alt");
   1.513 +	    CASESDLK12TONAME(SDLK12_RMETA, "right meta");
   1.514 +	    CASESDLK12TONAME(SDLK12_LMETA, "left meta");
   1.515 +	    CASESDLK12TONAME(SDLK12_LSUPER, "left super");	/* "Windows" keys */
   1.516 +	    CASESDLK12TONAME(SDLK12_RSUPER, "right super");	
   1.517 +	    CASESDLK12TONAME(SDLK12_MODE, "alt gr");
   1.518 +	    CASESDLK12TONAME(SDLK12_COMPOSE, "compose");
   1.519 +
   1.520 +	    CASESDLK12TONAME(SDLK12_HELP, "help");
   1.521 +	    CASESDLK12TONAME(SDLK12_PRINT, "print screen");
   1.522 +	    CASESDLK12TONAME(SDLK12_SYSREQ, "sys req");
   1.523 +	    CASESDLK12TONAME(SDLK12_BREAK, "break");
   1.524 +	    CASESDLK12TONAME(SDLK12_MENU, "menu");
   1.525 +	    CASESDLK12TONAME(SDLK12_POWER, "power");
   1.526 +	    CASESDLK12TONAME(SDLK12_EURO, "euro");
   1.527 +	    CASESDLK12TONAME(SDLK12_UNDO, "undo");
   1.528 +        #undef CASESDLK12TONAME
   1.529 +        default: break;
   1.530 +    }
   1.531 +
   1.532 +    return (char *) "unknown key";
   1.533 +}
   1.534 +
   1.535 +static SDL12Key
   1.536 +Keysym20to12(const SDL_Keycode keysym20)
   1.537 +{
   1.538 +    if ( ((int) keysym20) < 127 ) {  /* (most of) low-ASCII maps directly */
   1.539 +        if (keysym20 == SDLK_PAUSE) {
   1.540 +            return SDLK12_PAUSE;
   1.541 +        } else if (keysym20 == SDLK_CLEAR) {
   1.542 +            return SDLK12_CLEAR;
   1.543 +        }
   1.544 +        return (SDL12Key) keysym20;
   1.545 +    }
   1.546 +
   1.547 +    switch (keysym20) {
   1.548 +        #define CASEKEYSYM20TO12(k20, k12) case SDLK_##k20: return SDLK12_##k12
   1.549 +        CASEKEYSYM20TO12(KP_0, KP0);
   1.550 +        CASEKEYSYM20TO12(KP_1, KP1);
   1.551 +        CASEKEYSYM20TO12(KP_2, KP2);
   1.552 +        CASEKEYSYM20TO12(KP_3, KP3);
   1.553 +        CASEKEYSYM20TO12(KP_4, KP4);
   1.554 +        CASEKEYSYM20TO12(KP_5, KP5);
   1.555 +        CASEKEYSYM20TO12(KP_6, KP6);
   1.556 +        CASEKEYSYM20TO12(KP_7, KP7);
   1.557 +        CASEKEYSYM20TO12(KP_8, KP8);
   1.558 +        CASEKEYSYM20TO12(KP_9, KP9);
   1.559 +        CASEKEYSYM20TO12(NUMLOCKCLEAR, NUMLOCK);
   1.560 +        CASEKEYSYM20TO12(SCROLLLOCK, SCROLLOCK);
   1.561 +        CASEKEYSYM20TO12(RGUI, RMETA);
   1.562 +        CASEKEYSYM20TO12(LGUI, LMETA);
   1.563 +        CASEKEYSYM20TO12(PRINTSCREEN, PRINT);
   1.564 +        #undef CASEKEYSYM20TO12
   1.565 +
   1.566 +        #define CASEKEYSYM20TO12(k) case SDLK_##k: return SDLK12_##k
   1.567 +        CASEKEYSYM20TO12(CLEAR);
   1.568 +        CASEKEYSYM20TO12(PAUSE);
   1.569 +        CASEKEYSYM20TO12(KP_PERIOD);
   1.570 +        CASEKEYSYM20TO12(KP_DIVIDE);
   1.571 +        CASEKEYSYM20TO12(KP_MULTIPLY);
   1.572 +        CASEKEYSYM20TO12(KP_MINUS);
   1.573 +        CASEKEYSYM20TO12(KP_PLUS);
   1.574 +        CASEKEYSYM20TO12(KP_ENTER);
   1.575 +        CASEKEYSYM20TO12(KP_EQUALS);
   1.576 +        CASEKEYSYM20TO12(UP);
   1.577 +        CASEKEYSYM20TO12(DOWN);
   1.578 +        CASEKEYSYM20TO12(RIGHT);
   1.579 +        CASEKEYSYM20TO12(LEFT);
   1.580 +        CASEKEYSYM20TO12(INSERT);
   1.581 +        CASEKEYSYM20TO12(HOME);
   1.582 +        CASEKEYSYM20TO12(END);
   1.583 +        CASEKEYSYM20TO12(PAGEUP);
   1.584 +        CASEKEYSYM20TO12(PAGEDOWN);
   1.585 +        CASEKEYSYM20TO12(F1);
   1.586 +        CASEKEYSYM20TO12(F2);
   1.587 +        CASEKEYSYM20TO12(F3);
   1.588 +        CASEKEYSYM20TO12(F4);
   1.589 +        CASEKEYSYM20TO12(F5);
   1.590 +        CASEKEYSYM20TO12(F6);
   1.591 +        CASEKEYSYM20TO12(F7);
   1.592 +        CASEKEYSYM20TO12(F8);
   1.593 +        CASEKEYSYM20TO12(F9);
   1.594 +        CASEKEYSYM20TO12(F10);
   1.595 +        CASEKEYSYM20TO12(F11);
   1.596 +        CASEKEYSYM20TO12(F12);
   1.597 +        CASEKEYSYM20TO12(F13);
   1.598 +        CASEKEYSYM20TO12(F14);
   1.599 +        CASEKEYSYM20TO12(F15);
   1.600 +        CASEKEYSYM20TO12(CAPSLOCK);
   1.601 +        CASEKEYSYM20TO12(RSHIFT);
   1.602 +        CASEKEYSYM20TO12(LSHIFT);
   1.603 +        CASEKEYSYM20TO12(RCTRL);
   1.604 +        CASEKEYSYM20TO12(LCTRL);
   1.605 +        CASEKEYSYM20TO12(RALT);
   1.606 +        CASEKEYSYM20TO12(LALT);
   1.607 +        CASEKEYSYM20TO12(MODE);
   1.608 +        CASEKEYSYM20TO12(HELP);
   1.609 +        CASEKEYSYM20TO12(SYSREQ);;
   1.610 +        CASEKEYSYM20TO12(MENU);
   1.611 +        CASEKEYSYM20TO12(POWER);
   1.612 +        CASEKEYSYM20TO12(UNDO);
   1.613 +        #undef CASEKEYSYM20TO12
   1.614 +        default: break;
   1.615 +    }
   1.616 +
   1.617 +    FIXME("nothing maps to SDLK12_COMPOSE, SDLK12_BREAK, or SDLK12_EURO ...?");
   1.618 +    FIXME("map some of the SDLK12_WORLD keys");
   1.619 +    return SDLK12_UNKNOWN;
   1.620 +}
   1.621 +
   1.622  static int
   1.623  EventFilter20to12(void *data, SDL_Event *event20)
   1.624  {
   1.625 @@ -1152,10 +1751,24 @@
   1.626              break;
   1.627  
   1.628          // !!! FIXME: this is sort of a mess to convert.
   1.629 -        //case SDL_SYSWMEVENT:
   1.630 -
   1.631 -        case SDL_KEYDOWN: FIXME("write me"); return 0;
   1.632 -        case SDL_KEYUP: FIXME("write me"); return 0;
   1.633 +        case SDL_SYSWMEVENT: FIXME("write me"); return 0;
   1.634 +
   1.635 +        case SDL_KEYUP:
   1.636 +        case SDL_KEYDOWN:
   1.637 +            if (event20->key.repeat) {
   1.638 +                return 0;  /* ignore 2.0-style key repeat events */
   1.639 +            }
   1.640 +            event12.key.keysym.sym = Keysym20to12(event20->key.keysym.sym);
   1.641 +            if (event12.key.keysym.sym == SDLK12_UNKNOWN) {
   1.642 +                return 0;  /* drop it if we can't map it */
   1.643 +            }
   1.644 +            event12.type = (event20->type == SDL_KEYDOWN) ? SDL12_KEYDOWN : SDL12_KEYUP;
   1.645 +            event12.key.which = 0;
   1.646 +            event12.key.state = event20->key.state;
   1.647 +            event12.key.keysym.scancode = (event20->key.keysym.scancode < 256) ? (Uint8) event20->key.keysym.scancode : 0;
   1.648 +            event12.key.keysym.mod = event20->key.keysym.mod;  /* these match up between 1.2 and 2.0! */
   1.649 +            event12.key.keysym.unicode = 0;  FIXME("unicode");
   1.650 +            break;
   1.651  
   1.652          case SDL_TEXTEDITING: FIXME("write me"); return 0;
   1.653          case SDL_TEXTINPUT: FIXME("write me"); return 0;
   1.654 @@ -2392,12 +3005,14 @@
   1.655  DECLSPEC int SDLCALL
   1.656  SDL_EnableKeyRepeat(int delay, int interval)
   1.657  {
   1.658 +    FIXME("write me");
   1.659      return 0;
   1.660  }
   1.661  
   1.662  DECLSPEC void SDLCALL
   1.663  SDL_GetKeyRepeat(int *delay, int *interval)
   1.664  {
   1.665 +    FIXME("write me");
   1.666      if (delay) {
   1.667          *delay = SDL12_DEFAULT_REPEAT_DELAY;
   1.668      }