DEADSOFTWARE

Added stubs for gl, enet and sdl2
[d2df-sdl.git] / src / wrappers / sdl2 / sdl2.pas
1 {$INCLUDE ../shared/a_modes.inc}
2 {$SCOPEDENUMS OFF}
3 unit sdl2;
5 interface
7 {$I sdltype.inc}
8 {$I sdlscancode.inc}
10 const
11 SDL_HAT_CENTERED = $00;
12 SDL_HAT_UP = $01;
13 SDL_HAT_RIGHT = $02;
14 SDL_HAT_DOWN = $04;
15 SDL_HAT_LEFT = $08;
16 SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
17 SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
18 SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
19 SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
21 const
22 AUDIO_U8 = $0008;
23 AUDIO_S8 = $8008;
24 AUDIO_U16LSB = $0010;
25 AUDIO_S16LSB = $8010;
26 AUDIO_U16MSB = $1010;
27 AUDIO_S16MSB = $9010;
28 AUDIO_U16 = AUDIO_U16LSB;
29 AUDIO_S16 = AUDIO_S16LSB;
31 const
32 SDL_TOUCH_MOUSEID = UInt32(-1);
34 type
35 PSDL_Window = ^TSDL_Window;
36 TSDL_Window = record end;
38 PSDL_Joystick = Pointer;
39 TSDL_JoystickGUID = record
40 data: array[0..15] of UInt8;
41 end;
42 TSDL_JoystickID = SInt32;
44 PSDL_RWops = ^TSDL_RWops;
46 TSize = function(context: PSDL_RWops): SInt64; cdecl;
47 TSeek = function(context: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64; cdecl;
48 TRead = function(context: PSDL_RWops; ptr: Pointer; size: size_t; maxnum: size_t): size_t; cdecl;
49 TWrite = function(context: PSDL_RWops; const ptr: Pointer; size: size_t; num: size_t): size_t; cdecl;
50 TClose = function(context: PSDL_RWops): SInt32; cdecl;
52 TStdio = record
53 autoclose: TSDL_Bool;
54 fp: file;
55 end;
57 TMem = record
58 base: PUInt8;
59 here: PUInt8;
60 stop: PUInt8;
61 end;
63 TUnknown = record
64 data1: Pointer;
65 end;
67 TSDL_RWops = packed record
68 size: TSize;
69 seek: TSeek;
70 read: TRead;
71 write: TWrite;
72 close: TClose;
73 _type: UInt32;
74 case Integer of
75 0: (stdio: TStdio);
76 1: (mem: TMem);
77 2: (unknown: TUnknown);
78 {$IFDEF ANDROID}
79 3: (androidio: TAndroidIO);
80 {$ENDIF}
81 {$IFDEF WINDOWS}
82 3: (windowsio: TWindowsIO);
83 {$ENDIF}
84 end;
86 PSDL_TouchID = ^TSDL_TouchID;
87 TSDL_TouchID = SInt64;
89 PSDL_FingerID = ^TSDL_FingerID;
90 TSDL_FingerID = SInt64;
93 const
94 { Touch events }
95 SDL_FINGERDOWN = $700;
96 SDL_FINGERUP = $701;
97 SDL_FINGERMOTION = $702;
99 type
100 TSDL_TouchFingerEvent = record
101 type_: UInt32;
102 timestamp: UInt32;
103 touchId: TSDL_TouchID;
104 fingerId: TSDL_FingerID;
105 x, y, dx, dy: Float;
106 pressure: Float;
107 end;
110 const
111 SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000;
112 SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_MASK or 0;
114 type
115 PSDL_DisplayMode = ^TSDL_DisplayMode;
116 TSDL_DisplayMode = record
117 format: UInt32;
118 w: SInt32;
119 h: SInt32;
120 refresh_rate: SInt32;
121 driverdata: Pointer;
122 end;
124 TSDL_GLContext = Pointer;
126 const
127 SDL_WINDOW_FULLSCREEN = $00000001;
128 SDL_WINDOW_OPENGL = $00000002;
129 SDL_WINDOW_SHOWN = $00000004;
130 SDL_WINDOW_HIDDEN = $00000008;
131 SDL_WINDOW_BORDERLESS = $00000010;
132 SDL_WINDOW_RESIZABLE = $00000020;
133 SDL_WINDOW_MINIMIZED = $00000040;
134 SDL_WINDOW_MAXIMIZED = $00000080;
135 SDL_WINDOW_INPUT_GRABBED = $00000100;
136 SDL_WINDOW_INPUT_FOCUS = $00000200;
137 SDL_WINDOW_MOUSE_FOCUS = $00000400;
138 SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN or $00001000;
139 SDL_WINDOW_FOREIGN = $00000800;
140 SDL_WINDOW_ALLOW_HIGHDPI = $00002000;
142 SDL_WINDOWEVENT_EXPOSED = 3;
143 SDL_WINDOWEVENT_MOVED = 4;
144 SDL_WINDOWEVENT_RESIZED = 5;
145 SDL_WINDOWEVENT_MINIMIZED = 7;
146 SDL_WINDOWEVENT_MAXIMIZED = 8;
147 SDL_WINDOWEVENT_RESTORED = 9;
148 SDL_WINDOWEVENT_FOCUS_GAINED = 12;
149 SDL_WINDOWEVENT_FOCUS_LOST = 13;
151 SDL_DISABLE = 0;
152 SDL_ENABLE = 1;
154 SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
156 SDL_FIRSTEVENT = 0;
157 SDL_COMMONEVENT = 1;
158 SDL_QUITEV = $100;
159 SDL_WINDOWEVENT = $200;
160 SDL_KEYDOWN = $300;
161 SDL_KEYUP = $301;
162 //SDL_TEXTEDITING = $302;
163 SDL_TEXTINPUT = $303;
165 type
166 TSDL_WindowEvent = record
167 type_: UInt32; // SDL_WINDOWEVENT
168 timestamp: UInt32;
169 windowID: UInt32; // The associated window
170 event: UInt8; // SDL_WindowEventID
171 padding1: UInt8;
172 padding2: UInt8;
173 padding3: UInt8;
174 data1: SInt32; // event dependent data
175 data2: SInt32; // event dependent data
176 end;
178 PSDL_Keysym = ^TSDL_Keysym;
179 TSDL_Keysym = record
180 scancode: TSDL_ScanCode; // SDL physical key code - see SDL_Scancode for details
181 sym: TSDL_KeyCode; // SDL virtual key code - see SDL_Keycode for details
182 _mod: UInt16; // current key modifiers
183 unicode: UInt32; // (deprecated) use SDL_TextInputEvent instead
184 end;
186 TSDL_KeyboardEvent = record
187 type_: UInt32; // SDL_KEYDOWN or SDL_KEYUP
188 timestamp: UInt32;
189 windowID: UInt32; // The window with keyboard focus, if any
190 state: UInt8; // SDL_PRESSED or SDL_RELEASED
191 _repeat: UInt8; // Non-zero if this is a key repeat
192 padding2: UInt8;
193 padding3: UInt8;
194 keysym: TSDL_KeySym; // The key that was pressed or released
195 end;
197 TSDL_TextInputEvent = record
198 type_: UInt32; // SDL_TEXTINPUT
199 timestamp: UInt32;
200 windowID: UInt32; // The window with keyboard focus, if any
201 text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char; // The input text
202 end;
204 TSDL_QuitEvent = record
205 type_: UInt32; // SDL_QUIT
206 timestamp: UInt32;
207 end;
209 PSDL_Event = ^TSDL_Event;
210 TSDL_Event = record
211 case Integer of
212 0: (type_: UInt32);
213 //SDL_COMMONEVENT: (common: TSDL_CommonEvent);
214 SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
215 SDL_KEYUP,
216 SDL_KEYDOWN: (key: TSDL_KeyboardEvent);
217 //SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
218 SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
219 //SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
220 //SDL_MOUSEBUTTONUP,
221 //SDL_MOUSEBUTTONDOWN: (button: TSDL_MouseButtonEvent);
222 //SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
223 //SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
224 //SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
225 //SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
226 //SDL_JOYBUTTONDOWN,
227 //SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
228 //SDL_JOYDEVICEADDED,
229 //SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
230 //SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
231 //SDL_CONTROLLERBUTTONUP,
232 //SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
233 //SDL_CONTROLLERDEVICEADDED,
234 //SDL_CONTROLLERDEVICEREMOVED,
235 //SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
236 //SDL_AUDIODEVICEADDED,
237 //SDL_AUDIODEVICEREMOVED: (adevice: TSDL_AudioDeviceEvent);
238 SDL_QUITEV: (quit: TSDL_QuitEvent);
239 //SDL_USEREVENT: (user: TSDL_UserEvent);
240 //SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
241 SDL_FINGERDOWN,
242 SDL_FINGERUP,
243 SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
244 //SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
245 //SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
246 //SDL_DROPFILE: (drop: TSDL_DropEvent);
247 end;
249 const
250 SDL_GL_RED_SIZE = 0;
251 SDL_GL_GREEN_SIZE = 1;
252 SDL_GL_BLUE_SIZE = 2;
253 SDL_GL_ALPHA_SIZE = 3;
254 SDL_GL_BUFFER_SIZE = 4;
255 SDL_GL_DOUBLEBUFFER = 5;
256 SDL_GL_DEPTH_SIZE = 6;
257 SDL_GL_STENCIL_SIZE = 7;
258 SDL_GL_ACCUM_RED_SIZE = 8;
259 SDL_GL_ACCUM_GREEN_SIZE = 9;
260 SDL_GL_ACCUM_BLUE_SIZE = 10;
261 SDL_GL_ACCUM_ALPHA_SIZE = 11;
262 SDL_GL_STEREO = 12;
263 SDL_GL_MULTISAMPLEBUFFERS = 13;
264 SDL_GL_MULTISAMPLESAMPLES = 14;
265 SDL_GL_ACCELERATED_VISUAL = 15;
266 SDL_GL_RETAINED_BACKING = 16;
267 SDL_GL_CONTEXT_MAJOR_VERSION = 17;
268 SDL_GL_CONTEXT_MINOR_VERSION = 18;
269 SDL_GL_CONTEXT_EGL = 19;
270 SDL_GL_CONTEXT_FLAGS = 20;
271 SDL_GL_CONTEXT_PROFILE_MASK = 21;
272 SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22;
273 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE = 23;
275 type
276 TSDL_GLattr = DWord;
278 const
279 SDL_INIT_TIMER = $00000001;
280 SDL_INIT_AUDIO = $00000010;
281 SDL_INIT_VIDEO = $00000020;
282 SDL_INIT_JOYSTICK = $00000200;
283 SDL_INIT_HAPTIC = $00001000;
284 SDL_INIT_GAMECONTROLLER = $00002000; //turn on game controller also implicitly does JOYSTICK
285 SDL_INIT_NOPARACHUTE = $00100000; //Don't catch fatal signals
286 SDL_INIT_EVERYTHING = SDL_INIT_TIMER or SDL_INIT_AUDIO or
287 SDL_INIT_VIDEO or SDL_INIT_JOYSTICK or
288 SDL_INIT_HAPTIC or SDL_INIT_GAMECONTROLLER;
290 SDL_HINT_ACCELEROMETER_AS_JOYSTICK = 'SDL_ACCELEROMETER_AS_JOYSTICK';
292 /// MACRO ///
293 function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
295 /// FUNCTIONS ///
297 function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32;
298 function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32;
300 function SDL_NumJoysticks: SInt32;
301 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick;
302 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar;
303 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32;
304 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32;
305 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32;
306 procedure SDL_JoystickClose(joystick: PSDL_Joystick);
307 procedure SDL_JoystickUpdate;
308 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8;
309 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16;
310 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8;
312 function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar;
314 function SDL_GetPerformanceCounter: UInt64;
315 function SDL_GetPerformanceFrequency: UInt64;
317 function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops;
318 function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops;
320 function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32;
321 function SDL_IsTextInputActive: TSDL_Bool;
322 procedure SDL_StartTextInput;
323 procedure SDL_StopTextInput;
324 function SDL_GetNumTouchDevices: SInt32;
326 function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
327 function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode;
329 procedure SDL_DestroyWindow(window: PSDL_Window);
330 procedure SDL_GL_DeleteContext(context: TSDL_GLContext);
331 procedure SDL_RestoreWindow(window: PSDL_Window);
332 procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32);
333 function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window;
334 function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32;
335 function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32;
336 procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt);
337 function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32;
338 function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
340 function SDL_ShowCursor(toggle: SInt32): SInt32;
341 procedure SDL_Delay(ms: UInt32);
342 procedure SDL_GL_SwapWindow(window: PSDL_Window);
344 function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext;
345 function SDL_GetTicks: UInt32;
347 function SDL_PushEvent(event: PSDL_Event): SInt32;
348 function SDL_PollEvent(event: PSDL_Event): SInt32;
349 function SDL_GL_SetSwapInterval(interval: SInt32): SInt32;
350 function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32;
351 function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32;
353 function SDL_GetError: PAnsiChar;
355 function SDL_Init(flags: UInt32): SInt32;
356 procedure SDL_Quit();
357 function SDL_SetHint( const name: PChar; const value: PChar) : boolean;
359 implementation
360 /// MACRO ///
362 function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
363 begin
364 Result := (X shr 8) and $FF;
365 end;
367 /// FUNCTIONS ////
369 function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32;
370 begin
371 result := 0
372 end;
374 function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32;
375 begin
376 result := 0
377 end;
380 function SDL_NumJoysticks: SInt32;
381 begin
382 result := 0
383 end;
385 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick;
386 begin
387 result := nil
388 end;
390 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar;
391 begin
392 result := ''
393 end;
395 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32;
396 begin
397 result := 0
398 end;
400 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32;
401 begin
402 result := 0
403 end;
405 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32;
406 begin
407 result := 0
408 end;
410 procedure SDL_JoystickClose(joystick: PSDL_Joystick);
411 begin
412 end;
414 procedure SDL_JoystickUpdate;
415 begin
416 end;
418 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8;
419 begin
420 result := 0
421 end;
423 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16;
424 begin
425 result := 0
426 end;
428 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8;
429 begin
430 result := 0
431 end;
436 function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar;
437 begin
438 result := ''
439 end;
444 function SDL_GetPerformanceCounter: UInt64;
445 begin
446 result := 0
447 end;
449 function SDL_GetPerformanceFrequency: UInt64;
450 begin
451 result := 0
452 end;
456 function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops;
457 begin
458 result := nil
459 end;
461 function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops;
462 begin
463 result := nil
464 end;
469 function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32;
470 begin
471 result := 0
472 end;
474 function SDL_IsTextInputActive: TSDL_Bool;
475 begin
476 result := SDL_FALSE
477 end;
479 procedure SDL_StartTextInput;
480 begin
481 end;
483 procedure SDL_StopTextInput;
484 begin
485 end;
487 function SDL_GetNumTouchDevices: SInt32;
488 begin
489 result := 0
490 end;
494 function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
495 begin
496 result := 0
497 end;
499 function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode;
500 begin
501 result := nil
502 end;
504 procedure SDL_DestroyWindow(window: PSDL_Window);
505 begin
506 end;
508 procedure SDL_GL_DeleteContext(context: TSDL_GLContext);
509 begin
510 end;
512 procedure SDL_RestoreWindow(window: PSDL_Window);
513 begin
514 end;
516 procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32);
517 begin
518 end;
520 function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window;
521 begin
522 result := nil
523 end;
525 function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32;
526 begin
527 result := 0
528 end;
530 function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32;
531 begin
532 result := 0
533 end;
535 procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt);
536 begin
537 end;
539 function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32;
540 begin
541 result := 0
542 end;
544 function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
545 begin
546 result := 0
547 end;
549 function SDL_ShowCursor(toggle: SInt32): SInt32;
550 begin
551 result := 0
552 end;
554 procedure SDL_Delay(ms: UInt32);
555 begin
556 end;
558 procedure SDL_GL_SwapWindow(window: PSDL_Window);
559 begin
560 end;
562 function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext;
563 begin
564 result := nil
565 end;
567 function SDL_GetTicks: UInt32;
568 begin
569 result := 0
570 end;
572 function SDL_PushEvent(event: PSDL_Event): SInt32;
573 begin
574 result := 0
575 end;
577 function SDL_PollEvent(event: PSDL_Event): SInt32;
578 begin
579 result := 0
580 end;
582 function SDL_GL_SetSwapInterval(interval: SInt32): SInt32;
583 begin
584 result := 0
585 end;
587 function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32;
588 begin
589 result := 0
590 end;
592 function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32;
593 begin
594 result := 0
595 end;
597 function SDL_GetError: PAnsiChar;
598 begin
599 result := ''
600 end;
602 function SDL_Init(flags: UInt32): SInt32;
603 begin
604 result := 0
605 end;
607 procedure SDL_Quit();
608 begin
609 end;
611 function SDL_SetHint( const name: PChar; const value: PChar) : boolean;
612 begin
613 result := false
614 end;
616 end.