hedgewars/SDLh.pas
branchqmlfrontend
changeset 11403 b894922d58cc
parent 11071 3851ce4f2061
parent 11392 f4e19cd88747
child 11415 05cf35103206
equal deleted inserted replaced
11076:fcbdee9cdd74 11403:b894922d58cc
    55 
    55 
    56 
    56 
    57 (*  SDL  *)
    57 (*  SDL  *)
    58 const
    58 const
    59 {$IFDEF WIN32}
    59 {$IFDEF WIN32}
    60     SDLLibName = 'SDL.dll';
    60     SDLLibName = 'SDL2.dll';
    61     SDL_TTFLibName = 'SDL_ttf.dll';
    61     SDL_TTFLibName = 'SDL2_ttf.dll';
    62     SDL_MixerLibName = 'SDL_mixer.dll';
    62     SDL_MixerLibName = 'SDL2_mixer.dll';
    63     SDL_ImageLibName = 'SDL_image.dll';
    63     SDL_ImageLibName = 'SDL2_image.dll';
    64     SDL_NetLibName = 'SDL_net.dll';
    64     SDL_NetLibName = 'SDL2_net.dll';
    65 {$ELSE}
    65 {$ELSE}
    66     SDLLibName = 'libSDL';
    66     SDLLibName = 'libSDL2';
    67     SDL_TTFLibName = 'libSDL_ttf';
    67     SDL_TTFLibName = 'libSDL2_ttf';
    68     SDL_MixerLibName = 'libSDL_mixer';
    68     SDL_MixerLibName = 'libSDL2_mixer';
    69     SDL_ImageLibName = 'libSDL_image';
    69     SDL_ImageLibName = 'libSDL2_image';
    70     SDL_NetLibName = 'libSDL_net';
    70     SDL_NetLibName = 'libSDL2_net';
    71 {$ENDIF}
    71 {$ENDIF}
    72 
    72 
    73 /////////////////////////////////////////////////////////////////
    73 /////////////////////////////////////////////////////////////////
    74 /////////////////////  CONSTANT DEFINITIONS /////////////////////
    74 /////////////////////  CONSTANT DEFINITIONS /////////////////////
    75 /////////////////////////////////////////////////////////////////
    75 /////////////////////////////////////////////////////////////////
    77     // SDL_Init() flags
    77     // SDL_Init() flags
    78     SDL_INIT_TIMER          = $00000001;
    78     SDL_INIT_TIMER          = $00000001;
    79     SDL_INIT_AUDIO          = $00000010;
    79     SDL_INIT_AUDIO          = $00000010;
    80     SDL_INIT_VIDEO          = $00000020; // implies SDL_INIT_EVENTS (sdl2)
    80     SDL_INIT_VIDEO          = $00000020; // implies SDL_INIT_EVENTS (sdl2)
    81     SDL_INIT_JOYSTICK       = $00000200; // implies SDL_INIT_EVENTS (sdl2)
    81     SDL_INIT_JOYSTICK       = $00000200; // implies SDL_INIT_EVENTS (sdl2)
    82 {$IFDEF SDL2}
       
    83     SDL_INIT_HAPTIC         = $00001000;
    82     SDL_INIT_HAPTIC         = $00001000;
    84     SDL_INIT_GAMECONTROLLER = $00002000; // implies SDL_INIT_JOYSTICK
    83     SDL_INIT_GAMECONTROLLER = $00002000; // implies SDL_INIT_JOYSTICK
    85     SDL_INIT_EVENTS         = $00004000;
    84     SDL_INIT_EVENTS         = $00004000;
    86 {$ELSE}
       
    87     SDL_INIT_CDROM          = $00000100;
       
    88     SDL_INIT_EVENTTHREAD    = $01000000;
       
    89 {$ENDIF}
       
    90     SDL_INIT_NOPARACHUTE    = $00100000;
    85     SDL_INIT_NOPARACHUTE    = $00100000;
    91     //SDL_INIT_EVERYTHING                // unsafe, init subsystems one at a time
    86     //SDL_INIT_EVERYTHING                // unsafe, init subsystems one at a time
    92 
    87 
    93     SDL_ALLEVENTS        = $FFFFFFFF;    // dummy event type to prevent stack corruption
    88     SDL_ALLEVENTS        = $FFFFFFFF;    // dummy event type to prevent stack corruption
    94     SDL_APPINPUTFOCUS    = $02;
    89     SDL_APPINPUTFOCUS    = $02;
    98     SDL_BUTTON_RIGHT     = 3;
    93     SDL_BUTTON_RIGHT     = 3;
    99     SDL_BUTTON_WHEELUP   = 4;
    94     SDL_BUTTON_WHEELUP   = 4;
   100     SDL_BUTTON_WHEELDOWN = 5;
    95     SDL_BUTTON_WHEELDOWN = 5;
   101 
    96 
   102 
    97 
   103 {$IFDEF SDL2}
    98     SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
       
    99     SDL_TEXTINPUTEVENT_TEXT_SIZE   = 32;
       
   100 
   104     // SDL_Event types
   101     // SDL_Event types
   105     // pascal does not support unions as is, so we list here every possible event
   102     // pascal does not support unions as is, so we list here every possible event
   106     // and later associate a struct type each
   103     // and later associate a struct type each
   107     SDL_FIRSTEVENT        = 0;              // type
   104     SDL_FIRSTEVENT        = 0;              // type
   108     SDL_COMMONDEVENT      = 1;              // type and timestamp
   105     SDL_COMMONDEVENT      = 1;              // type and timestamp
   191     SDL_WINDOWEVENT_ENTER        = 10;   //*< Window has gained mouse focus
   188     SDL_WINDOWEVENT_ENTER        = 10;   //*< Window has gained mouse focus
   192     SDL_WINDOWEVENT_LEAVE        = 11;   //*< Window has lost mouse focus
   189     SDL_WINDOWEVENT_LEAVE        = 11;   //*< Window has lost mouse focus
   193     SDL_WINDOWEVENT_FOCUS_GAINED = 12;   //*< Window has gained keyboard focus
   190     SDL_WINDOWEVENT_FOCUS_GAINED = 12;   //*< Window has gained keyboard focus
   194     SDL_WINDOWEVENT_FOCUS_LOST   = 13;   //*< Window has lost keyboard focus
   191     SDL_WINDOWEVENT_FOCUS_LOST   = 13;   //*< Window has lost keyboard focus
   195     SDL_WINDOWEVENT_CLOSE        = 14;   //*< The window manager requests that the window be closed */
   192     SDL_WINDOWEVENT_CLOSE        = 14;   //*< The window manager requests that the window be closed */
   196 {$ELSE}
       
   197     // SDL_Event types
       
   198     SDL_NOEVENT         = 0;
       
   199     SDL_ACTIVEEVENT     = 1;
       
   200     SDL_KEYDOWN         = 2;
       
   201     SDL_KEYUP           = 3;
       
   202     SDL_MOUSEMOTION     = 4;
       
   203     SDL_MOUSEBUTTONDOWN = 5;
       
   204     SDL_MOUSEBUTTONUP   = 6;
       
   205     SDL_JOYAXISMOTION   = 7;
       
   206     SDL_JOYBALLMOTION   = 8;
       
   207     SDL_JOYHATMOTION    = 9;
       
   208     SDL_JOYBUTTONDOWN   = 10;
       
   209     SDL_JOYBUTTONUP     = 11;
       
   210     SDL_QUITEV          = 12;
       
   211     SDL_VIDEORESIZE     = 16;
       
   212 
       
   213     // SDL_Surface flags
       
   214     SDL_SWSURFACE   = $00000000;
       
   215     SDL_HWSURFACE   = $00000001;
       
   216     SDL_OPENGL      = $00000002;
       
   217     SDL_ASYNCBLIT   = $00000004;
       
   218     SDL_RESIZABLE   = $00000010;
       
   219     SDL_NOFRAME     = $00000020;
       
   220     SDL_HWACCEL     = $00000100;
       
   221     SDL_SRCCOLORKEY = $00001000;
       
   222     SDL_RLEACCEL    = $00004000;
       
   223     SDL_SRCALPHA    = $00010000;
       
   224     SDL_ANYFORMAT   = $00100000;
       
   225     SDL_HWPALETTE   = $20000000;
       
   226     SDL_DOUBLEBUF   = $40000000;
       
   227     SDL_FULLSCREEN  = $80000000;
       
   228 {$ENDIF}
       
   229 
   193 
   230 {$IFDEF ENDIAN_LITTLE}
   194 {$IFDEF ENDIAN_LITTLE}
   231     RMask = $000000FF;
   195     RMask = $000000FF;
   232     GMask = $0000FF00;
   196     GMask = $0000FF00;
   233     BMask = $00FF0000;
   197     BMask = $00FF0000;
   259     KMOD_NUM    = $1000;
   223     KMOD_NUM    = $1000;
   260     KMOD_CAPS   = $2000;
   224     KMOD_CAPS   = $2000;
   261     KMOD_MODE   = $4000;
   225     KMOD_MODE   = $4000;
   262 
   226 
   263     {* SDL_mixer *}
   227     {* SDL_mixer *}
   264     MIX_MAX_VOLUME = 128;
   228     MIX_MAX_VOLUME      = 128;
   265     MIX_INIT_FLAC  = $00000001;
   229     MIX_INIT_FLAC       = $00000001;
   266     MIX_INIT_MOD   = $00000002;
   230     MIX_INIT_MOD        = $00000002;
   267     MIX_INIT_MP3   = $00000004;
   231     MIX_INIT_MODPLUG    = $00000004;
   268     MIX_INIT_OGG   = $00000008;
   232     MIX_INIT_MP3        = $00000008;
       
   233     MIX_INIT_OGG        = $00000010;
       
   234     MIX_INIT_FLUIDSYNTH = $00000020;
   269 
   235 
   270     {* SDL_TTF *}
   236     {* SDL_TTF *}
   271     TTF_STYLE_NORMAL = 0;
   237     TTF_STYLE_NORMAL = 0;
   272     TTF_STYLE_BOLD   = 1;
   238     TTF_STYLE_BOLD   = 1;
   273     TTF_STYLE_ITALIC = 2;
   239     TTF_STYLE_ITALIC = 2;
   286     {* SDL_image *}
   252     {* SDL_image *}
   287     IMG_INIT_JPG = $00000001;
   253     IMG_INIT_JPG = $00000001;
   288     IMG_INIT_PNG = $00000002;
   254     IMG_INIT_PNG = $00000002;
   289     IMG_INIT_TIF = $00000004;
   255     IMG_INIT_TIF = $00000004;
   290 
   256 
   291     {* SDL_keysym *}
   257     {* SDL_keycode *}
       
   258     SDLK_UNKNOWN = 0;
   292     SDLK_BACKSPACE = 8;
   259     SDLK_BACKSPACE = 8;
   293     SDLK_RETURN    = 13;
   260     SDLK_RETURN    = 13;
   294     SDLK_ESCAPE    = 27;
   261     SDLK_ESCAPE    = 27;
   295     SDLK_a         = 97;
   262     SDLK_a         = 97;
   296     SDLK_c         = 99;
   263     SDLK_c         = 99;
   307     SDLK_HOME      = 278;
   274     SDLK_HOME      = 278;
   308     SDLK_END       = 279;
   275     SDLK_END       = 279;
   309     SDLK_PAGEUP    = 280;
   276     SDLK_PAGEUP    = 280;
   310     SDLK_PAGEDOWN  = 281;
   277     SDLK_PAGEDOWN  = 281;
   311 
   278 
       
   279     // special keycodes (for modifier keys etc. will have this bit set)
       
   280     SDLK_SCANCODE_MASK = (1 shl 30);
       
   281 
       
   282     SDL_SCANCODE_UNKNOWN = 0;
       
   283     SDL_SCANCODE_A = 4;
       
   284     SDL_SCANCODE_B = 5;
       
   285     SDL_SCANCODE_C = 6;
       
   286     SDL_SCANCODE_D = 7;
       
   287     SDL_SCANCODE_E = 8;
       
   288     SDL_SCANCODE_F = 9;
       
   289     SDL_SCANCODE_G = 10;
       
   290     SDL_SCANCODE_H = 11;
       
   291     SDL_SCANCODE_I = 12;
       
   292     SDL_SCANCODE_J = 13;
       
   293     SDL_SCANCODE_K = 14;
       
   294     SDL_SCANCODE_L = 15;
       
   295     SDL_SCANCODE_M = 16;
       
   296     SDL_SCANCODE_N = 17;
       
   297     SDL_SCANCODE_O = 18;
       
   298     SDL_SCANCODE_P = 19;
       
   299     SDL_SCANCODE_Q = 20;
       
   300     SDL_SCANCODE_R = 21;
       
   301     SDL_SCANCODE_S = 22;
       
   302     SDL_SCANCODE_T = 23;
       
   303     SDL_SCANCODE_U = 24;
       
   304     SDL_SCANCODE_V = 25;
       
   305     SDL_SCANCODE_W = 26;
       
   306     SDL_SCANCODE_X = 27;
       
   307     SDL_SCANCODE_Y = 28;
       
   308     SDL_SCANCODE_Z = 29;
       
   309     SDL_SCANCODE_1 = 30;
       
   310     SDL_SCANCODE_2 = 31;
       
   311     SDL_SCANCODE_3 = 32;
       
   312     SDL_SCANCODE_4 = 33;
       
   313     SDL_SCANCODE_5 = 34;
       
   314     SDL_SCANCODE_6 = 35;
       
   315     SDL_SCANCODE_7 = 36;
       
   316     SDL_SCANCODE_8 = 37;
       
   317     SDL_SCANCODE_9 = 38;
       
   318     SDL_SCANCODE_0 = 39;
       
   319     SDL_SCANCODE_RETURN = 40;
       
   320     SDL_SCANCODE_ESCAPE = 41;
       
   321     SDL_SCANCODE_BACKSPACE = 42;
       
   322     SDL_SCANCODE_TAB = 43;
       
   323     SDL_SCANCODE_SPACE = 44;
       
   324     SDL_SCANCODE_MINUS = 45;
       
   325     SDL_SCANCODE_EQUALS = 46;
       
   326     SDL_SCANCODE_LEFTBRACKET = 47;
       
   327     SDL_SCANCODE_RIGHTBRACKET = 48;
       
   328     SDL_SCANCODE_BACKSLASH = 49;
       
   329     SDL_SCANCODE_NONUSHASH = 50;
       
   330     SDL_SCANCODE_SEMICOLON = 51;
       
   331     SDL_SCANCODE_APOSTROPHE = 52;
       
   332     SDL_SCANCODE_GRAVE = 53;
       
   333     SDL_SCANCODE_COMMA = 54;
       
   334     SDL_SCANCODE_PERIOD = 55;
       
   335     SDL_SCANCODE_SLASH = 56;
       
   336     SDL_SCANCODE_CAPSLOCK = 57;
       
   337     SDL_SCANCODE_F1 = 58;
       
   338     SDL_SCANCODE_F2 = 59;
       
   339     SDL_SCANCODE_F3 = 60;
       
   340     SDL_SCANCODE_F4 = 61;
       
   341     SDL_SCANCODE_F5 = 62;
       
   342     SDL_SCANCODE_F6 = 63;
       
   343     SDL_SCANCODE_F7 = 64;
       
   344     SDL_SCANCODE_F8 = 65;
       
   345     SDL_SCANCODE_F9 = 66;
       
   346     SDL_SCANCODE_F10 = 67;
       
   347     SDL_SCANCODE_F11 = 68;
       
   348     SDL_SCANCODE_F12 = 69;
       
   349     SDL_SCANCODE_PRINTSCREEN = 70;
       
   350     SDL_SCANCODE_SCROLLLOCK = 71;
       
   351     SDL_SCANCODE_PAUSE = 72;
       
   352     SDL_SCANCODE_INSERT = 73;
       
   353     SDL_SCANCODE_HOME = 74;
       
   354     SDL_SCANCODE_PAGEUP = 75;
       
   355     SDL_SCANCODE_DELETE = 76;
       
   356     SDL_SCANCODE_END = 77;
       
   357     SDL_SCANCODE_PAGEDOWN = 78;
       
   358     SDL_SCANCODE_RIGHT = 79;
       
   359     SDL_SCANCODE_LEFT = 80;
       
   360     SDL_SCANCODE_DOWN = 81;
       
   361     SDL_SCANCODE_UP = 82;
       
   362     SDL_SCANCODE_NUMLOCKCLEAR = 83;
       
   363     SDL_SCANCODE_KP_DIVIDE = 84;
       
   364     SDL_SCANCODE_KP_MULTIPLY = 85;
       
   365     SDL_SCANCODE_KP_MINUS = 86;
       
   366     SDL_SCANCODE_KP_PLUS = 87;
       
   367     SDL_SCANCODE_KP_ENTER = 88;
       
   368     SDL_SCANCODE_KP_1 = 89;
       
   369     SDL_SCANCODE_KP_2 = 90;
       
   370     SDL_SCANCODE_KP_3 = 91;
       
   371     SDL_SCANCODE_KP_4 = 92;
       
   372     SDL_SCANCODE_KP_5 = 93;
       
   373     SDL_SCANCODE_KP_6 = 94;
       
   374     SDL_SCANCODE_KP_7 = 95;
       
   375     SDL_SCANCODE_KP_8 = 96;
       
   376     SDL_SCANCODE_KP_9 = 97;
       
   377     SDL_SCANCODE_KP_0 = 98;
       
   378     SDL_SCANCODE_KP_PERIOD = 99;
       
   379     SDL_SCANCODE_NONUSBACKSLASH = 100;
       
   380     SDL_SCANCODE_APPLICATION = 101;
       
   381     SDL_SCANCODE_POWER = 102;
       
   382     SDL_SCANCODE_KP_EQUALS = 103;
       
   383     SDL_SCANCODE_F13 = 104;
       
   384     SDL_SCANCODE_F14 = 105;
       
   385     SDL_SCANCODE_F15 = 106;
       
   386     SDL_SCANCODE_F16 = 107;
       
   387     SDL_SCANCODE_F17 = 108;
       
   388     SDL_SCANCODE_F18 = 109;
       
   389     SDL_SCANCODE_F19 = 110;
       
   390     SDL_SCANCODE_F20 = 111;
       
   391     SDL_SCANCODE_F21 = 112;
       
   392     SDL_SCANCODE_F22 = 113;
       
   393     SDL_SCANCODE_F23 = 114;
       
   394     SDL_SCANCODE_F24 = 115;
       
   395     SDL_SCANCODE_EXECUTE = 116;
       
   396     SDL_SCANCODE_HELP = 117;
       
   397     SDL_SCANCODE_MENU = 118;
       
   398     SDL_SCANCODE_SELECT = 119;
       
   399     SDL_SCANCODE_STOP = 120;
       
   400     SDL_SCANCODE_AGAIN = 121;
       
   401     SDL_SCANCODE_UNDO = 122;
       
   402     SDL_SCANCODE_CUT = 123;
       
   403     SDL_SCANCODE_COPY = 124;
       
   404     SDL_SCANCODE_PASTE = 125;
       
   405     SDL_SCANCODE_FIND = 126;
       
   406     SDL_SCANCODE_MUTE = 127;
       
   407     SDL_SCANCODE_VOLUMEUP = 128;
       
   408     SDL_SCANCODE_VOLUMEDOWN = 129;
       
   409     SDL_SCANCODE_KP_COMMA = 133;
       
   410     SDL_SCANCODE_KP_EQUALSAS400 = 134;
       
   411     SDL_SCANCODE_INTERNATIONAL1 = 135;
       
   412     SDL_SCANCODE_INTERNATIONAL2 = 136;
       
   413     SDL_SCANCODE_INTERNATIONAL3 = 137;
       
   414     SDL_SCANCODE_INTERNATIONAL4 = 138;
       
   415     SDL_SCANCODE_INTERNATIONAL5 = 139;
       
   416     SDL_SCANCODE_INTERNATIONAL6 = 140;
       
   417     SDL_SCANCODE_INTERNATIONAL7 = 141;
       
   418     SDL_SCANCODE_INTERNATIONAL8 = 142;
       
   419     SDL_SCANCODE_INTERNATIONAL9 = 143;
       
   420     SDL_SCANCODE_LANG1 = 144; (*< Hangul/English toggle *)
       
   421     SDL_SCANCODE_LANG2 = 145; (*< Hanja conversion *)
       
   422     SDL_SCANCODE_LANG3 = 146; (*< Katakana *)
       
   423     SDL_SCANCODE_LANG4 = 147; (*< Hiragana *)
       
   424     SDL_SCANCODE_LANG5 = 148; (*< Zenkaku/Hankaku *)
       
   425     SDL_SCANCODE_LANG6 = 149; (*< reserved *)
       
   426     SDL_SCANCODE_LANG7 = 150; (*< reserved *)
       
   427     SDL_SCANCODE_LANG8 = 151; (*< reserved *)
       
   428     SDL_SCANCODE_LANG9 = 152; (*< reserved *)
       
   429     SDL_SCANCODE_ALTERASE = 153;
       
   430     SDL_SCANCODE_SYSREQ = 154;
       
   431     SDL_SCANCODE_CANCEL = 155;
       
   432     SDL_SCANCODE_CLEAR = 156;
       
   433     SDL_SCANCODE_PRIOR = 157;
       
   434     SDL_SCANCODE_RETURN2 = 158;
       
   435     SDL_SCANCODE_SEPARATOR = 159;
       
   436     SDL_SCANCODE_OUT = 160;
       
   437     SDL_SCANCODE_OPER = 161;
       
   438     SDL_SCANCODE_CLEARAGAIN = 162;
       
   439     SDL_SCANCODE_CRSEL = 163;
       
   440     SDL_SCANCODE_EXSEL = 164;
       
   441     SDL_SCANCODE_KP_00 = 176;
       
   442     SDL_SCANCODE_KP_000 = 177;
       
   443     SDL_SCANCODE_THOUSANDSSEPARATOR = 178;
       
   444     SDL_SCANCODE_DECIMALSEPARATOR = 179;
       
   445     SDL_SCANCODE_CURRENCYUNIT = 180;
       
   446     SDL_SCANCODE_CURRENCYSUBUNIT = 181;
       
   447     SDL_SCANCODE_KP_LEFTPAREN = 182;
       
   448     SDL_SCANCODE_KP_RIGHTPAREN = 183;
       
   449     SDL_SCANCODE_KP_LEFTBRACE = 184;
       
   450     SDL_SCANCODE_KP_RIGHTBRACE = 185;
       
   451     SDL_SCANCODE_KP_TAB = 186;
       
   452     SDL_SCANCODE_KP_BACKSPACE = 187;
       
   453     SDL_SCANCODE_KP_A = 188;
       
   454     SDL_SCANCODE_KP_B = 189;
       
   455     SDL_SCANCODE_KP_C = 190;
       
   456     SDL_SCANCODE_KP_D = 191;
       
   457     SDL_SCANCODE_KP_E = 192;
       
   458     SDL_SCANCODE_KP_F = 193;
       
   459     SDL_SCANCODE_KP_XOR = 194;
       
   460     SDL_SCANCODE_KP_POWER = 195;
       
   461     SDL_SCANCODE_KP_PERCENT = 196;
       
   462     SDL_SCANCODE_KP_LESS = 197;
       
   463     SDL_SCANCODE_KP_GREATER = 198;
       
   464     SDL_SCANCODE_KP_AMPERSAND = 199;
       
   465     SDL_SCANCODE_KP_DBLAMPERSAND = 200;
       
   466     SDL_SCANCODE_KP_VERTICALBAR = 201;
       
   467     SDL_SCANCODE_KP_DBLVERTICALBAR = 202;
       
   468     SDL_SCANCODE_KP_COLON = 203;
       
   469     SDL_SCANCODE_KP_HASH = 204;
       
   470     SDL_SCANCODE_KP_SPACE = 205;
       
   471     SDL_SCANCODE_KP_AT = 206;
       
   472     SDL_SCANCODE_KP_EXCLAM = 207;
       
   473     SDL_SCANCODE_KP_MEMSTORE = 208;
       
   474     SDL_SCANCODE_KP_MEMRECALL = 209;
       
   475     SDL_SCANCODE_KP_MEMCLEAR = 210;
       
   476     SDL_SCANCODE_KP_MEMADD = 211;
       
   477     SDL_SCANCODE_KP_MEMSUBTRACT = 212;
       
   478     SDL_SCANCODE_KP_MEMMULTIPLY = 213;
       
   479     SDL_SCANCODE_KP_MEMDIVIDE = 214;
       
   480     SDL_SCANCODE_KP_PLUSMINUS = 215;
       
   481     SDL_SCANCODE_KP_CLEAR = 216;
       
   482     SDL_SCANCODE_KP_CLEARENTRY = 217;
       
   483     SDL_SCANCODE_KP_BINARY = 218;
       
   484     SDL_SCANCODE_KP_OCTAL = 219;
       
   485     SDL_SCANCODE_KP_DECIMAL = 220;
       
   486     SDL_SCANCODE_KP_HEXADECIMAL = 221;
       
   487     SDL_SCANCODE_LCTRL = 224;
       
   488     SDL_SCANCODE_LSHIFT = 225;
       
   489     SDL_SCANCODE_LALT = 226;
       
   490     SDL_SCANCODE_LGUI = 227;
       
   491     SDL_SCANCODE_RCTRL = 228;
       
   492     SDL_SCANCODE_RSHIFT = 229;
       
   493     SDL_SCANCODE_RALT = 230;
       
   494     SDL_SCANCODE_RGUI = 231;
       
   495     SDL_SCANCODE_MODE = 257;
       
   496     SDL_SCANCODE_AUDIONEXT = 258;
       
   497     SDL_SCANCODE_AUDIOPREV = 259;
       
   498     SDL_SCANCODE_AUDIOSTOP = 260;
       
   499     SDL_SCANCODE_AUDIOPLAY = 261;
       
   500     SDL_SCANCODE_AUDIOMUTE = 262;
       
   501     SDL_SCANCODE_MEDIASELECT = 263;
       
   502     SDL_SCANCODE_WWW = 264;
       
   503     SDL_SCANCODE_MAIL = 265;
       
   504     SDL_SCANCODE_CALCULATOR = 266;
       
   505     SDL_SCANCODE_COMPUTER = 267;
       
   506     SDL_SCANCODE_AC_SEARCH = 268;
       
   507     SDL_SCANCODE_AC_HOME = 269;
       
   508     SDL_SCANCODE_AC_BACK = 270;
       
   509     SDL_SCANCODE_AC_FORWARD = 271;
       
   510     SDL_SCANCODE_AC_STOP = 272;
       
   511     SDL_SCANCODE_AC_REFRESH = 273;
       
   512     SDL_SCANCODE_AC_BOOKMARKS = 274;
       
   513     SDL_SCANCODE_BRIGHTNESSDOWN = 275;
       
   514     SDL_SCANCODE_BRIGHTNESSUP = 276;
       
   515     SDL_SCANCODE_DISPLAYSWITCH = 277;
       
   516     SDL_SCANCODE_KBDILLUMTOGGLE = 278;
       
   517     SDL_SCANCODE_KBDILLUMDOWN = 279;
       
   518     SDL_SCANCODE_KBDILLUMUP = 280;
       
   519     SDL_SCANCODE_EJECT = 281;
       
   520     SDL_SCANCODE_SLEEP = 282;
       
   521     SDL_SCANCODE_APP1 = 283;
       
   522     SDL_SCANCODE_APP2 = 284;
   312 
   523 
   313 /////////////////////////////////////////////////////////////////
   524 /////////////////////////////////////////////////////////////////
   314 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   525 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   315 /////////////////////////////////////////////////////////////////
   526 /////////////////////////////////////////////////////////////////
   316 
   527 
   317 // two important reference points for the wanderers of this area
   528 // two important reference points for the wanderers of this area
   318 // http://www.freepascal.org/docs-html/ref/refsu5.html
   529 // http://www.freepascal.org/docs-html/ref/refsu5.html
   319 // http://www.freepascal.org/docs-html/prog/progsu144.html
   530 // http://www.freepascal.org/docs-html/prog/progsu144.html
   320 
   531 
   321 type
   532 type
   322 {$IFDEF SDL2}
       
   323     PSDL_Window   = Pointer;
   533     PSDL_Window   = Pointer;
   324     PSDL_Renderer = Pointer;
   534     PSDL_Renderer = Pointer;
   325     PSDL_Texture  = Pointer;
   535     PSDL_Texture  = Pointer;
   326     PSDL_GLContext= Pointer;
   536     PSDL_GLContext= Pointer;
   327     TSDL_TouchId  = Int64;
   537     TSDL_TouchId  = Int64;
   328 {$ENDIF}
       
   329     TSDL_FingerId = Int64;
   538     TSDL_FingerId = Int64;
       
   539     TSDL_Keycode = LongInt;
       
   540     TSDL_Scancode = LongInt;
   330 
   541 
   331     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
   542     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
   332 
   543 
   333     PSDL_Rect = ^TSDL_Rect;
   544     PSDL_Rect = ^TSDL_Rect;
   334     TSDL_Rect = record
   545     TSDL_Rect = record
   335 {$IFDEF SDL2}
       
   336         x, y, w, h: LongInt;
   546         x, y, w, h: LongInt;
   337 {$ELSE}
       
   338         x, y: SmallInt;
       
   339         w, h: Word;
       
   340 {$ENDIF}
       
   341         end;
   547         end;
   342 
   548 
   343     TPoint = record
   549     TPoint = record
   344         x, y: LongInt;
   550         x, y: LongInt;
   345         end;
   551         end;
   346 
   552 
   347     PSDL_PixelFormat = ^TSDL_PixelFormat;
   553     PSDL_PixelFormat = ^TSDL_PixelFormat;
   348     TSDL_PixelFormat = record
   554     TSDL_PixelFormat = record
   349 {$IFDEF SDL2}
       
   350         format: LongWord;
   555         format: LongWord;
   351         palette: Pointer;
   556         palette: Pointer;
   352         BitsPerPixel : Byte;
   557         BitsPerPixel : Byte;
   353         BytesPerPixel: Byte;
   558         BytesPerPixel: Byte;
   354         padding: array[0..1] of Byte;
   559         padding: array[0..1] of Byte;
   364         Gshift: Byte;
   569         Gshift: Byte;
   365         Bshift: Byte;
   570         Bshift: Byte;
   366         Ashift: Byte;
   571         Ashift: Byte;
   367         refcount: LongInt;
   572         refcount: LongInt;
   368         next: PSDL_PixelFormat;
   573         next: PSDL_PixelFormat;
   369 {$ELSE}
       
   370         palette: Pointer;
       
   371         BitsPerPixel : Byte;
       
   372         BytesPerPixel: Byte;
       
   373         Rloss : Byte;
       
   374         Gloss : Byte;
       
   375         Bloss : Byte;
       
   376         Aloss : Byte;
       
   377         Rshift: Byte;
       
   378         Gshift: Byte;
       
   379         Bshift: Byte;
       
   380         Ashift: Byte;
       
   381         RMask : LongWord;
       
   382         GMask : LongWord;
       
   383         BMask : LongWord;
       
   384         AMask : LongWord;
       
   385         colorkey: LongWord;
       
   386         alpha: Byte;
       
   387 {$ENDIF}
       
   388         end;
   574         end;
   389 
   575 
   390     PSDL_Surface = ^TSDL_Surface;
   576     PSDL_Surface = ^TSDL_Surface;
   391     TSDL_Surface = record
   577     TSDL_Surface = record
   392         flags : LongWord;
   578         flags : LongWord;
   393         format: PSDL_PixelFormat;
   579         format: PSDL_PixelFormat;
   394         w, h  : LongInt;
   580         w, h  : LongInt;
   395         pitch : {$IFDEF SDL2}LongInt{$ELSE}Word{$ENDIF};
   581         pitch : LongInt;
   396         pixels: Pointer;
   582         pixels: Pointer;
   397 {$IFDEF PAS2C}
   583 {$IFDEF PAS2C}
   398         hwdata   : Pointer;
   584         hwdata   : Pointer;
   399         clip_rect: TSDL_Rect;
   585         clip_rect: TSDL_Rect;
   400         unsed1   : LongWord;
   586         unsed1   : LongWord;
   402         map      : Pointer;
   588         map      : Pointer;
   403         format_version: Longword;
   589         format_version: Longword;
   404         refcount : LongInt;
   590         refcount : LongInt;
   405         offset   : LongInt;
   591         offset   : LongInt;
   406 {$ELSE}
   592 {$ELSE}
   407 {$IFDEF SDL2}
       
   408         userdata  : Pointer;
   593         userdata  : Pointer;
   409         locked    : LongInt;
   594         locked    : LongInt;
   410         lock_data : Pointer;
   595         lock_data : Pointer;
   411         clip_rect : TSDL_Rect;
   596         clip_rect : TSDL_Rect;
   412         map       : Pointer;
   597         map       : Pointer;
   413         refcount  : LongInt;
   598         refcount  : LongInt;
   414 {$ELSE}
       
   415         offset : LongInt;
       
   416 {$ENDIF}
       
   417 {$ENDIF}
   599 {$ENDIF}
   418         end;
   600         end;
   419 
   601 
   420 
   602 
   421     PSDL_Color = ^TSDL_Color;
   603     PSDL_Color = ^TSDL_Color;
   427         end;
   609         end;
   428 
   610 
   429 
   611 
   430     (* SDL_RWops and friends *)
   612     (* SDL_RWops and friends *)
   431     PSDL_RWops = ^TSDL_RWops;
   613     PSDL_RWops = ^TSDL_RWops;
   432 {$IFDEF SDL2}
       
   433     TSize  = function( context: PSDL_RWops): Int64; cdecl;
   614     TSize  = function( context: PSDL_RWops): Int64; cdecl;
   434     TSeek  = function( context: PSDL_RWops; offset: Int64; whence: LongInt ): Int64; cdecl;
   615     TSeek  = function( context: PSDL_RWops; offset: Int64; whence: LongInt ): Int64; cdecl;
   435 {$ELSE}
       
   436     TSeek  = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
       
   437 {$ENDIF}
       
   438     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   616     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   439     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   617     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   440     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   618     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   441 
   619 
   442     TStdio = record
   620     TStdio = record
   443         autoclose: {$IFDEF SDL2}Boolean{$ELSE}LongInt{$ENDIF};
   621         autoclose: Boolean;
   444         fp: Pointer;
   622         fp: Pointer;
   445         end;
   623         end;
   446 
   624 
   447     TMem = record
   625     TMem = record
   448         base: PByte;
   626         base: PByte;
   450         stop: PByte;
   628         stop: PByte;
   451         end;
   629         end;
   452 
   630 
   453     TUnknown = record
   631     TUnknown = record
   454         data1: Pointer;
   632         data1: Pointer;
   455 {$IFDEF SDL2}
       
   456         data2: Pointer;
   633         data2: Pointer;
   457 {$ENDIF}
       
   458         end;
   634         end;
   459 
   635 
   460 {$IFDEF ANDROID}
   636 {$IFDEF ANDROID}
   461     TAndroidio = record
   637     TAndroidio = record
   462         fileName, inputStream, readableByteChannel: Pointer;
   638         fileName, inputStream, readableByteChannel: Pointer;
   469     TWinbuffer = record
   645     TWinbuffer = record
   470         data: Pointer;
   646         data: Pointer;
   471         size, left: LongInt;
   647         size, left: LongInt;
   472         end;
   648         end;
   473     TWindowsio = record
   649     TWindowsio = record
   474         append : {$IFDEF SDL2}Boolean{$ELSE}LongInt{$ENDIF};
   650         append : Boolean;
   475         h : Pointer;
   651         h : Pointer;
   476         buffer : TWinbuffer;
   652         buffer : TWinbuffer;
   477         end;
   653         end;
   478 {$ENDIF}
   654 {$ENDIF}
   479 {$ENDIF}
   655 {$ENDIF}
   480 
   656 
   481     TSDL_RWops = record
   657     TSDL_RWops = record
   482 {$IFDEF SDL2}
       
   483         size: TSize;
   658         size: TSize;
   484 {$ENDIF}
       
   485         seek: TSeek;
   659         seek: TSeek;
   486         read: TRead;
   660         read: TRead;
   487         write: TWrite;
   661         write: TWrite;
   488         close: TClose;
   662         close: TClose;
   489         type_: LongWord;
   663         type_: LongWord;
   501             end;
   675             end;
   502 
   676 
   503 
   677 
   504 {* SDL_Event type definition *}
   678 {* SDL_Event type definition *}
   505 
   679 
   506 {$IFDEF SDL2}
       
   507     TSDL_Keysym = record
   680     TSDL_Keysym = record
   508         scancode: LongInt;
   681         scancode: TSDL_Scancode;
   509         sym: LongInt;
   682         sym: TSDL_Keycode;
   510         modifier: Word;
   683         modifier: Word;
   511         unused: LongWord;
   684         unused: LongWord;
   512         end;
   685         end;
   513 
   686 
   514     TSDL_WindowEvent = record
   687     TSDL_WindowEvent = record
   518         event: Byte;
   691         event: Byte;
   519         padding1, padding2, padding3: Byte;
   692         padding1, padding2, padding3: Byte;
   520         data1, data2: LongInt;
   693         data1, data2: LongInt;
   521         end;
   694         end;
   522 
   695 
   523     // available in sdl12 but not exposed
       
   524     TSDL_TextEditingEvent = record
   696     TSDL_TextEditingEvent = record
   525         type_: LongWord;
   697         type_: Longword;
   526         timestamp: LongWord;
   698         timestamp: Longword;
   527         windowID: LongWord;
   699         windowID: Longword;
   528         text: array[0..31] of Byte;
   700         text: array [0..SDL_TEXTEDITINGEVENT_TEXT_SIZE - 1] of char;
   529         start, lenght: LongInt;
   701         start: LongInt;
   530         end;
   702         length: LongInt;
   531 
   703         end;
   532     // available in sdl12 but not exposed
   704 
   533     TSDL_TextInputEvent = record
   705     TSDL_TextInputEvent = record
   534         type_: LongWord;
   706         type_: Longword;
   535         timestamp: LongWord;
   707         timestamp: Longword;
   536         windowID: LongWord;
   708         windowID: Longword;
   537         text: array[0..31] of Byte;
   709         text: array [0..SDL_TEXTINPUTEVENT_TEXT_SIZE - 1] of char;
   538         end;
   710         end;
   539 
   711 
   540     TSDL_TouchFingerEvent = record
   712     TSDL_TouchFingerEvent = record
   541         type_: LongWord;
   713         type_: LongWord;
   542         timestamp: LongWord;
   714         timestamp: LongWord;
   603         type_: LongWord;
   775         type_: LongWord;
   604         timestamp: LongWord;
   776         timestamp: LongWord;
   605         end;
   777         end;
   606 
   778 
   607     TSDL_OSEvent = TSDL_CommonEvent;
   779     TSDL_OSEvent = TSDL_CommonEvent;
   608 {$ELSE}
       
   609     TSDL_KeySym = record
       
   610         scancode: Byte;
       
   611         sym: LongWord;
       
   612         modifier: LongWord;
       
   613         unicode: Word;
       
   614         end;
       
   615 
       
   616     TSDL_ActiveEvent = record
       
   617         type_: Byte;
       
   618         gain: Byte;
       
   619         state: Byte;
       
   620         end;
       
   621 
       
   622     TSDL_ResizeEvent = record
       
   623         type_: Byte;
       
   624         w, h: LongInt;
       
   625         end;
       
   626 {$ENDIF}
       
   627 
   780 
   628     TSDL_KeyboardEvent = record
   781     TSDL_KeyboardEvent = record
   629 {$IFDEF SDL2}
       
   630         type_: LongWord;
   782         type_: LongWord;
   631         timestamp: LongWord;
   783         timestamp: LongWord;
   632         windowID: LongWord;
   784         windowID: LongWord;
   633         state, repeat_, padding2, padding3: Byte;
   785         state, repeat_, padding2, padding3: Byte;
   634 {$ELSE}
       
   635         type_, which, state: Byte;
       
   636 {$ENDIF}
       
   637         keysym: TSDL_Keysym;
   786         keysym: TSDL_Keysym;
   638         end;
   787         end;
   639 
   788 
   640     TSDL_MouseMotionEvent = record
   789     TSDL_MouseMotionEvent = record
   641 {$IFDEF SDL2}
       
   642         type_: LongWord;
   790         type_: LongWord;
   643         timestamp: LongWord;
   791         timestamp: LongWord;
   644         windowID: LongWord;
   792         windowID: LongWord;
   645         which, state: LongWord;
   793         which, state: LongWord;
   646         x, y, xrel, yrel: LongInt;
   794         x, y, xrel, yrel: LongInt;
   647 {$ELSE}
       
   648         type_, which, state: Byte;
       
   649         x, y, xrel, yrel: Word;
       
   650 {$ENDIF}
       
   651         end;
   795         end;
   652 
   796 
   653     TSDL_MouseButtonEvent = record
   797     TSDL_MouseButtonEvent = record
   654 {$IFDEF SDL2}
       
   655         type_: LongWord;
   798         type_: LongWord;
   656         timestamp: LongWord;
   799         timestamp: LongWord;
   657         windowID: LongWord;
   800         windowID: LongWord;
   658         which: LongWord;
   801         which: LongWord;
   659         button, state, padding1, padding2: Byte;
   802         button, state, padding1, padding2: Byte;
   660         x, y: LongInt;
   803         x, y: LongInt;
   661 {$ELSE}
       
   662         type_, which, button, state: Byte;
       
   663         x, y: Word;
       
   664 {$ENDIF}
       
   665         end;
   804         end;
   666 
   805 
   667     TSDL_MouseWheelEvent = record
   806     TSDL_MouseWheelEvent = record
   668         type_: LongWord;
   807         type_: LongWord;
   669 {$IFDEF SDL2}
       
   670         timestamp: LongWord;
   808         timestamp: LongWord;
   671         windowID: LongWord;
   809         windowID: LongWord;
   672         which: LongWord;
   810         which: LongWord;
   673 {$ELSE}
       
   674         which: Byte;
       
   675 {$ENDIF}
       
   676         x, y: LongInt;
   811         x, y: LongInt;
   677         end;
   812         end;
   678 
   813 
   679     TSDL_JoyAxisEvent = record
   814     TSDL_JoyAxisEvent = record
   680 {$IFDEF SDL2}
       
   681         type_: LongWord;
   815         type_: LongWord;
   682         timestamp: LongWord;
   816         timestamp: LongWord;
   683         which: LongWord;
   817         which: LongWord;
   684 {$ELSE}
       
   685         type_: Byte;
       
   686         which: Byte;
       
   687 {$ENDIF}
       
   688         axis: Byte;
   818         axis: Byte;
   689 {$IFDEF SDL2}
       
   690         padding1, padding2, padding3: Byte;
   819         padding1, padding2, padding3: Byte;
   691         value: LongInt;
   820         value: LongInt;
   692         padding4: Word;
   821         padding4: Word;
   693 {$ELSE}
       
   694         value: SmallInt;
       
   695 {$ENDIF}
       
   696         end;
   822         end;
   697 
   823 
   698     TSDL_JoyBallEvent = record
   824     TSDL_JoyBallEvent = record
   699 {$IFDEF SDL2}
       
   700         type_: LongWord;
   825         type_: LongWord;
   701         timestamp: LongWord;
   826         timestamp: LongWord;
   702         which: LongWord;
   827         which: LongWord;
   703 {$ELSE}
       
   704         type_: Byte;
       
   705         which: Byte;
       
   706 {$ENDIF}
       
   707         ball: Byte;
   828         ball: Byte;
   708 {$IFDEF SDL2}
       
   709         padding1, padding2, padding3: Byte;
   829         padding1, padding2, padding3: Byte;
   710 {$ENDIF}
       
   711         xrel, yrel: SmallInt;
   830         xrel, yrel: SmallInt;
   712         end;
   831         end;
   713 
   832 
   714     TSDL_JoyHatEvent = record
   833     TSDL_JoyHatEvent = record
   715 {$IFDEF SDL2}
       
   716         type_: LongWord;
   834         type_: LongWord;
   717         timestamp: LongWord;
   835         timestamp: LongWord;
   718         which: LongWord;
   836         which: LongWord;
   719 {$ELSE}
       
   720         type_: Byte;
       
   721         which: Byte;
       
   722 {$ENDIF}
       
   723         hat: Byte;
   837         hat: Byte;
   724         value: Byte;
   838         value: Byte;
   725 {$IFDEF SDL2}
       
   726         padding1, padding2: Byte;
   839         padding1, padding2: Byte;
   727 {$ENDIF}
       
   728         end;
   840         end;
   729 
   841 
   730     TSDL_JoyButtonEvent = record
   842     TSDL_JoyButtonEvent = record
   731 {$IFDEF SDL2}
   843         type_: LongWord;
   732         type_: LongWord;
   844         timestamp: LongWord;
   733         timestamp: LongWord;
       
   734 {$ELSE}
       
   735         type_: Byte;
       
   736 {$ENDIF}
       
   737         which: Byte;
   845         which: Byte;
   738         button: Byte;
   846         button: Byte;
   739         state: Byte;
   847         state: Byte;
   740 {$IFDEF SDL2}
       
   741         padding1: Byte;
   848         padding1: Byte;
   742 {$ENDIF}
       
   743         end;
   849         end;
   744 
   850 
   745     TSDL_QuitEvent = record
   851     TSDL_QuitEvent = record
   746 {$IFDEF SDL2}
   852         type_: LongWord;
   747         type_: LongWord;
   853         timestamp: LongWord;
   748         timestamp: LongWord;
       
   749 {$ELSE}
       
   750         type_: Byte;
       
   751 {$ENDIF}
       
   752         end;
   854         end;
   753 
   855 
   754     TSDL_UserEvent = record
   856     TSDL_UserEvent = record
   755 {$IFDEF SDL2}
       
   756         type_: LongWord;
   857         type_: LongWord;
   757         timestamp: LongWord;
   858         timestamp: LongWord;
   758         windowID: LongWord;
   859         windowID: LongWord;
   759 {$ELSE}
       
   760         type_: Byte;
       
   761 {$ENDIF}
       
   762         code: LongInt;
   860         code: LongInt;
   763         data1, data2: Pointer;
   861         data1, data2: Pointer;
   764         end;
   862         end;
   765 
   863 
   766     PSDL_Event = ^TSDL_Event;
   864     PSDL_Event = ^TSDL_Event;
   767     TSDL_Event = record
   865     TSDL_Event = record
   768 {$IFDEF SDL2}
       
   769         case LongInt of
   866         case LongInt of
   770             SDL_FIRSTEVENT: (type_: LongWord);
   867             SDL_FIRSTEVENT: (type_: LongWord);
   771             SDL_COMMONDEVENT: (common: TSDL_CommonEvent);
   868             SDL_COMMONDEVENT: (common: TSDL_CommonEvent);
   772             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
   869             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
   773             SDL_KEYDOWN,
   870             SDL_KEYDOWN,
   774             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   871             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   775             SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
   872             SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
   776             SDL_TEXTINPUT: (tedit: TSDL_TextInputEvent);
   873             SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
   777             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   874             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   778             SDL_MOUSEBUTTONDOWN,
   875             SDL_MOUSEBUTTONDOWN,
   779             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   876             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   780             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
   877             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
   781             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   878             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   799             SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
   896             SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
   800             SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
   897             SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
   801             SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
   898             SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
   802             SDL_DROPFILE: (drop: TSDL_DropEvent);
   899             SDL_DROPFILE: (drop: TSDL_DropEvent);
   803             SDL_ALLEVENTS: (foo: shortstring);
   900             SDL_ALLEVENTS: (foo: shortstring);
   804 {$ELSE}
       
   805         case Byte of
       
   806             SDL_NOEVENT: (type_: Byte);
       
   807             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
       
   808             SDL_KEYDOWN,
       
   809             SDL_KEYUP: (key: TSDL_KeyboardEvent);
       
   810             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
       
   811             SDL_MOUSEBUTTONDOWN,
       
   812             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
       
   813             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
       
   814             SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
       
   815             SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
       
   816             SDL_JOYBUTTONDOWN,
       
   817             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
       
   818             SDL_QUITEV: (quit: TSDL_QuitEvent);
       
   819             //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
       
   820             SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
       
   821             SDL_ALLEVENTS: (foo: shortstring);
       
   822 {$ENDIF}
       
   823         end;
   901         end;
   824 
   902 
   825     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   903     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   826 
   904 
   827     TByteArray = array[0..65535] of Byte;
   905     TByteArray = array[0..65535] of Byte;
   850         SDL_GL_ACCUM_ALPHA_SIZE,
   928         SDL_GL_ACCUM_ALPHA_SIZE,
   851         SDL_GL_STEREO,
   929         SDL_GL_STEREO,
   852         SDL_GL_MULTISAMPLEBUFFERS,
   930         SDL_GL_MULTISAMPLEBUFFERS,
   853         SDL_GL_MULTISAMPLESAMPLES,
   931         SDL_GL_MULTISAMPLESAMPLES,
   854         SDL_GL_ACCELERATED_VISUAL,
   932         SDL_GL_ACCELERATED_VISUAL,
   855 {$IFDEF SDL2}
       
   856         SDL_GL_RETAINED_BACKING,
   933         SDL_GL_RETAINED_BACKING,
   857         SDL_GL_CONTEXT_MAJOR_VERSION,
   934         SDL_GL_CONTEXT_MAJOR_VERSION,
   858         SDL_GL_CONTEXT_MINOR_VERSION,
   935         SDL_GL_CONTEXT_MINOR_VERSION,
   859         SDL_GL_CONTEXT_EGL,
   936         SDL_GL_CONTEXT_EGL,
   860         SDL_GL_CONTEXT_FLAGS,
   937         SDL_GL_CONTEXT_FLAGS,
   861         SDL_GL_CONTEXT_PROFILE_MASK,
   938         SDL_GL_CONTEXT_PROFILE_MASK,
   862         SDL_GL_SHARE_WITH_CURRENT_CONTEXT
   939         SDL_GL_SHARE_WITH_CURRENT_CONTEXT
   863 {$ELSE}
       
   864         SDL_GL_SWAP_CONTROL
       
   865 {$ENDIF}
       
   866         );
   940         );
   867 
   941 
   868 {$IFDEF SDL2}
       
   869     TSDL_ArrayByteOrder = (  // array component order, low Byte -> high Byte
   942     TSDL_ArrayByteOrder = (  // array component order, low Byte -> high Byte
   870         SDL_ARRAYORDER_NONE,
   943         SDL_ARRAYORDER_NONE,
   871         SDL_ARRAYORDER_RGB,
   944         SDL_ARRAYORDER_RGB,
   872         SDL_ARRAYORDER_RGBA,
   945         SDL_ARRAYORDER_RGBA,
   873         SDL_ARRAYORDER_ARGB,
   946         SDL_ARRAYORDER_ARGB,
   874         SDL_ARRAYORDER_BGR,
   947         SDL_ARRAYORDER_BGR,
   875         SDL_ARRAYORDER_BGRA,
   948         SDL_ARRAYORDER_BGRA,
   876         SDL_ARRAYORDER_ABGR
   949         SDL_ARRAYORDER_ABGR
   877         );
   950         );
   878 {$ENDIF}
       
   879 
   951 
   880     // Joystick/Controller support
   952     // Joystick/Controller support
   881     PSDL_Joystick = ^TSDL_Joystick;
   953     PSDL_Joystick = ^TSDL_Joystick;
   882     TSDL_Joystick = record
   954     TSDL_Joystick = record
   883             end;
   955             end;
   945 {* SDL *}
  1017 {* SDL *}
   946 function  SDL_Init(flags: LongWord): LongInt; cdecl; external SDLLibName;
  1018 function  SDL_Init(flags: LongWord): LongInt; cdecl; external SDLLibName;
   947 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
  1019 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
   948 procedure SDL_Quit; cdecl; external SDLLibName;
  1020 procedure SDL_Quit; cdecl; external SDLLibName;
   949 
  1021 
       
  1022 procedure SDL_free(mem: Pointer); cdecl; external SDLLibName;
       
  1023 
   950 procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
  1024 procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
   951 function  SDL_GetTicks: LongWord; cdecl; external SDLLibName;
  1025 function  SDL_GetTicks: LongWord; cdecl; external SDLLibName;
   952 
  1026 
   953 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1027 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
   954 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
  1028 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   978 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
  1052 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
   979 
  1053 
   980 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
  1054 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
   981 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
  1055 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
   982 
  1056 
   983 {$IFDEF SDL2}
       
   984 function  SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
  1057 function  SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
       
  1058 procedure SDL_SetWindowIcon(window: PSDL_Window; icon: PSDL_Surface); cdecl; external SDLLibName;
       
  1059 
   985 function  SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
  1060 function  SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
   986 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
  1061 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   987 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
  1062 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   988 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
  1063 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
   989 function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
  1064 function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
   990 
  1065 
   991 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
  1066 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
   992 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
  1067 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
   993 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
  1068 procedure SDL_GL_SwapWindow(window: PSDL_Window); cdecl; external SDLLibName;
   994 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
  1069 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
   995 
  1070 
   996 procedure SDL_VideoQuit; cdecl; external SDLLibName;
  1071 procedure SDL_VideoQuit; cdecl; external SDLLibName;
   997 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
  1072 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
   998 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
  1073 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
  1009 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): Boolean; cdecl; external SDLLibName;
  1084 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): Boolean; cdecl; external SDLLibName;
  1010 
  1085 
  1011 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
  1086 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
  1012 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
  1087 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
  1013 procedure SDL_StartTextInput; cdecl; external SDLLibName;
  1088 procedure SDL_StartTextInput; cdecl; external SDLLibName;
       
  1089 procedure SDL_StopTextInput; cdecl; external SDLLibName;
  1014 
  1090 
  1015 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
  1091 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
  1016 
  1092 
  1017 function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; cdecl; external SDLLibName;
  1093 function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; cdecl; external SDLLibName;
  1018 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
  1094 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
  1019 {$ELSE}
       
  1020 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
       
  1021 
       
  1022 function  SDL_EnableUNICODE(enable: LongInt): LongInt; cdecl; external SDLLibName;
       
  1023 function  SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt; cdecl; external SDLLibName;
       
  1024 function  SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; cdecl; external SDLLibName;
       
  1025 {$ENDIF}
       
  1026 
  1095 
  1027 
  1096 
  1028 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
  1097 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
  1029 function  SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName;
  1098 function  SDL_GetKeyName(key: TSDL_Keycode): PChar; cdecl; external SDLLibName;
  1030 function  SDL_GetScancodeName(key: LongWord): PChar; cdecl; external SDLLibName;
  1099 function  SDL_GetScancodeName(key: TSDL_Scancode): PChar; cdecl; external SDLLibName;
  1031 function  SDL_GetKeyFromScancode(key: LongWord): LongInt; cdecl; external SDLLibName;
  1100 function  SDL_GetKeyFromScancode(key: TSDL_Scancode): TSDL_Keycode; cdecl; external SDLLibName;
  1032 
  1101 // SDL2 functions has some additional functions (not listed here) for keycode/scancode translation
  1033 
  1102 
  1034 procedure SDL_PumpEvents; cdecl; external SDLLibName;
  1103 procedure SDL_PumpEvents; cdecl; external SDLLibName;
  1035 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
  1104 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
  1036 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
  1105 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
  1037 procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
  1106 procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
  1038 
  1107 
  1039 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
  1108 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
  1040 procedure SDL_WarpMouse(x, y: Word); {$IFDEF SDL2}inline{$ELSE}cdecl; external SDLLibName{$ENDIF};
  1109 procedure SDL_WarpMouse(x, y: Word); inline;
  1041 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL2} name 'SDL_GetKeyboardState'{$ENDIF};
  1110 
       
  1111 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
  1042 
  1112 
  1043 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
  1113 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
  1044 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
  1114 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
  1045 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
  1115 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
  1046 
  1116 
  1047 
  1117 
  1048 (* remember to mark the threaded functions as 'cdecl; export;'
  1118 (* remember to mark the threaded functions as 'cdecl; export;'
  1049    (or have fun debugging nil arguments) *)
  1119    (or have fun debugging nil arguments) *)
  1050 function  SDL_CreateThread(fn: Pointer; {$IFDEF SDL2}name: PChar;{$ENDIF} data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
  1120 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
  1051 procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName;
  1121 procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName;
  1052 procedure SDL_KillThread(thread: PSDL_Thread); cdecl; external SDLLibName;
       
  1053 
  1122 
  1054 function  SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
  1123 function  SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
  1055 procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
  1124 procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
  1056 function  SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName {$IFNDEF SDL2}name 'SDL_mutexP'{$ENDIF};
  1125 function  SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
  1057 function  SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName {$IFNDEF SDL2}name 'SDL_mutexV'{$ENDIF};
  1126 function  SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
  1058 
  1127 
  1059 function  SDL_CreateCond: PSDL_cond; cdecl; external SDLLibName;
  1128 function  SDL_CreateCond: PSDL_cond; cdecl; external SDLLibName;
  1060 procedure SDL_DestroyCond(cond: PSDL_cond); cdecl; external SDLLibName;
  1129 procedure SDL_DestroyCond(cond: PSDL_cond); cdecl; external SDLLibName;
  1061 function  SDL_CondSignal(cond: PSDL_cond): LongInt; cdecl; external SDLLibName;
  1130 function  SDL_CondSignal(cond: PSDL_cond): LongInt; cdecl; external SDLLibName;
  1062 function  SDL_CondBroadcast(cond: PSDL_cond): LongInt; cdecl; external SDLLibName;
  1131 function  SDL_CondBroadcast(cond: PSDL_cond): LongInt; cdecl; external SDLLibName;
  1115 function  TTF_OpenFontRW(src: PSDL_RWops; freesrc: LongBool; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
  1184 function  TTF_OpenFontRW(src: PSDL_RWops; freesrc: LongBool; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
  1116 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
  1185 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
  1117 procedure TTF_CloseFont(font: PTTF_Font); cdecl; external SDL_TTFLibName;
  1186 procedure TTF_CloseFont(font: PTTF_Font); cdecl; external SDL_TTFLibName;
  1118 
  1187 
  1119 (*  SDL_mixer  *)
  1188 (*  SDL_mixer  *)
  1120 function  Mix_Init(flags: LongInt): LongInt; {$IFDEF SDL_MIXER_NEWER}cdecl; external SDL_MixerLibName{$ELSE}inline{$ENDIF};
  1189 function  Mix_Init(flags: LongInt): LongInt; cdecl; external SDL_MixerLibName;
  1121 procedure Mix_Quit; {$IFDEF SDL_MIXER_NEWER}cdecl; external SDL_MixerLibName{$ELSE}inline{$ENDIF};
  1190 procedure Mix_Quit; cdecl; external SDL_MixerLibName;
  1122 
  1191 
  1123 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
  1192 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
  1124 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
  1193 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
  1125 function  Mix_QuerySpec(frequency: PLongInt; format: PWord; channels: PLongInt): LongInt; cdecl; external SDL_MixerLibName;
  1194 function  Mix_QuerySpec(frequency: PLongInt; format: PWord; channels: PLongInt): LongInt; cdecl; external SDL_MixerLibName;
  1126 
  1195 
  1151 function  Mix_FadeOutChannel(channel: LongInt; fadems: LongInt): LongInt; cdecl; external SDL_MixerLibName;
  1220 function  Mix_FadeOutChannel(channel: LongInt; fadems: LongInt): LongInt; cdecl; external SDL_MixerLibName;
  1152 
  1221 
  1153 procedure Mix_SetPostMix( mix_func: TPostMix; arg: Pointer); cdecl; external SDL_MixerLibName;
  1222 procedure Mix_SetPostMix( mix_func: TPostMix; arg: Pointer); cdecl; external SDL_MixerLibName;
  1154 
  1223 
  1155 (*  SDL_image  *)
  1224 (*  SDL_image  *)
  1156 function  IMG_Init(flags: LongInt): LongInt; {$IFDEF SDL_IMAGE_NEWER}cdecl; external SDL_ImageLibName{$ELSE}inline{$ENDIF};
  1225 function  IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
  1157 procedure IMG_Quit; {$IFDEF SDL_IMAGE_NEWER}cdecl; external SDL_ImageLibName{$ELSE}inline{$ENDIF};
  1226 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
  1158 
  1227 
  1159 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1228 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1160 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongBool): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1229 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongBool): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1161 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1230 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1162 function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongBool; type_: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1231 function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongBool; type_: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
  1174 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName;
  1243 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName;
  1175 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName;
  1244 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName;
  1176 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
  1245 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
  1177 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
  1246 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
  1178 
  1247 
       
  1248 // SDL 2 clipboard functions
       
  1249 function SDL_HasClipboardText(): Boolean; cdecl; external SDLLibName;
       
  1250 // returns nil if memory for clipboard contents copy couldn't be allocated
       
  1251 function SDL_GetClipboardText(): PChar; cdecl; external SDLLibName;
       
  1252 // returns 0 on success or negative error number on failure
       
  1253 function SDL_SetClipboardText(const text: PChar): LongInt; cdecl; external SDLLibName;
  1179 
  1254 
  1180 procedure SDLNet_Write16(value: Word; buf: Pointer);
  1255 procedure SDLNet_Write16(value: Word; buf: Pointer);
  1181 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
  1256 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
  1182 function  SDLNet_Read16(buf: Pointer): Word;
  1257 function  SDLNet_Read16(buf: Pointer): Word;
  1183 function  SDLNet_Read32(buf: Pointer): LongWord;
  1258 function  SDLNet_Read32(buf: Pointer): LongWord;
  1184 
  1259 
  1185 implementation
  1260 implementation
  1186 {$IFDEF SDL2}
       
  1187 uses uStore;
  1261 uses uStore;
  1188 
  1262 
  1189 // for sdl1.2 we directly call SDL_WarpMouse()
  1263 // for sdl1.2 we directly call SDL_WarpMouse()
  1190 // for sdl2 we provide a SDL_WarpMouse() which calls the right SDL_WarpMouseInWindow() function
  1264 // for sdl2 we provide a SDL_WarpMouse() which calls the right SDL_WarpMouseInWindow() function
  1191 // this has the advantage of reducing 'uses' and 'ifdef' statements
  1265 // this has the advantage of reducing 'uses' and 'ifdef' statements
  1192 // (SDLwindow is a private member of uStore module)
  1266 // (SDLwindow is a private member of uStore module)
  1193 procedure SDL_WarpMouse(x, y: Word); inline;
  1267 procedure SDL_WarpMouse(x, y: Word); inline;
  1194 begin
  1268 begin
  1195     WarpMouse(x, y);
  1269     WarpMouse(x, y);
  1196 end;
  1270 end;
  1197 {$ENDIF}
       
  1198 
  1271 
  1199 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1272 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1200 begin
  1273 begin
  1201     SDL_MustLock:=
  1274     SDL_MustLock:=
  1202 {$IFDEF SDL2}
       
  1203         ((surface^.flags and SDL_RLEACCEL) <> 0)
  1275         ((surface^.flags and SDL_RLEACCEL) <> 0)
  1204 {$ELSE}
       
  1205         ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
       
  1206 {$ENDIF}
       
  1207 end;
  1276 end;
  1208 
       
  1209 {$IFNDEF SDL_MIXER_NEWER}
       
  1210 function  Mix_Init(flags: LongInt): LongInt; inline;
       
  1211 begin
       
  1212     Mix_Init:= flags;
       
  1213 end;
       
  1214 
       
  1215 procedure Mix_Quit; inline;
       
  1216 begin
       
  1217 end;
       
  1218 {$ENDIF}
       
  1219 
       
  1220 {$IFNDEF SDL_IMAGE_NEWER}
       
  1221 function  IMG_Init(flags: LongInt): LongInt; inline;
       
  1222 begin
       
  1223     IMG_Init:= flags;
       
  1224 end;
       
  1225 
       
  1226 procedure IMG_Quit; inline;
       
  1227 begin
       
  1228 end;
       
  1229 {$ENDIF}
       
  1230 
  1277 
  1231 procedure SDLNet_Write16(value: Word; buf: Pointer);
  1278 procedure SDLNet_Write16(value: Word; buf: Pointer);
  1232 begin
  1279 begin
  1233     PByteArray(buf)^[1]:= value;
  1280     PByteArray(buf)^[1]:= value;
  1234     PByteArray(buf)^[0]:= value shr 8
  1281     PByteArray(buf)^[0]:= value shr 8
  1254                   (PByteArray(buf)^[2] shl  8) or
  1301                   (PByteArray(buf)^[2] shl  8) or
  1255                   (PByteArray(buf)^[1] shl 16) or
  1302                   (PByteArray(buf)^[1] shl 16) or
  1256                   (PByteArray(buf)^[0] shl 24)
  1303                   (PByteArray(buf)^[0] shl 24)
  1257 end;
  1304 end;
  1258 
  1305 
       
  1306 
  1259 end.
  1307 end.
  1260 
  1308