function e_InitInput(): Boolean;
procedure e_ReleaseInput();
procedure e_ClearInputBuffer();
-function e_PollInput(): Boolean;
+//function e_PollInput(): Boolean;
+procedure e_PollJoysticks(); // call this from message loop to update joysticks
function e_KeyPressed(Key: Word): Boolean;
function e_AnyKeyPressed(): Boolean;
function e_GetFirstKeyPressed(): Word;
}
end;
-function PollJoysticks(): Boolean;
+procedure e_PollJoysticks();
var
i, j: Word;
hat: Byte;
begin
- Result := False;
+ //Result := False;
if (Joysticks = nil) or (e_JoysticksAvailable = 0) then Exit;
SDL_JoystickUpdate();
for j := Low(Joysticks) to High(Joysticks) do
+ begin
with Joysticks[j] do
begin
- for i := 0 to Buttons do
- ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0;
- for i := 0 to Axes do
- AxisBuf[i] := SDL_JoystickGetAxis(Handle, i);
+ for i := 0 to Buttons do ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0;
+ for i := 0 to Axes do AxisBuf[i] := SDL_JoystickGetAxis(Handle, i);
for i := 0 to Hats do
begin
hat := SDL_JoystickGetHat(Handle, i);
HatBuf[i, HAT_RIGHT] := LongBool(hat and SDL_HAT_RIGHT);
end;
end;
+ end;
end;
procedure GenerateKeyNames();
end;
end;
+{
function e_PollInput(): Boolean;
var
kb, js: Boolean;
begin
kb := PollKeyboard();
- js := PollJoysticks();
+ js := e_PollJoysticks();
Result := kb or js;
end;
+}
function e_KeyPressed(Key: Word): Boolean;
var
Exit;
end;
-// ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
- e_PollInput();
+ // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
+ // no need to, as we'll do it in event handler
// Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
g_Console_Update();
begin
e_TextureFontGetSize(gStdFont, ww2, hh2);
- e_PollInput();
+ g_ProcessMessages();
+
if e_KeyPressed(IK_TAB) then
begin
if not gStatsPressed then
enet_packet_destroy(NetEvent.packet);
end
else
+ begin
if (NetEvent.kind = ENET_EVENT_TYPE_DISCONNECT) then
begin
State := 0;
OuterLoop := False;
Break;
end;
+ end;
end;
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
begin
State := 0;
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
OuterLoop := False;
end;
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
break;
end;
end;
procedure g_Serverlist_Control(var SL: TNetServerList);
+var
+ qm: Boolean;
begin
if gConsoleShow or gChatShow then
Exit;
- e_PollInput();
+ qm := g_ProcessMessages(); // this updates kbd
- if e_KeyPressed(IK_ESCAPE) then
+ if qm or e_KeyPressed(IK_ESCAPE) then
begin
SL := nil;
gState := STATE_MENU;
wadoptFast := gSFSFastMode;
e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', 'megawads/DOOM2D.WAD:\MAP01');
- gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitch', False);
+ gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
// Ãåéìïëåé â ñâîåé èãðå
gcMap := config.ReadStr('GameplayCustom', 'Map', '');
config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
- config.WriteBool('Game', 'BerserkAutoswitch', gBerserkAutoswitch);
+ config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
config.WriteStr ('GameplayCustom', 'Map', gcMap);
config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
else
g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj.X, FObj.Y);
- if gFlash = 1 then
- if FPain < 50 then
- FPain := min(FPain + 25, 50);
- end else g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID);
+ if (gFlash = 1) and (FPain < 50) then FPain := min(FPain + 25, 50);
+ end
+ else
+ begin
+ g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID);
+ end;
DidFire := True;
FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap];
procedure ProcessLoading (forceUpdate: Boolean=false);
+// returns `true` if quit event was received
+function g_ProcessMessages (): Boolean;
+
var
gwin_dump_extensions: Boolean = false;
while (SDL_PollEvent(@ev) > 0) do
begin
+ EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then break;
end;
+ e_PollJoysticks();
if (ev.type_ = SDL_QUITEV) or (gExit = EXIT_QUIT) then
begin
end;
-function ProcessMessage (): Boolean;
+function g_ProcessMessages (): Boolean;
var
- i, t: Integer;
ev: TSDL_Event;
begin
result := false;
FillChar(ev, SizeOf(ev), 0);
-
while (SDL_PollEvent(@ev) > 0) do
begin
result := EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then exit;
end;
+ e_PollJoysticks();
+end;
+
+
+function ProcessMessage (): Boolean;
+var
+ i, t: Integer;
+begin
+ result := g_ProcessMessages();
Time := GetTimer();
Time_Delta := Time-Time_Old;