diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 44997de63c8046824eb8b1c762ad9fb636fe57f1..d703ea2fc2088a829bfa3af1bf07b83d31b44f16 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
gwin_has_stencil: Boolean = false;
gwin_k8_enable_light_experiments: Boolean = false;
g_dbg_aimline_on: Boolean = false;
gwin_has_stencil: Boolean = false;
gwin_k8_enable_light_experiments: Boolean = false;
g_dbg_aimline_on: Boolean = false;
+ g_dbg_input: Boolean = False;
implementation
implementation
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_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
const
ticksOverflow: Int64 = -1;
lastTicks: Uint32 = 0; // to detect overflow
{$ENDIF}
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
procedure KillGLWindow (preserveGL: Boolean);
begin
down: Boolean;
i: Integer;
hat: array [HAT_LEFT..HAT_DOWN] of Boolean;
down: Boolean;
i: Integer;
hat: array [HAT_LEFT..HAT_DOWN] of Boolean;
- joy: PSDL_Joystick;
begin
result := false;
begin
result := false;
{$ENDIF}
if ev.key._repeat = 0 then
begin
{$ENDIF}
if ev.key._repeat = 0 then
begin
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s', [down, key]);
e_KeyUpDown(key, down);
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;
end;
- if down then KeyPress(key);
end;
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP:
end;
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP:
begin
key := e_JoyButtonToKey(ev.jbutton.which, ev.jbutton.button);
down := ev.type_ = SDL_JOYBUTTONDOWN;
begin
key := e_JoyButtonToKey(ev.jbutton.which, ev.jbutton.button);
down := ev.type_ = SDL_JOYBUTTONDOWN;
+ if g_dbg_input then
+ 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);
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
- if down then KeyPress(key)
+ end
+ else
+ begin
+ if g_dbg_input then
+ begin
+ down := ev.type_ = SDL_JOYBUTTONDOWN;
+ e_LogWritefln('Input Debug: NOT IN RANGE! jbutton, joy=%s, button=%s, press=%s', [ev.jbutton.which, ev.jbutton.button, down])
+ end
end;
SDL_JOYAXISMOTION:
end;
SDL_JOYAXISMOTION:
key := e_JoyAxisToKey(ev.jaxis.which, ev.jaxis.axis, AX_PLUS);
minuskey := e_JoyAxisToKey(ev.jaxis.which, ev.jaxis.axis, AX_MINUS);
key := e_JoyAxisToKey(ev.jaxis.which, ev.jaxis.axis, AX_PLUS);
minuskey := e_JoyAxisToKey(ev.jaxis.which, ev.jaxis.axis, AX_MINUS);
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev.jaxis.which, ev.jaxis.axis, ev.jaxis.value, JoystickZeroAxes[ev.jaxis.which, ev.jaxis.axis], e_JoystickDeadzones[ev.jaxis.which]]);
+
if ev.jaxis.value < JoystickZeroAxes[ev.jaxis.which, ev.jaxis.axis] - e_JoystickDeadzones[ev.jaxis.which] then
begin
if (e_KeyPressed(key)) then
if ev.jaxis.value < JoystickZeroAxes[ev.jaxis.which, ev.jaxis.axis] - e_JoystickDeadzones[ev.jaxis.which] then
begin
if (e_KeyPressed(key)) then
end;
e_KeyUpDown(minuskey, True);
g_Console_ProcessBind(minuskey, True);
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
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);
end;
e_KeyUpDown(key, True);
g_Console_ProcessBind(key, True);
- KeyPress(key);
end
else
begin
end
else
begin
g_Console_ProcessBind(key, False);
end;
end;
g_Console_ProcessBind(key, False);
end;
end;
+ end
+ else
+ begin
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: NOT IN RANGE! jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev.jaxis.which, ev.jaxis.axis, ev.jaxis.value, JoystickZeroAxes[ev.jaxis.which, ev.jaxis.axis], e_JoystickDeadzones[ev.jaxis.which]])
end;
SDL_JOYHATMOTION:
if (ev.jhat.which < e_MaxJoys) and (ev.jhat.hat < e_MaxJoyHats) then
begin
end;
SDL_JOYHATMOTION:
if (ev.jhat.which < e_MaxJoys) and (ev.jhat.hat < e_MaxJoyHats) then
begin
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: jhat, joy=%s, hat=%s, value=%s', [ev.jhat.which, ev.jhat.hat, ev.jhat.value]);
hat[HAT_UP] := LongBool(ev.jhat.value and SDL_HAT_UP);
hat[HAT_DOWN] := LongBool(ev.jhat.value and SDL_HAT_DOWN);
hat[HAT_LEFT] := LongBool(ev.jhat.value and SDL_HAT_LEFT);
hat[HAT_UP] := LongBool(ev.jhat.value and SDL_HAT_UP);
hat[HAT_DOWN] := LongBool(ev.jhat.value and SDL_HAT_DOWN);
hat[HAT_LEFT] := LongBool(ev.jhat.value and SDL_HAT_LEFT);
key := e_JoyHatToKey(ev.jhat.which, ev.jhat.hat, i);
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
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
end
end;
JoystickHatState[ev.jhat.which, ev.jhat.hat] := hat
+ end
+ else
+ begin
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: NOT IN RANGE! jhat, joy=%s, hat=%s, value=%s', [ev.jhat.which, ev.jhat.hat, ev.jhat.value])
end;
SDL_JOYDEVICEADDED:
if (ev.jdevice.which < e_MaxJoys) then
begin
end;
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
+ e_LogWritefln('Warning! Added Joystick %s, but we support only <= %s', [ev.jdevice.which, e_MaxJoys])
end;
SDL_JOYDEVICEREMOVED:
end;
SDL_JOYDEVICEREMOVED:
- if (ev.jdevice.which < e_MaxJoys) then
begin
begin
- e_JoystickAvailable[ev.jdevice.which] := False;
- e_LogWritefln('Removed Joystick %s', [ev.jdevice.which])
+ e_LogWritefln('Removed Joystick %s', [ev.jdevice.which]);
+ if (ev.jdevice.which < e_MaxJoys) then
+ 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)}
end;
{$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)}
SDL_TEXTINPUT:
begin
SDL_TEXTINPUT:
begin
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: text, text=%s', [ev.text.text]);
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
if (keychr > 127) then keychr := Word(wchar2win(WideChar(keychr)));
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
if (keychr > 127) then keychr := Word(wchar2win(WideChar(keychr)));
procedure ProcessLoading (forceUpdate: Boolean=false);
var
ev: TSDL_Event;
procedure ProcessLoading (forceUpdate: Boolean=false);
var
ev: TSDL_Event;
- ID: LongWord;
stt: UInt64;
begin
FillChar(ev, sizeof(ev), 0);
stt: UInt64;
begin
FillChar(ev, sizeof(ev), 0);
if forceUpdate then
begin
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();
DrawLoadingStat();
+ g_Console_Draw(True);
SwapBuffers();
end;
end;
SwapBuffers();
end;
end;
else if (NetMode = NET_CLIENT) then g_Net_Client_Update();
end;
else if (NetMode = NET_CLIENT) then g_Net_Client_Update();
end;
+ if NetMode = NET_SERVER then g_Net_Flush();
+
g_Map_ProfilersEnd();
g_Mons_ProfilersEnd();
g_Map_ProfilersEnd();
g_Mons_ProfilersEnd();
{$IFDEF USE_GLES1}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
{$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);
{$ELSE}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
+ if arg = '--debug-input' then g_dbg_input := True;
+
{.$IF DEFINED(D2F_DEBUG)}
if arg = '--aimline' then g_dbg_aimline_on := true;
{.$ENDIF}
{.$IF DEFINED(D2F_DEBUG)}
if arg = '--aimline' then g_dbg_aimline_on := true;
{.$ENDIF}
end;
end;
+initialization
+ conRegVar('d_input', @g_dbg_input, '', '')
end.
end.