summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e632c8d)
raw | patch | inline | side by side (parent: e632c8d)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 19 Sep 2017 04:31:08 +0000 (07:31 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 19 Sep 2017 04:32:25 +0000 (07:32 +0300) |
src/game/g_window.pas | patch | blob | history |
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 97d359ea088d269019be92376800c7401dbc6557..bd2a287ae5aa094e7d649c43601707065156962a 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
ticksOverflow: Int64 = -1;
lastTicks: Uint32 = 0; // to detect overflow
{$ENDIF}
+{$IF not DEFINED(HEADLESS)}
curMsButState: Word = 0;
curKbState: Word = 0;
curMsX: Integer = 0;
curMsY: Integer = 0;
+{$ENDIF}
function g_Window_SetDisplay(PreserveGL: Boolean = False): Boolean;
var
end;
end;
+procedure resetKMState ();
+begin
+{$IF not DEFINED(HEADLESS)}
+ curMsButState := 0;
+ curKbState := 0;
+{$ENDIF}
+end;
+
function WindowEventHandler(ev: TSDL_WindowEvent): Boolean;
var
wActivate, wDeactivate: Boolean;
SDL_WINDOWEVENT_MINIMIZED:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
e_UnpressAllKeys();
if not wMinimized then
begin
SDL_WINDOWEVENT_RESIZED:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
gScreenWidth := ev.data1;
gScreenHeight := ev.data2;
ChangeWindowSize();
SDL_WINDOWEVENT_MAXIMIZED:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
if wMinimized then
begin
e_ResizeWindow(gScreenWidth, gScreenHeight);
SDL_WINDOWEVENT_RESTORED:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
if wMinimized then
begin
e_ResizeWindow(gScreenWidth, gScreenHeight);
SDL_WINDOWEVENT_FOCUS_GAINED:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
wActivate := True;
//e_WriteLog('window gained focus!', MSG_NOTIFY);
g_Holmes_WindowFocused();
SDL_WINDOWEVENT_FOCUS_LOST:
begin
- curMsButState := 0;
- curKbState := 0;
+ resetKMState();
wDeactivate := True;
e_UnpressAllKeys();
//e_WriteLog('window lost focus!', MSG_NOTIFY);
key, keychr: Word;
uc: UnicodeChar;
//joy: Integer;
+ {$IF not DEFINED(HEADLESS)}
msev: THMouseEvent;
kbev: THKeyEvent;
+ {$ENDIF}
function buildBut (b: Byte): Word;
begin
end;
end;
+ {$IF not DEFINED(HEADLESS)}
procedure updateKBState ();
var
kbstate: PUint8;
if (kbstate[SDL_SCANCODE_LALT] <> 0) or (kbstate[SDL_SCANCODE_RALT] <> 0) then curKbState := curKbState or THKeyEvent.ModAlt;
if (kbstate[SDL_SCANCODE_LSHIFT] <> 0) or (kbstate[SDL_SCANCODE_RSHIFT] <> 0) then curKbState := curKbState or THKeyEvent.ModShift;
end;
+ {$ENDIF}
begin
Result := False;
+ {$IF not DEFINED(HEADLESS)}
updateKBState();
+ {$ENDIF}
case ev.type_ of
SDL_WINDOWEVENT:
SDL_KEYDOWN, SDL_KEYUP:
begin
key := ev.key.keysym.scancode;
+ {$IF not DEFINED(HEADLESS)}
if (g_holmes_enabled) then
begin
if (ev.type_ = SDL_KEYDOWN) then kbev.kind := THKeyEvent.Press else kbev.kind := THKeyEvent.Release;
kbev.sym := ev.key.keysym.sym;
kbev.bstate := curMsButState;
kbev.kstate := curKbState;
- {$IF not DEFINED(HEADLESS)}
if g_Holmes_keyEvent(kbev) then
begin
if (ev.type_ <> SDL_KEYDOWN) then e_KeyUpDown(ev.key.keysym.scancode, false);
exit;
end;
- {$ENDIF}
end;
+ {$ENDIF}
if (ev.type_ = SDL_KEYDOWN) then KeyPress(key);
e_KeyUpDown(ev.key.keysym.scancode, (ev.type_ = SDL_KEYDOWN));
end;
procedure SwapBuffers();
begin
- {$IFDEF HEADLESS}Exit;{$ENDIF}
+ {$IF not DEFINED(HEADLESS)}
SDL_GL_SwapWindow(h_Wnd);
+ {$ENDIF}
end;
procedure KillGLWindow();
function SDLMain(): Integer;
var
idx: Integer;
+ {$IF not DEFINED(HEADLESS)}
ltmp: Integer;
+ {$ENDIF}
arg: AnsiString;
mdfo: TStream;
begin