hedgewars/SDLh.pas
changeset 6974 2d3beb445d64
parent 6972 1c267028a071
child 6976 ec6b4118e7b1
equal deleted inserted replaced
6973:582ca7e8e338 6974:2d3beb445d64
    49 
    49 
    50 {$IFDEF FPC}
    50 {$IFDEF FPC}
    51     {$PACKRECORDS C}
    51     {$PACKRECORDS C}
    52 {$ELSE}
    52 {$ELSE}
    53     {$DEFINE cdecl attribute(cdecl)}
    53     {$DEFINE cdecl attribute(cdecl)}
       
    54     type PByte = ^Byte;
       
    55     type PInteger = ^Integer;
       
    56     type PLongInt = ^LongInt;
    54 {$ENDIF}
    57 {$ENDIF}
    55 
    58 
    56 {$IFDEF DARWIN}
    59 {$IFDEF DARWIN}
    57     {$IFNDEF IPHONEOS}
    60     {$IFNDEF IPHONEOS}
    58         {$PASCALMAINNAME SDL_main}
    61         {$PASCALMAINNAME SDL_main}
   369         colorkey: LongWord;
   372         colorkey: LongWord;
   370         alpha: Byte;
   373         alpha: Byte;
   371 {$ENDIF}
   374 {$ENDIF}
   372         end;
   375         end;
   373 
   376 
   374     SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT);
   377     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
   375 
   378 
   376     PSDL_Surface = ^TSDL_Surface;
   379     PSDL_Surface = ^TSDL_Surface;
   377     TSDL_Surface = record
   380     TSDL_Surface = record
   378         flags : LongWord;
   381         flags : LongWord;
   379         format: PSDL_PixelFormat;
   382         format: PSDL_PixelFormat;
   908 
   911 
   909 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   912 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   910 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
   913 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
   911 procedure SDL_StartTextInput; cdecl; external SDLLibName;
   914 procedure SDL_StartTextInput; cdecl; external SDLLibName;
   912 
   915 
   913 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
   916 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
   914 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
   917 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
   915 {$ELSE}
   918 {$ELSE}
   916 function  SDL_CreateThread(fn: Pointer; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
   919 function  SDL_CreateThread(fn: Pointer; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
   917 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
   920 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
   918 {$ENDIF}
   921 {$ENDIF}
   919 
   922 
   920 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   923 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   921 function  SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName;
   924 function  SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName;
   922 function  SDL_GetScancodeName(key: LongWord): PChar; cdecl; external SDLLibName;
   925 function  SDL_GetScancodeName(key: LongWord): PChar; cdecl; external SDLLibName;
  1049 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
  1052 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
  1050 function  SDLNet_Read16(buf: Pointer): Word;
  1053 function  SDLNet_Read16(buf: Pointer): Word;
  1051 function  SDLNet_Read32(buf: Pointer): LongWord;
  1054 function  SDLNet_Read32(buf: Pointer): LongWord;
  1052 
  1055 
  1053 implementation
  1056 implementation
       
  1057 {$IFDEF SDL13}
  1054 uses strings, uVariables;
  1058 uses strings, uVariables;
  1055 
  1059 
  1056 {$IFDEF SDL13}
  1060 // compatible functions
  1057 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
       
  1058 // compatible function, but we use SDL_CreateWindow, so the window would be NULL
       
  1059 procedure SDL_WarpMouse(x, y: Word);
  1061 procedure SDL_WarpMouse(x, y: Word);
  1060 begin
  1062 begin
  1061     SDL_WarpMouseInWindow(SDLwindow, x, y);
  1063     SDL_WarpMouseInWindow(SDLwindow, x, y);
  1062 end;
  1064 end;
  1063 
  1065 
  1077 begin
  1079 begin
  1078     SDL_StartTextInput();
  1080     SDL_StartTextInput();
  1079     exit(0);
  1081     exit(0);
  1080 end;
  1082 end;
  1081 
  1083 
  1082 function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt;
  1084 function SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt;
  1083 begin
  1085 begin
       
  1086     timedelay:= timedelay;  // avoid hint
       
  1087     interval:= interval;    // avoid hint
  1084     exit(0);
  1088     exit(0);
  1085 end;
  1089 end;
  1086 {$ELSE}
  1090 {$ELSE}
  1087 function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
  1091 function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
  1088 const conversionFormat: TSDL_PixelFormat = (
  1092 const conversionFormat: TSDL_PixelFormat = (
  1096     exit(@conversionFormat);
  1100     exit(@conversionFormat);
  1097 end;
  1101 end;
  1098 
  1102 
  1099 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
  1103 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
  1100 begin
  1104 begin
  1101     pixelformat:= pixelformat;
  1105     pixelformat:= pixelformat;  // avoid hint
  1102 end;
  1106 end;
  1103 {$ENDIF}
  1107 {$ENDIF}
  1104 
  1108 
  1105 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1109 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1106 begin
  1110 begin