diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 3950137c0361ab6a7aca40eca9e30c385cf280de..d790c4f852c9f468bd51c39ba4a9fd1b221faa20 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
g_console, e_input, g_options, g_game,
g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
g_map, g_gfx, g_monsters, xprofiler,
- g_touch;
+ g_touch, g_gui;
const
ticksOverflow: Int64 = -1;
lastTicks: Uint32 = 0; // to detect overflow
{$ENDIF}
- JoystickHatState: array [0..e_MaxJoys, 0..e_MaxJoyHats, HAT_LEFT..HAT_DOWN] of Boolean;
- JoystickZeroAxes: array [0..e_MaxJoys, 0..e_MaxJoyAxes] of Integer;
+ JoystickHandle: array [0..e_MaxJoys - 1] of PSDL_Joystick;
+ JoystickHatState: array [0..e_MaxJoys - 1, 0..e_MaxJoyHats - 1, HAT_LEFT..HAT_DOWN] of Boolean;
+ JoystickZeroAxes: array [0..e_MaxJoys - 1, 0..e_MaxJoyAxes - 1] of Integer;
procedure KillGLWindow (preserveGL: Boolean);
begin
down: Boolean;
i: Integer;
hat: array [HAT_LEFT..HAT_DOWN] of Boolean;
- joy: PSDL_Joystick;
begin
result := false;
if g_dbg_input then
e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s', [down, key]);
e_KeyUpDown(key, down);
- g_Console_ProcessBind(key, down)
+ g_Console_ProcessBind(key, down);
+ end
+ else if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+ begin
+ // key repeat in menus and shit
+ KeyPress(key);
end;
- if down then KeyPress(key);
end;
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP:
e_LogWritefln('Input Debug: jbutton, joy=%s, button=%s, keycode=%s, press=%s', [ev.jbutton.which, ev.jbutton.button, key, down]);
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
- if down then KeyPress(key)
end
else
begin
end;
e_KeyUpDown(minuskey, True);
g_Console_ProcessBind(minuskey, True);
- KeyPress(minuskey);
end
else if ev.jaxis.value > JoystickZeroAxes[ev.jaxis.which, ev.jaxis.axis] + e_JoystickDeadzones[ev.jaxis.which] then
begin
end;
e_KeyUpDown(key, True);
g_Console_ProcessBind(key, True);
- KeyPress(key);
end
else
begin
key := e_JoyHatToKey(ev.jhat.which, ev.jhat.hat, i);
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
- if down then KeyPress(key)
end
end;
JoystickHatState[ev.jhat.which, ev.jhat.hat] := hat
SDL_JOYDEVICEADDED:
if (ev.jdevice.which < e_MaxJoys) then
begin
- joy := SDL_JoystickOpen(ev.jdevice.which);
- ASSERT(joy <> nil);
- e_LogWritefln('Added Joystick %s', [ev.jdevice.which]);
- e_JoystickAvailable[ev.jdevice.which] := True;
- for i := 0 to Min(SDL_JoystickNumAxes(joy), e_MaxJoyAxes) do
- JoystickZeroAxes[ev.jdevice.which, i] := SDL_JoystickGetAxis(joy, i);
- SDL_JoystickClose(joy)
+ JoystickHandle[ev.jdevice.which] := SDL_JoystickOpen(ev.jdevice.which);
+ if JoystickHandle[ev.jdevice.which] <> nil then
+ begin
+ e_LogWritefln('Added Joystick %s', [ev.jdevice.which]);
+ e_JoystickAvailable[ev.jdevice.which] := True;
+ for i := 0 to Min(SDL_JoystickNumAxes(JoystickHandle[ev.jdevice.which]), e_MaxJoyAxes) - 1 do
+ JoystickZeroAxes[ev.jdevice.which, i] := SDL_JoystickGetAxis(JoystickHandle[ev.jdevice.which], i)
+ end
+ else
+ e_LogWritefln('Warning! Failed to open Joystick %s', [ev.jdevice.which])
end
else
begin
begin
e_LogWritefln('Removed Joystick %s', [ev.jdevice.which]);
if (ev.jdevice.which < e_MaxJoys) then
- e_JoystickAvailable[ev.jdevice.which] := False
+ begin
+ e_JoystickAvailable[ev.jdevice.which] := False;
+ if JoystickHandle[ev.jdevice.which] <> nil then
+ SDL_JoystickClose(JoystickHandle[ev.jdevice.which]);
+ JoystickHandle[ev.jdevice.which] := nil
+ end
end;
{$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)}
procedure ProcessLoading (forceUpdate: Boolean=false);
var
ev: TSDL_Event;
- ID: LongWord;
stt: UInt64;
begin
FillChar(ev, sizeof(ev), 0);
if forceUpdate then
begin
- if g_Texture_Get('INTER', ID) then
- begin
- e_DrawSize(ID, 0, 0, 0, false, false, gScreenWidth, gScreenHeight);
- e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
- end
- else
- begin
- e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
- end;
+ DrawMenuBackground('INTER');
+ e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
DrawLoadingStat();
SwapBuffers();
{$IFDEF USE_GLES1}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
{$ELSE}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);