1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 TGLProfile
= (Core
, Compat
, Common
, CommonLite
);
26 TGLDisplayInfo
= record
30 major
, minor
: Integer;
34 (* --- Graphics --- *)
35 function sys_GetDisplayModes (bpp
: Integer): SSArray
;
36 function sys_SetDisplayMode (w
, h
, bpp
: Integer; fullscreen
, maximized
: Boolean): Boolean;
37 procedure sys_EnableVSync (yes
: Boolean);
38 procedure sys_Repaint
;
40 function sys_SetDisplayModeGL (const info
: TGLDisplayInfo
): Boolean;
43 function sys_HandleInput (): Boolean;
44 procedure sys_RequestQuit
;
47 function sys_IsTextInputActive (): Boolean;
48 procedure sys_ShowKeyboard (yes
: Boolean);
56 sys_CharPress
: procedure (ch
: AnsiChar) = nil;
57 sys_ScreenResize
: procedure (w
, h
: Integer) = nil;
62 {$IFDEF ENABLE_HOLMES}
65 {$IFDEF ENABLE_RENDER}
71 SysUtils
, SDL2
, Math
, ctypes
,
72 e_log
, e_input
, e_sound
,
73 g_options
, g_console
, g_game
, g_basic
77 GameTitle
= 'Doom 2D: Forever (SDL 2, %s)';
81 context
: TSDL_GLContext
;
82 display
, wx
, wy
: Integer;
84 JoystickHandle
: array [0..e_MaxJoys
- 1] of PSDL_Joystick
;
85 JoystickHatState
: array [0..e_MaxJoys
- 1, 0..e_MaxJoyHats
- 1, HAT_LEFT
..HAT_DOWN
] of Boolean;
86 JoystickZeroAxes
: array [0..e_MaxJoys
- 1, 0..e_MaxJoyAxes
- 1] of Integer;
87 rMajor
, rMinor
, rProfile
: Integer;
92 keyFinger
: array [VK_FIRSTKEY
..VK_LASTKEY
] of Integer;
95 (* --------- Graphics --------- *)
97 function GetTitle (): AnsiString;
100 info
:= g_GetBuildHash(false);
101 if info
= 'custom build' then
102 info
:= info
+ ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE
+ ' ' + GAME_BUILDTIME
;
103 result
:= Format(GameTitle
, [info
]);
106 function InitWindow (w
, h
, bpp
: Integer; fullScreen
, maximized
: Boolean): Boolean;
107 var flags
: UInt32
; x
, y
: cint
; title
: AnsiString;
109 // note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB;
110 e_LogWritefln('InitWindow %s %s %s %s', [w
, h
, bpp
, fullScreen
]);
114 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION
, rMajor
);
115 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION
, rMinor
);
116 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK
, rProfile
);
117 if rProfile
in [SDL_GL_CONTEXT_PROFILE_CORE
, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
] then
119 SDL_GL_SetAttribute(SDL_GL_RED_SIZE
, 8);
120 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE
, 8);
121 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE
, 8);
122 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE
, 16);
123 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER
, 1);
124 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE
, 8); // lights; it is enough to have 1-bit stencil buffer for lighting, but...
126 flags
:= SDL_WINDOW_OPENGL
or SDL_WINDOW_RESIZABLE
;
127 if fullScreen
then flags
:= flags
or SDL_WINDOW_FULLSCREEN
;
128 if maximized
then flags
:= flags
or SDL_WINDOW_MAXIMIZED
;
131 x
:= SDL_WINDOWPOS_CENTERED
;
132 y
:= SDL_WINDOWPOS_CENTERED
140 window
:= SDL_CreateWindow(PChar(title
), x
, y
, w
, h
, flags
);
141 if window
<> nil then
143 context
:= SDL_GL_CreateContext(window
);
144 if context
<> nil then
146 if (fullscreen
= false) and (maximized
= false) and (wc
= false) then
148 SDL_GetWindowPosition(window
, @x
, @y
);
151 gFullScreen
:= fullscreen
;
152 gWinMaximized
:= maximized
;
153 gRC_FullScreen
:= fullscreen
;
154 gRC_Maximized
:= maximized
;
155 if @sys_ScreenResize
<> nil then
156 sys_ScreenResize(w
, h
);
161 // SDL_DestroyWindow(window);
162 e_LogWritefln('SDL: unable to create OpenGL context: %s', [SDL_GetError
])
167 e_LogWritefln('SDL: unable to create window: %s', [SDL_GetError
])
172 if fullScreen
then flags
:= SDL_WINDOW_FULLSCREEN
else flags
:= 0;
173 SDL_SetWindowFullscreen(window
, flags
);
174 SDL_SetWindowSize(window
, w
, h
);
175 if maximized
then SDL_MaximizeWindow(window
);
176 // always reset to center when changing fullscreen->windowed for safety purposes
177 if wc
or (gFullscreen
and not fullscreen
) or (gWinMaximized
and not maximized
) then
179 x
:= SDL_WINDOWPOS_CENTERED
;
180 y
:= SDL_WINDOWPOS_CENTERED
187 SDL_SetWindowPosition(window
, x
, y
);
188 if (fullscreen
= false) and (maximized
= false) and (wc
= false) then
190 SDL_GetWindowPosition(window
, @x
, @y
);
193 gFullScreen
:= fullscreen
;
194 gWinMaximized
:= maximized
;
195 gRC_FullScreen
:= fullscreen
;
196 gRC_Maximized
:= maximized
;
197 if @sys_ScreenResize
<> nil then
198 sys_ScreenResize(w
, h
);
203 procedure sys_Repaint
;
205 SDL_GL_SwapWindow(window
)
208 procedure sys_EnableVSync (yes
: Boolean);
211 SDL_GL_SetSwapInterval(1)
213 SDL_GL_SetSwapInterval(0)
216 function sys_GetDisplayModes (bpp
: Integer): SSArray
;
217 var i
, count
, num
, pw
, ph
: Integer; m
: TSDL_DisplayMode
;
220 num
:= SDL_GetNumDisplayModes(display
);
222 e_LogWritefln('SDL: unable to get numer of available display modes: %s', [SDL_GetError
]);
225 e_LogWritefln('Video modes for display %s:', [display
]);
226 SetLength(result
, num
);
227 i
:= 0; count
:= 0; pw
:= 0; ph
:= 0;
230 SDL_GetDisplayMode(display
, i
, @m
);
231 if ((pw
<> m
.w
) or (ph
<> m
.h
)) then
233 e_LogWritefln('* %sx%sx%s@%s', [m
.w
, m
.h
, SDL_BITSPERPIXEL(m
.format
), m
.refresh_rate
]);
234 pw
:= m
.w
; ph
:= m
.h
;
235 result
[count
] := IntToStr(m
.w
) + 'x' + IntToStr(m
.h
);
240 e_LogWritefln('- %sx%sx%s@%s', [m
.w
, m
.h
, SDL_BITSPERPIXEL(m
.format
), m
.refresh_rate
]);
244 SetLength(result
, count
)
248 function sys_SetDisplayMode (w
, h
, bpp
: Integer; fullScreen
, maximized
: Boolean): Boolean;
253 rProfile
:= SDL_GL_CONTEXT_PROFILE_ES
;
257 rProfile
:= SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
;
259 result
:= InitWindow(w
, h
, bpp
, fullScreen
, maximized
)
262 function sys_SetDisplayModeGL (const info
: TGLDisplayInfo
): Boolean;
264 rMajor
:= info
.major
;
265 rMinor
:= info
.minor
;
267 TGLProfile
.Core
: rProfile
:= SDL_GL_CONTEXT_PROFILE_CORE
;
268 TGLProfile
.Compat
: rProfile
:= SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
;
269 TGLProfile
.Common
: rProfile
:= SDL_GL_CONTEXT_PROFILE_ES
;
270 TGLProfile
.CommonLite
: rProfile
:= SDL_GL_CONTEXT_PROFILE_ES
;
272 result
:= InitWindow(info
.w
, info
.h
, info
.bpp
, info
.fullscreen
, info
.maximized
);
275 (* --------- Joystick --------- *)
277 procedure HandleJoyButton (var ev
: TSDL_JoyButtonEvent
);
278 var down
: Boolean; key
: Integer;
280 if (ev
.which
< e_MaxJoys
) and (ev
.button
< e_MaxJoyBtns
) then
282 key
:= e_JoyButtonToKey(ev
.which
, ev
.button
);
283 down
:= ev
.type_
= SDL_JOYBUTTONDOWN
;
285 e_LogWritefln('Input Debug: jbutton, joy=%s, button=%s, keycode=%s, press=%s', [ev
.which
, ev
.button
, key
, down
]);
286 e_KeyUpDown(key
, down
);
287 g_Console_ProcessBind(key
, down
)
293 down
:= ev
.type_
= SDL_JOYBUTTONDOWN
;
294 e_LogWritefln('Input Debug: NOT IN RANGE! jbutton, joy=%s, button=%s, press=%s', [ev
.which
, ev
.button
, down
])
299 procedure HandleJoyAxis (var ev
: TSDL_JoyAxisEvent
);
300 var key
, minuskey
: Integer;
302 if (ev
.which
< e_MaxJoys
) and (ev
.axis
< e_MaxJoyAxes
) then
304 key
:= e_JoyAxisToKey(ev
.which
, ev
.axis
, AX_PLUS
);
305 minuskey
:= e_JoyAxisToKey(ev
.which
, ev
.axis
, AX_MINUS
);
308 e_LogWritefln('Input Debug: jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev
.which
, ev
.axis
, ev
.value
, JoystickZeroAxes
[ev
.which
, ev
.axis
], e_JoystickDeadzones
[ev
.which
]]);
310 if ev
.value
< JoystickZeroAxes
[ev
.which
, ev
.axis
] - e_JoystickDeadzones
[ev
.which
] then
312 if (e_KeyPressed(key
)) then
314 e_KeyUpDown(key
, False);
315 g_Console_ProcessBind(key
, False)
317 e_KeyUpDown(minuskey
, True);
318 g_Console_ProcessBind(minuskey
, True)
320 else if ev
.value
> JoystickZeroAxes
[ev
.which
, ev
.axis
] + e_JoystickDeadzones
[ev
.which
] then
322 if (e_KeyPressed(minuskey
)) then
324 e_KeyUpDown(minuskey
, False);
325 g_Console_ProcessBind(minuskey
, False)
327 e_KeyUpDown(key
, True);
328 g_Console_ProcessBind(key
, True)
332 if (e_KeyPressed(minuskey
)) then
334 e_KeyUpDown(minuskey
, False);
335 g_Console_ProcessBind(minuskey
, False)
337 if (e_KeyPressed(key
)) then
339 e_KeyUpDown(key
, False);
340 g_Console_ProcessBind(key
, False)
347 e_LogWritefln('Input Debug: NOT IN RANGE! jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev
.which
, ev
.axis
, ev
.value
, JoystickZeroAxes
[ev
.which
, ev
.axis
], e_JoystickDeadzones
[ev
.which
]])
351 procedure HandleJoyHat (var ev
: TSDL_JoyHatEvent
);
355 hat
: array [HAT_LEFT
..HAT_DOWN
] of Boolean;
357 if (ev
.which
< e_MaxJoys
) and (ev
.hat
< e_MaxJoyHats
) then
360 e_LogWritefln('Input Debug: jhat, joy=%s, hat=%s, value=%s', [ev
.which
, ev
.hat
, ev
.value
]);
361 hat
[HAT_UP
] := LongBool(ev
.value
and SDL_HAT_UP
);
362 hat
[HAT_DOWN
] := LongBool(ev
.value
and SDL_HAT_DOWN
);
363 hat
[HAT_LEFT
] := LongBool(ev
.value
and SDL_HAT_LEFT
);
364 hat
[HAT_RIGHT
] := LongBool(ev
.value
and SDL_HAT_RIGHT
);
365 for i
:= HAT_LEFT
to HAT_DOWN
do
367 if JoystickHatState
[ev
.which
, ev
.hat
, i
] <> hat
[i
] then
370 key
:= e_JoyHatToKey(ev
.which
, ev
.hat
, i
);
371 e_KeyUpDown(key
, down
);
372 g_Console_ProcessBind(key
, down
)
375 JoystickHatState
[ev
.which
, ev
.hat
] := hat
380 e_LogWritefln('Input Debug: NOT IN RANGE! jhat, joy=%s, hat=%s, value=%s', [ev
.which
, ev
.hat
, ev
.value
])
384 procedure HandleJoyAdd (var ev
: TSDL_JoyDeviceEvent
);
387 if (ev
.which
< e_MaxJoys
) then
389 JoystickHandle
[ev
.which
] := SDL_JoystickOpen(ev
.which
);
390 if JoystickHandle
[ev
.which
] <> nil then
392 e_LogWritefln('Added Joystick %s', [ev
.which
]);
393 e_JoystickAvailable
[ev
.which
] := True;
394 for i
:= 0 to Min(SDL_JoystickNumAxes(JoystickHandle
[ev
.which
]), e_MaxJoyAxes
) - 1 do
395 JoystickZeroAxes
[ev
.which
, i
] := SDL_JoystickGetAxis(JoystickHandle
[ev
.which
], i
)
399 e_LogWritefln('Warning! Failed to open Joystick %s', [ev
.which
])
404 e_LogWritefln('Warning! Added Joystick %s, but we support only <= %s', [ev
.which
, e_MaxJoys
])
408 procedure HandleJoyRemove (var ev
: TSDL_JoyDeviceEvent
);
410 e_LogWritefln('Removed Joystick %s', [ev
.which
]);
411 if (ev
.which
< e_MaxJoys
) then
413 e_JoystickAvailable
[ev
.which
] := False;
414 if JoystickHandle
[ev
.which
] <> nil then
415 SDL_JoystickClose(JoystickHandle
[ev
.which
]);
416 JoystickHandle
[ev
.which
] := nil
420 (* --------- Touch --------- *)
422 {$IFDEF ENABLE_TOUCH}
423 function sys_IsTextInputActive (): Boolean;
425 Result
:= SDL_IsTextInputActive() = SDL_True
428 procedure sys_ShowKeyboard (yes
: Boolean);
431 e_LogWritefln('g_Touch_ShowKeyboard(%s)', [yes
]);
432 (* on desktop we always receive text (needed for cheats) *)
433 if yes
or (SDL_HasScreenKeyboardSupport() = SDL_FALSE
) then
439 procedure HandleTouch (const ev
: TSDL_TouchFingerEvent
);
441 x
, y
, i
, finger
: Integer;
443 function IntersectControl(ctl
, xx
, yy
: Integer): Boolean;
444 {$IFDEF ENABLE_RENDER}
445 var x
, y
, w
, h
: Integer; founded
: Boolean;
448 {$IFDEF ENABLE_RENDER}
449 r_Render_GetKeyRect(ctl
, x
, y
, w
, h
, founded
);
450 Result
:= founded
and (xx
>= x
) and (yy
>= y
) and (xx
<= x
+ w
) and (yy
<= y
+ h
);
456 procedure KeyUp (finger
, i
: Integer);
459 e_LogWritefln('Input Debug: g_touch.KeyUp, finger=%s, key=%s', [finger
, i
]);
462 e_KeyUpDown(i
, False);
463 g_Console_ProcessBind(i
, False);
465 (* up/down + fire hack *)
467 if g_touch_fire
and (gGameSettings
.GameType
<> GT_NONE
) and (g_ActiveWindow
= nil) and angleFire
then
469 if g_touch_fire
and (gGameSettings
.GameType
<> GT_NONE
) and angleFire
then
472 if (i
= VK_UP
) or (i
= VK_DOWN
) then
475 keyFinger
[VK_FIRE
] := 0;
476 e_KeyUpDown(VK_FIRE
, False);
477 g_Console_ProcessBind(VK_FIRE
, False)
482 procedure KeyDown (finger
, i
: Integer);
485 e_LogWritefln('Input Debug: g_touch.KeyDown, finger=%s, key=%s', [finger
, i
]);
487 keyFinger
[i
] := finger
;
488 e_KeyUpDown(i
, True);
489 g_Console_ProcessBind(i
, True);
491 (* up/down + fire hack *)
493 if g_touch_fire
and (gGameSettings
.GameType
<> GT_NONE
) and (g_ActiveWindow
= nil) then
495 if g_touch_fire
and (gGameSettings
.GameType
<> GT_NONE
) then
501 keyFinger
[VK_FIRE
] := -1;
502 e_KeyUpDown(VK_FIRE
, True);
503 g_Console_ProcessBind(VK_FIRE
, True)
505 else if i
= VK_DOWN
then
508 keyFinger
[VK_FIRE
] := -1;
509 e_KeyUpDown(VK_FIRE
, True);
510 g_Console_ProcessBind(VK_FIRE
, True)
515 procedure KeyMotion (finger
, i
: Integer);
517 if keyFinger
[i
] <> finger
then
525 if not g_touch_enabled
then
528 finger
:= ev
.fingerId
+ 2;
529 x
:= Trunc(ev
.x
* gWinSizeX
);
530 y
:= Trunc(ev
.y
* gWinSizeY
);
532 for i
:= VK_FIRSTKEY
to VK_LASTKEY
do
534 if IntersectControl(i
, x
, y
) then
536 if ev
.type_
= SDL_FINGERUP
then
538 else if ev
.type_
= SDL_FINGERMOTION
then
540 else if ev
.type_
= SDL_FINGERDOWN
then
543 else if keyFinger
[i
] = finger
then
545 if ev
.type_
= SDL_FINGERUP
then
547 else if ev
.type_
= SDL_FINGERMOTION
then
554 (* --------- Input --------- *)
556 function HandleWindow (var ev
: TSDL_WindowEvent
): Boolean;
560 e_LogWritefln('Window Event: event = %s, data1 = %s, data2 = %s', [ev
.event
, ev
.data1
, ev
.data2
]);
562 SDL_WINDOWEVENT_RESIZED
:
563 if @sys_ScreenResize
<> nil then
564 sys_ScreenResize(ev
.data1
, ev
.data2
);
565 SDL_WINDOWEVENT_EXPOSED
: sys_Repaint
;
566 SDL_WINDOWEVENT_CLOSE
: result
:= true;
567 SDL_WINDOWEVENT_MOVED
:
572 SDL_WINDOWEVENT_FOCUS_LOST
, SDL_WINDOWEVENT_MINIMIZED
:
575 if gMuteWhenInactive
then
576 e_MuteChannels(true);
577 {$IFDEF ENABLE_HOLMES}
578 if assigned(winBlurCB
) then winBlurCB
;
581 SDL_WINDOWEVENT_FOCUS_GAINED
, SDL_WINDOWEVENT_MAXIMIZED
, SDL_WINDOWEVENT_RESTORED
:
583 if ev
.event
= SDL_WINDOWEVENT_MAXIMIZED
then
585 gWinMaximized
:= true;
586 gRC_Maximized
:= true
588 else if ev
.event
= SDL_WINDOWEVENT_RESTORED
then
590 gWinMaximized
:= false;
591 gRC_Maximized
:= false
593 e_MuteChannels(false);
594 {$IFDEF ENABLE_HOLMES}
595 if assigned(winFocusCB
) then winFocusCB
;
601 procedure HandleKeyboard (var ev
: TSDL_KeyboardEvent
);
602 var down
: Boolean; key
: Integer;
604 key
:= ev
.keysym
.scancode
;
605 down
:= (ev
.type_
= SDL_KEYDOWN
);
606 if key
= SDL_SCANCODE_AC_BACK
then
607 key
:= SDL_SCANCODE_ESCAPE
;
608 {$IFDEF ENABLE_HOLMES}
609 if fuiOnSDLEvent(PSDL_Event(@ev
)^) then
611 // event eaten, but...
612 if not down
then e_KeyUpDown(key
, false);
616 if ev
._repeat
= 0 then
619 e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s', [down
, key
]);
620 e_KeyUpDown(key
, down
);
621 g_Console_ProcessBind(key
, down
);
626 e_LogWritefln('Input Debug: keyrep, scancode=%s', [key
]);
627 g_Console_ProcessBindRepeat(key
);
631 procedure HandleTextInput (var ev
: TSDL_TextInputEvent
);
632 var ch
: UnicodeChar
; sch
: AnsiChar;
634 Utf8ToUnicode(@ch
, PChar(ev
.text), 1);
635 sch
:= AnsiChar(wchar2win(ch
));
637 e_LogWritefln('Input Debug: text, text="%s", ch = %s, sch = %s', [ev
.text, Ord(ch
), Ord(sch
)]);
638 if @sys_CharPress
<> nil then
639 if IsValid1251(Word(ch
)) and IsPrintable1251(ch
) then
643 function sys_HandleInput (): Boolean;
647 ZeroMemory(@ev
, sizeof(ev
));
648 while SDL_PollEvent(@ev
) <> 0 do
651 SDL_QUITEV
: result
:= true;
652 SDL_WINDOWEVENT
: result
:= HandleWindow(ev
.window
);
653 SDL_KEYUP
, SDL_KEYDOWN
: HandleKeyboard(ev
.key
);
654 SDL_JOYBUTTONDOWN
, SDL_JOYBUTTONUP
: HandleJoyButton(ev
.jbutton
);
655 SDL_JOYAXISMOTION
: HandleJoyAxis(ev
.jaxis
);
656 SDL_JOYHATMOTION
: HandleJoyHat(ev
.jhat
);
657 SDL_JOYDEVICEADDED
: HandleJoyAdd(ev
.jdevice
);
658 SDL_JOYDEVICEREMOVED
: HandleJoyRemove(ev
.jdevice
);
659 SDL_TEXTINPUT
: HandleTextInput(ev
.text);
660 {$IFDEF ENABLE_TOUCH}
661 SDL_FINGERMOTION
, SDL_FINGERDOWN
, SDL_FINGERUP
: HandleTouch(ev
.tfinger
);
663 {$IFDEF ENABLE_HOLMES}
664 SDL_MOUSEBUTTONDOWN
, SDL_MOUSEBUTTONUP
, SDL_MOUSEWHEEL
, SDL_MOUSEMOTION
: fuiOnSDLEvent(ev
);
670 procedure sys_RequestQuit
;
673 ev
.type_
:= SDL_QUITEV
;
677 (* --------- Init --------- *)
682 e_WriteLog('Init SDL2', TMsgType
.Notify
);
684 {$IFDEF USE_SDLMIXER}
685 flags
:= SDL_INIT_TIMER
or SDL_INIT_AUDIO
or $00004000;
687 flags
:= SDL_INIT_TIMER
or $00004000;
690 flags
:= SDL_INIT_TIMER
or SDL_INIT_VIDEO
;
692 SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK
, '0');
693 if SDL_Init(flags
) <> 0 then
694 raise Exception
.Create('SDL: Init failed: ' + SDL_GetError
);
696 if SDL_InitSubSystem(SDL_INIT_JOYSTICK
) <> 0 then
697 e_LogWritefln('SDL: Init subsystem failed: %s', [SDL_GetError()]);
699 SDL_ShowCursor(SDL_DISABLE
);
700 {$IFDEF ENABLE_TOUCH}
701 sys_ShowKeyboard(FALSE);
702 g_touch_enabled
:= SDL_GetNumTouchDevices() > 0;
704 g_touch_enabled
:= False;
710 e_WriteLog('Releasing SDL2', TMsgType
.Notify
);
711 if context
<> nil then
713 SDL_GL_DeleteContext(context
);
716 if window
<> nil then
718 SDL_DestroyWindow(window
);
725 conRegVar('sdl2_display_index', @display
, 'use display index as base', '');
726 conRegVar('sdl2_window_x', @wx
, 'window position x', '');
727 conRegVar('sdl2_window_y', @wy
, 'window position y', '');
728 conRegVar('sdl2_window_center', @wc
, 'force window creation at center', '');
730 wx
:= SDL_WINDOWPOS_CENTERED
;
731 wy
:= SDL_WINDOWPOS_CENTERED
;