summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3fff94d)
raw | patch | inline | side by side (parent: 3fff94d)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 5 Apr 2019 14:21:06 +0000 (17:21 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 5 Apr 2019 22:19:41 +0000 (01:19 +0300) |
src/engine/e_input.pas | patch | blob | history | |
src/game/g_console.pas | patch | blob | history | |
src/game/g_touch.pas | patch | blob | history |
diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas
index bf7f61489794872afae17de7a8b786f8bf39a0cf..b93ca59c869d64a7cc99435c66557fc14cb0a99b 100644 (file)
--- a/src/engine/e_input.pas
+++ b/src/engine/e_input.pas
VK_LSTRAFE = VK_FIRSTKEY + 31;
VK_RSTRAFE = VK_FIRSTKEY + 32;
VK_PRINTSCR = VK_FIRSTKEY + 33;
+ VK_SHOWKBD = VK_FIRSTKEY + 34;
+ VK_HIDEKBD = VK_FIRSTKEY + 35;
VK_LASTKEY = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys + e_MaxVirtKeys - 1;
AX_MINUS = 0;
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 5439a0f1738b37198687d599a6f4f37736bbef32..fd8e24b3cf1bd05371a5d9a1c277fc4bdb194418 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
if (gInputBinds[i].down <> nil) then
begin
act := act + gInputBinds[i].down[0];
- for j := 1 to High(gInputBinds[i].down) do
- act := act + ' ;' + gInputBinds[i].down[j];
+ for j := 1 to High(gInputBinds[i].down) - 1 do
+ act := act + '; ' + gInputBinds[i].down[j];
end;
act := act + '" "';
if (gInputBinds[i].up <> nil) then
begin
act := act + gInputBinds[i].up[0];
for j := 1 to High(gInputBinds[i].up) do
- act := act + ' ;' + gInputBinds[i].up[j];
+ act := act + '; ' + gInputBinds[i].up[j];
end;
act := act + '"';
g_Console_Add(act)
g_Console_Add('unbind <key>');
'unbindall':
for i := 0 to e_MaxInputKeys - 1 do
- g_Console_BindKey(i, '')
+ g_Console_BindKey(i, '');
+ 'showkeyboard':
+ g_Touch_ShowKeyboard(True);
+ 'hidekeyboard':
+ g_Touch_ShowKeyboard(False);
end
end;
AddCommand('bindlist', BindCommands);
AddCommand('unbind', BindCommands);
AddCommand('unbindall', BindCommands);
+ AddCommand('showkeyboard', BindCommands);
+ AddCommand('hidekeyboard', BindCommands);
AddCommand('clear', ConsoleCommands, 'clear console');
AddCommand('clearhistory', ConsoleCommands);
g_Console_BindKey(e_JoyButtonToKey(i, 7), '+p' + IntToStr(i mod 2 + 1) + '_strafe', '-p' + IntToStr(i mod 2 + 1) + '_strafe');
end;
+ g_Console_BindKey(VK_LSTRAFE, '+moveleft; +strafe', '-moveleft; -strafe');
+ g_Console_BindKey(VK_RSTRAFE, '+moveright; +strafe', '-moveright; -strafe');
g_Console_BindKey(VK_LEFT, '+moveleft', '-moveleft');
g_Console_BindKey(VK_RIGHT, '+moveright', '-moveright');
g_Console_BindKey(VK_UP, '+lookup', '-lookup');
g_Console_BindKey(VK_TEAM, 'toggleteamchat');
g_Console_BindKey(VK_PRINTSCR, 'screenshot');
g_Console_BindKey(VK_STATUS, '+scores', '-scores');
+ g_Console_BindKey(VK_SHOWKBD, 'showkeyboard');
+ g_Console_BindKey(VK_HIDEKBD, 'hidekeyboard');
// VK_CONSOLE
// VK_ESCAPE
diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas
index 15ecb11f6c5d84b74de96133d5d6715a476ca538..0638cc2713bfbfb432e484160ff431faa77adcbf 100644 (file)
--- a/src/game/g_touch.pas
+++ b/src/game/g_touch.pas
SDL2;
var
- g_touch_enabled: Boolean;
- g_touch_size: Single;
- g_touch_offset: Single;
- g_touch_fire: Boolean;
- g_touch_alt: Boolean;
+ g_touch_enabled: Boolean = False;
+ g_touch_size: Single = 1.0;
+ g_touch_offset: Single = 50.0;
+ g_touch_fire: Boolean = True;
+ g_touch_alt: Boolean = False;
procedure g_Touch_Init;
procedure g_Touch_ShowKeyboard(yes: Boolean);
SysUtils,
e_log, e_graphics, e_input, g_options, g_game, g_main, g_weapons, g_console;
- const
- VS_KEYBOARD = 60000;
- VS_HIDEKEYBOARD = 60001;
-
var
angleFire: Boolean;
keyFinger: array [VK_FIRSTKEY..VK_LASTKEY] of Integer;
if SDL_IsTextInputActive() = SDL_True then
case key of
- VS_HIDEKEYBOARD: S(sw - (sz/2), 0, sz / 2, sz / 2);
+ VK_HIDEKBD: S(sw - (sz/2), 0, sz / 2, sz / 2);
end
else if g_touch_alt then
case key of
(* top ------- x ------------------------------- y w ----- h -- *)
VK_CONSOLE: S(0, 0, sz / 2, sz / 2);
VK_ESCAPE: S(sw - 1*(sz/2) - 1, 0, sz / 2, sz / 2);
- VS_KEYBOARD: S(sw - 2*(sz/2) - 1, 0, sz / 2, sz / 2);
+ VK_SHOWKBD: S(sw - 2*(sz/2) - 1, 0, sz / 2, sz / 2);
VK_CHAT: S(sw / 2 - (sz/2) / 2 - (sz/2) - 1, 0, sz / 2, sz / 2);
VK_STATUS: S(sw / 2 - (sz/2) / 2 - 1, 0, sz / 2, sz / 2);
VK_TEAM: S(sw / 2 - (sz/2) / 2 + (sz/2) - 1, 0, sz / 2, sz / 2);
VK_CONSOLE: S(sw/2 - sz/4 - 1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
VK_STATUS: S(sw/2 - sz/4 - 0*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
VK_TEAM: S(sw/2 - sz/4 - -1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
- VS_KEYBOARD: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_SHOWKBD: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
VK_0: S(sw/2 - sz/4 - 5*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
VK_1: S(sw/2 - sz/4 - 4*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
VK_2: S(sw/2 - sz/4 - 3*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
function GetKeyName(key: Integer): String;
begin
case key of
- VS_KEYBOARD: result := 'KBD';
- VS_HIDEKEYBOARD: result := 'KBD';
+ VK_SHOWKBD: result := 'KBD';
+ VK_HIDEKBD: result := 'KBD';
VK_LEFT: result := 'LEFT';
VK_RIGHT: result := 'RIGHT';
VK_UP: result := 'UP';
procedure g_Touch_HandleEvent(const ev: TSDL_TouchFingerEvent);
var
x, y, i, finger: Integer;
+
+ procedure KeyUp (finger, i: Integer);
+ begin
+ keyFinger[i] := 0;
+ e_KeyUpDown(i, False);
+ g_Console_ProcessBind(i, False);
+
+ (* up/down + fire hack *)
+ if g_touch_fire and (gGameSettings.GameType <> GT_NONE) and angleFire then
+ begin
+ if (i = VK_UP) or (i = VK_DOWN) then
+ begin
+ angleFire := False;
+ keyFinger[VK_FIRE] := 0;
+ e_KeyUpDown(VK_FIRE, False);
+ g_Console_ProcessBind(VK_FIRE, False)
+ end
+ end
+ end;
+
+ procedure KeyDown (finger, i: Integer);
+ begin
+ KeyPress(i); // Menu events
+ keyFinger[i] := finger;
+ e_KeyUpDown(i, True);
+ g_Console_ProcessBind(i, True);
+
+ (* up/down + fire hack *)
+ if g_touch_fire and (gGameSettings.GameType <> GT_NONE) then
+ begin
+ if i = VK_UP then
+ begin
+ angleFire := True;
+ keyFinger[VK_FIRE] := -1;
+ e_KeyUpDown(VK_FIRE, True);
+ g_Console_ProcessBind(VK_FIRE, True)
+ end
+ else if i = VK_DOWN then
+ begin
+ angleFire := True;
+ keyFinger[VK_FIRE] := -1;
+ e_KeyUpDown(VK_FIRE, True);
+ g_Console_ProcessBind(VK_FIRE, True)
+ end
+ end
+ end;
+
+ procedure KeyMotion (finger, i: Integer);
+ begin
+ if keyFinger[i] <> finger then
+ begin
+ KeyUp(finger, i);
+ KeyDown(finger, i)
+ end
+ end;
+
begin
if not g_touch_enabled then
Exit;
if IntersectControl(i, x, y) then
begin
if ev.type_ = SDL_FINGERUP then
- keyFinger[i] := 0
+ KeyUp(finger, i)
else if ev.type_ = SDL_FINGERMOTION then
- keyFinger[i] := finger
+ KeyMotion(finger, i)
else if ev.type_ = SDL_FINGERDOWN then
- begin
- KeyPress(i); // Menu events
- keyFinger[i] := finger;
- end
+ keyDown(finger, i)
end
else if keyFinger[i] = finger then
begin
if ev.type_ = SDL_FINGERUP then
- keyFinger[i] := 0
+ KeyUp(finger, i)
else if ev.type_ = SDL_FINGERMOTION then
- keyFinger[i] := 0
- end;
-
- e_KeyUpDown(i, keyFinger[i] <> 0);
- end;
-
- if IntersectControl(VS_KEYBOARD, x, y) then
- g_Touch_ShowKeyboard(true);
- if IntersectControl(VS_HIDEKEYBOARD, x, y) then
- g_Touch_ShowKeyboard(false);
-
- (* emulate up+fire / donw+fire *)
- if g_touch_fire and (gGameSettings.GameType <> GT_NONE) then
- begin
- if keyFinger[VK_UP] <> 0 then
- begin
- angleFire := true;
- keyFinger[VK_FIRE] := keyFinger[VK_UP];
- e_KeyUpDown(VK_FIRE, true);
- end
- else if keyFinger[VK_DOWN] <> 0 then
- begin
- angleFire := true;
- keyFinger[VK_FIRE] := keyFinger[VK_DOWN];
- e_KeyUpDown(VK_FIRE, true);
+ KeyUp(finger, i)
end
- else if angleFire then
- begin
- angleFire := false;
- keyFinger[VK_FIRE] := 0;
- e_KeyUpDown(VK_FIRE, false);
- end
- end;
-
- (* left/right strafe *)
- if gGameSettings.GameType <> GT_NONE then
- begin
- if keyFinger[VK_LSTRAFE] <> 0 then
- begin
- keyFinger[VK_LEFT] := finger;
- keyFinger[VK_RIGHT] := 0;
- keyFinger[VK_STRAFE] := finger;
- e_KeyUpDown(VK_LEFT, true);
- e_KeyUpDown(VK_RIGHT, false);
- e_KeyUpDown(VK_STRAFE, true);
- end
- else if keyFinger[VK_RSTRAFE] <> 0 then
- begin
- keyFinger[VK_LEFT] := 0;
- keyFinger[VK_RIGHT] := finger;
- keyFinger[VK_STRAFE] := finger;
- e_KeyUpDown(VK_LEFT, false);
- e_KeyUpDown(VK_RIGHT, true);
- e_KeyUpDown(VK_STRAFE, true);
- end
- else
- begin
- keyFinger[VK_STRAFE] := 0;
- e_KeyUpDown(VK_STRAFE, false);
- end
-
- end;
+ end
end;
procedure g_Touch_Draw;
- var i: Integer;
+ var i, x, y, w, h: Integer; founded: Boolean;
+ begin
+{$IFNDEF HEADLESS}
+ if not g_touch_enabled then
+ Exit;
- procedure Draw (i: Integer);
- var x, y, w, h: Integer; founded: Boolean;
+ for i := VK_FIRSTKEY to VK_LASTKEY do
begin
GetKeyRect(i, x, y, w, h, founded);
if founded then
begin
e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 31);
e_TextureFontPrintEx(x, y, GetKeyName(i), gStdFont, 255, 255, 255, 1, True)
- end;
- end;
-
- begin
-{$IFNDEF HEADLESS}
- if not g_touch_enabled then
- Exit;
-
- for i := VK_FIRSTKEY to VK_LASTKEY do
- Draw(i);
-
- Draw(VS_KEYBOARD);
- Draw(VS_HIDEKEYBOARD);
+ end
+ end
{$ENDIF}
end;