hedgewars/SDLh.pas
changeset 2390 57fb33ab04a4
parent 2379 d62b1f224982
child 2428 6800f8aa0184
equal deleted inserted replaced
2389:bc3e45a4d5fb 2390:57fb33ab04a4
    45 	{$linklib gcc}
    45 	{$linklib gcc}
    46 {$ENDIF}
    46 {$ENDIF}
    47 {$ENDIF}
    47 {$ENDIF}
    48 
    48 
    49 (*  SDL  *)
    49 (*  SDL  *)
    50 const {$IFDEF WIN32}
    50 const
    51 	SDLLibName = 'SDL.dll';
    51 {$IFDEF WIN32}
    52 	{$ENDIF}
    52         SDLLibName = 'SDL.dll';
    53 	{$IFDEF UNIX}
    53 {$ENDIF}
    54 			{$IFDEF DARWIN}
    54 {$IFDEF UNIX}
    55 			SDLLibName = 'SDL';
    55 	{$IFDEF DARWIN}
    56 			{$ELSE}
    56                 SDLLibName = 'SDL';
    57 			SDLLibName = 'libSDL.so';
    57         {$ELSE}
    58 			{$ENDIF}
    58 		SDLLibName = 'libSDL.so';
    59 	{$ENDIF}
    59         {$ENDIF}
       
    60 {$ENDIF}
    60 	SDL_SWSURFACE   = $00000000;
    61 	SDL_SWSURFACE   = $00000000;
    61 	SDL_HWSURFACE   = $00000001;
    62 	SDL_HWSURFACE   = $00000001;
    62 	SDL_SRCALPHA    = $00010000;
    63 	SDL_SRCALPHA    = $00010000;
    63 	SDL_INIT_VIDEO  = $00000020;
    64 	SDL_INIT_VIDEO  = $00000020;
    64 	SDL_INIT_AUDIO  = $00000010;
    65 	SDL_INIT_AUDIO  = $00000010;
       
    66 
       
    67 	SDL_APPINPUTFOCUS=$00000010;
    65 
    68 
    66 {$IFDEF SDL13}
    69 {$IFDEF SDL13}
    67 	SDL_ASYNCBLIT   = $08000000;
    70 	SDL_ASYNCBLIT   = $08000000;
    68 	SDL_ANYFORMAT   = $10000000;
    71 	SDL_ANYFORMAT   = $10000000;
    69 	SDL_HWPALETTE   = $00200000;
    72 	SDL_HWPALETTE   = $00200000;
    87 	SDL_NOFRAME     = $00000020;
    90 	SDL_NOFRAME     = $00000020;
    88 	SDL_OPENGL      = $00000002;
    91 	SDL_OPENGL      = $00000002;
    89 	SDL_RESIZABLE   = $00000010;
    92 	SDL_RESIZABLE   = $00000010;
    90 {$ENDIF}
    93 {$ENDIF}
    91 
    94 
       
    95 {*begin sdl_event binding*}
    92 	SDL_NOEVENT     = 0;
    96 	SDL_NOEVENT     = 0;
    93 	SDL_ACTIVEEVENT = 1;
       
    94 	SDL_KEYDOWN     = 2;
    97 	SDL_KEYDOWN     = 2;
    95 	SDL_KEYUP       = 3;
    98 	SDL_KEYUP       = 3;
    96 	SDL_MOUSEBUTTONDOWN = 5;
       
    97 	SDL_MOUSEBUTTONUP   = 6;
       
    98 	SDL_QUITEV      = 12;
    99 	SDL_QUITEV      = 12;
    99 	SDL_VIDEORESIZE = 16;
   100 	SDL_VIDEORESIZE = 16;
   100 
   101 
   101 {$IFDEF SDL13}
   102 {$IFDEF SDL13}
       
   103         SDL_WINDOWEVENT = 1;
       
   104         SDL_TEXTINPUT = 4;
   102 	SDL_MOUSEMOTION  = 5;
   105 	SDL_MOUSEMOTION  = 5;
   103 {$ENDIF}
   106         SDL_MOUSEBUTTONDOWN = 6;
   104 
   107 	SDL_MOUSEBUTTONUP   = 7;
   105 	SDL_APPINPUTFOCUS = 2;
   108         SDL_MOUSEWHEEL = 8;  //different handling, should create SDL_MouseWheelEvent type
   106 	SDL_BUTTON_WHEELDUP = 4;
   109 {$ELSE}
       
   110         SDL_ACTIVEEVENT = 1;
       
   111        	SDL_MOUSEBUTTONDOWN = 5;
       
   112 	SDL_MOUSEBUTTONUP   = 6;
       
   113         SDL_BUTTON_WHEELDUP = 4;
   107 	SDL_BUTTON_WHEELDOWN = 5;
   114 	SDL_BUTTON_WHEELDOWN = 5;
       
   115 {$ENDIF}
       
   116 {*end sdl_event binding*}
   108 
   117 
   109 	RMask = $000000FF;
   118 	RMask = $000000FF;
   110 	GMask = $0000FF00;
   119 	GMask = $0000FF00;
   111 	BMask = $00FF0000;
   120 	BMask = $00FF0000;
   112 	AMask = $FF000000;
   121 	AMask = $FF000000;
   113 
   122 
   114 type PSDL_Rect = ^TSDL_Rect;
   123 type PSDL_Rect = ^TSDL_Rect;
   115 	TSDL_Rect = record
   124 	TSDL_Rect = record
   116 	{$IFDEF SDL13}
   125 {$IFDEF SDL13}
   117 		x, y, w, h: LongInt;
   126 		x, y, w, h: LongInt;
   118 	{$ELSE}
   127 {$ELSE}
   119 		x, y: SmallInt;
   128 		x, y: SmallInt;
   120 		w, h: Word;
   129 		w, h: Word;
   121 	{$ENDIF}
   130 {$ENDIF}
   122 		end;
   131 		end;
   123 
   132 
   124 	TPoint = record
   133 	TPoint = record
   125 		X: LongInt;
   134 		X: LongInt;
   126 		Y: LongInt;
   135 		Y: LongInt;
   275 			end;
   284 			end;
   276 
   285 
   277      PSDL_Event = ^TSDL_Event;
   286      PSDL_Event = ^TSDL_Event;
   278      TSDL_Event = record
   287      TSDL_Event = record
   279                   case Byte of
   288                   case Byte of
       
   289 {$IFDEF SDL13}
       
   290                         //doublecheck the type of WINDOWEVENT TEXTINPUT
       
   291                         SDL_NOEVENT: (type_: byte);
       
   292                         SDL_WINDOWEVENT: (active: TSDL_ActiveEvent);
       
   293                         SDL_KEYDOWN,
       
   294                         SDL_KEYUP: (key: TSDL_KeyboardEvent);
       
   295                         SDL_TEXTINPUT: (txtin: byte);
       
   296                         SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
       
   297                         SDL_MOUSEBUTTONDOWN,
       
   298                         SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
       
   299 {$ELSE}
   280                        SDL_NOEVENT: (type_: byte);
   300                        SDL_NOEVENT: (type_: byte);
   281                        SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   301                        SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   282                        SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
   302                        SDL_KEYDOWN,
       
   303                        SDL_KEYUP: (key: TSDL_KeyboardEvent);
   283                        SDL_QUITEV: (quit: TSDL_QuitEvent);
   304                        SDL_QUITEV: (quit: TSDL_QuitEvent);
   284                        SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
   305                        SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
   285                        SDL_MOUSEBUTTONDOWN,
   306                        SDL_MOUSEBUTTONDOWN,
   286                        SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   307                        SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   287 {$IFDEF SDL13}
       
   288                        SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
       
   289 {$ENDIF}
   308 {$ENDIF}
   290      end;
   309      end;
   291 
   310 
   292      PByteArray = ^TByteArray;
   311      PByteArray = ^TByteArray;
   293      TByteArray = array[0..65535] of Byte;
   312      TByteArray = array[0..65535] of Byte;