summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eca2ce7)
raw | patch | inline | side by side (parent: eca2ce7)
author | Stas'M <x86corez@gmail.com> | |
Sun, 2 May 2021 22:04:31 +0000 (01:04 +0300) | ||
committer | Stas'M <x86corez@gmail.com> | |
Sun, 2 May 2021 22:04:31 +0000 (01:04 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/sdl/g_system.pas | patch | blob | history | |
src/game/sdl2/g_system.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index c779409eaa4ecc070b5ddf844b941f1e4c16c7be..bbbd1c2024df8a367eff8f7beb22a575c427ba83 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
function g_Console_FindBind (n: Integer; down: AnsiString; up: AnsiString = ''): Integer;
procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = '');
procedure g_Console_ProcessBind (key: Integer; down: Boolean);
+procedure g_Console_ProcessBindRepeat (key: Integer);
procedure g_Console_ResetBinds;
procedure conwriteln (const s: AnsiString; show: Boolean=false);
end;
gInputBinds: Array [0..e_MaxInputKeys - 1] of record
+ rep: Boolean;
down, up: SSArray;
end;
menu_toggled: BOOLEAN; (* hack for menu controls *)
begin
g_Console_Add('bind <key> <down action> [up action]')
end;
+ 'bindrep':
+ // bindrep <key>
+ if Length(p) = 2 then
+ begin
+ key := LowerCase(p[1]);
+ i := 0;
+ while (i < e_MaxInputKeys) and (key <> LowerCase(e_KeyNames[i])) do inc(i);
+ if i < e_MaxInputKeys then
+ gInputBinds[i].rep := True
+ else
+ g_Console_Add('bindrep: "' + p[1] + '" is not a key')
+ end
+ else
+ g_Console_Add('bindrep <key>');
+ 'bindunrep':
+ // bindunrep <key>
+ if Length(p) = 2 then
+ begin
+ key := LowerCase(p[1]);
+ i := 0;
+ while (i < e_MaxInputKeys) and (key <> LowerCase(e_KeyNames[i])) do inc(i);
+ if i < e_MaxInputKeys then
+ gInputBinds[i].rep := False
+ else
+ g_Console_Add('bindunrep: "' + p[1] + '" is not a key')
+ end
+ else
+ g_Console_Add('bindunrep <key>');
'bindlist':
for i := 0 to e_MaxInputKeys - 1 do
if (gInputBinds[i].down <> nil) or (gInputBinds[i].up <> nil) then
AddCommand('g_language', SystemCommands);
AddCommand('bind', BindCommands);
+ AddCommand('bindrep', BindCommands);
+ AddCommand('bindunrep', BindCommands);
AddCommand('bindlist', BindCommands);
AddCommand('unbind', BindCommands);
AddCommand('unbindall', BindCommands);
ASSERT(key < e_MaxInputKeys);
if key > 0 then
begin
+ gInputBinds[key].rep := False;
gInputBinds[key].down := ParseAlias(down);
gInputBinds[key].up := ParseAlias(up);
end;
menu_toggled := False
end;
+procedure g_Console_ProcessBindRepeat (key: Integer);
+ var i: Integer;
+begin
+ if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+ begin
+ KeyPress(key); // key repeat in menus and shit
+ Exit;
+ end;
+ if BindsAllowed(key) and gInputBinds[key].rep then
+ begin
+ for i := 0 to High(gInputBinds[key].down) do
+ g_Console_Process(gInputBinds[key].down[i], True);
+ end;
+end;
+
procedure g_Console_ResetBinds;
var i: Integer;
begin
if Length(gInputBinds[i].up) > 0 then
Write(f, ' ', QuoteStr(GetCommandString(gInputBinds[i].up)));
WriteLn(f, '');
+ if gInputBinds[i].rep then
+ WriteLn(f, 'bindrep ', e_KeyNames[i]);
end;
// lang
index c53a7b347596c44c4331497c94c7ee3a2cb524b0..1f4061abf7fdc4ba9ff74475e09d7ece908356e1 100644 (file)
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
end
- else if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+ else
begin
- KeyPress(key) // key repeat in menus and shit
+ g_Console_ProcessBindRepeat(key)
end;
if down and IsValid1251(ev.keysym.unicode) and IsPrintable1251(ch) then
CharPress(ch)
index 8842b6794b7362b7cf4860c09abacbbaa0ca91f4..eec03232f7d26e99fd2619d39994ff5291b26257 100644 (file)
e_KeyUpDown(key, down);
g_Console_ProcessBind(key, down);
end
- else if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+ else
begin
- KeyPress(key) // key repeat in menus and shit
+ if g_dbg_input then
+ e_LogWritefln('Input Debug: keyrep, scancode=%s', [key]);
+ g_Console_ProcessBindRepeat(key);
end
end;