summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3424d00)
raw | patch | inline | side by side (parent: 3424d00)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 1 Mar 2018 16:08:29 +0000 (19:08 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 17 Mar 2018 00:04:27 +0000 (02:04 +0200) |
src/engine/e_input.pas | patch | blob | history | |
src/game/g_game.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 1aae709d8706c719b0c27598e69da46a4c709d6b..1c27249fc44465151cf00dc129c9bf85fa6a5f51 100644 (file)
--- a/src/engine/e_input.pas
+++ b/src/engine/e_input.pas
e_MaxJoyBtns = 32;
e_MaxJoyAxes = 8;
e_MaxJoyHats = 8;
- e_MaxVirtKeys = 32;
+ e_MaxVirtKeys = 48;
e_MaxJoyKeys = e_MaxJoyBtns + e_MaxJoyAxes*2 + e_MaxJoyHats*4;
// $$$..$$$ - 4*32 Joystick buttons
// $$$..$$$ - 8*2 Joystick axes (- and +)
// $$$..$$$ - 4*4 Joystick hats (L U R D)
- // $$$..$$$ - 32 Virtual buttons/keys
+ // $$$..$$$ - 48 Virtual buttons/keys
// these are apparently used in g_gui and g_game and elsewhere
IK_INVALID = 65535;
VK_PREV = VK_FIRSTKEY + 28;
VK_NEXT = VK_FIRSTKEY + 29;
VK_STRAFE = VK_FIRSTKEY + 30;
+ VK_LSTRAFE = VK_FIRSTKEY + 31;
+ VK_RSTRAFE = VK_FIRSTKEY + 32;
+ VK_PRINTSCR = VK_FIRSTKEY + 33;
VK_LASTKEY = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys + e_MaxVirtKeys - 1;
AX_MINUS = 0;
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 80fb0531df35051f2b53f7eef73719392ca9460d..1923452907701501d2b724eddef191b6aeb3028e 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
begin
if g_ActiveWindow = nil then
begin
- if e_KeyPressed(gGameControls.GameControls.Chat) then
+ if e_KeyPressed(gGameControls.GameControls.Chat) or e_KeyPressed(VK_CHAT) then
g_Console_Chat_Switch(False)
- else if (e_KeyPressed(gGameControls.GameControls.TeamChat)) and
+ else if (e_KeyPressed(gGameControls.GameControls.TeamChat) or e_KeyPressed(VK_TEAM)) and
(gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
g_Console_Chat_Switch(True);
end;
end else
if not gChatEnter then
if (not e_KeyPressed(gGameControls.GameControls.Chat))
- and (not e_KeyPressed(gGameControls.GameControls.TeamChat)) then
+ and (not e_KeyPressed(gGameControls.GameControls.TeamChat))
+ and (not e_KeyPressed(VK_CHAT))
+ and (not e_KeyPressed(VK_TEAM)) then
gChatEnter := True;
// Ñòàòèñòèêà ïî Tab:
if gGameOn then
IsDrawStat := (not gConsoleShow) and (not gChatShow) and
(gGameSettings.GameType <> GT_SINGLE) and
- e_KeyPressed(gGameControls.GameControls.Stat);
+ (e_KeyPressed(gGameControls.GameControls.Stat) or e_KeyPressed(VK_STATUS));
// Èãðà èäåò:
if gGameOn and not gPause and (gState <> STATE_FOLD) then
end;
// Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
- if e_KeyPressed(gGameControls.GameControls.TakeScreenshot) then
+ if e_KeyPressed(gGameControls.GameControls.TakeScreenshot) or e_KeyPressed(VK_PRINTSCR) then
if (GetTimer()-LastScreenShot) > 200000 div 1000 then
begin
g_TakeScreenShot();
diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas
index 20aacd4bafa2fca0fd16b7ede30796302a953467..52167bd57b0b8f099ef43732fc0a0f9171071a33 100644 (file)
--- a/src/game/g_touch.pas
+++ b/src/game/g_touch.pas
jab: Boolean;
size: Single;
enabled: Boolean;
+ angleFireEnabled, angleFire: Boolean;
keyFinger: array [VK_FIRSTKEY..VK_LASTKEY] of Integer;
procedure GetKeyRect(key: Word; out x, y, w, h: Integer; out founded: Boolean);
- var
- sw, sh, sz: Integer;
- dpi: Single;
+ var
+ sw, sh, sz: Integer;
+ dpi: Single;
begin
if SDL_GetDisplayDPI(0, @dpi, nil, nil) <> 0 then
dpi := 96;
begin
x := 0; y := 0; w := sz; h := sz;
case key of
- VK_LEFT: begin x := 0; y := sh div 2 - h div 2; end;
- VK_RIGHT: begin x := w; y := sh div 2 - h div 2; end;
- VK_UP: begin x := sw - w - 1; y := sh div 2 - h div 2 - h; end;
- VK_DOWN: begin x := sw - w - 1; y := sh div 2 - h div 2 + h; end;
- VK_FIRE: begin x := sw - 1*w - 1; y := sh div 2 - h div 2; end;
- VK_OPEN: begin x := sw - 3*w - 1; y := sh div 2 - h div 2; end;
- VK_JUMP: begin x := sw - 2*w - 1; y := sh div 2 - h div 2; end;
+ VK_LSTRAFE: begin x := 0; y := sh div 2 - h div 2; w := w div 2 end;
+ VK_LEFT: begin x := w div 2; y := sh div 2 - h div 2 end;
+ VK_RIGHT: begin x := w div 2 + 1*w;y := sh div 2 - h div 2 end;
+ VK_RSTRAFE: begin x := w div 2 + 2*w;y := sh div 2 - h div 2; w := w div 2 end;
+ VK_UP: begin x := sw - w - 1; y := sh div 2 - h div 2 - h end;
+ VK_FIRE: begin x := sw - 1*w - 1; y := sh div 2 - h div 2 end;
+ VK_DOWN: begin x := sw - w - 1; y := sh div 2 - h div 2 + h end;
+ VK_NEXT: begin x := sw - 2*w - 1; y := sh div 2 - h div 2 - h end;
+ VK_JUMP: begin x := sw - 2*w - 1; y := sh div 2 - h div 2 end;
+ VK_PREV: begin x := sw - 3*w - 1; y := sh div 2 - h div 2 - h end;
+ VK_OPEN: begin x := sw - 3*w - 1; y := sh div 2 - h div 2 end;
else
w := sz div 2; h := sz div 2;
case key of
- VK_0: begin x := sw div 2 - w div 2 - 5*w - 1; y := sh - 1*h - 1; end;
- VK_1: begin x := sw div 2 - w div 2 - 4*w - 1; y := sh - 1*h - 1; end;
- VK_2: begin x := sw div 2 - w div 2 - 3*w - 1; y := sh - 1*h - 1; end;
- VK_3: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 1*h - 1; end;
- VK_4: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 1*h - 1; end;
- VK_5: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 1*h - 1; end;
- VK_6: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 1*h - 1; end;
- VK_7: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 1*h - 1; end;
- VK_8: begin x := sw div 2 - w div 2 + 3*w - 1; y := sh - 1*h - 1; end;
- VK_9: begin x := sw div 2 - w div 2 + 4*w - 1; y := sh - 1*h - 1; end;
- VK_A: begin x := sw div 2 - w div 2 + 5*w - 1; y := sh - 1*h - 1; end;
- VK_CHAT: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 2*h - 1; end;
- VK_ESCAPE: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 2*h - 1; end;
- VK_CONSOLE: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 2*h - 1; end;
- VK_STATUS: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 2*h - 1; end;
- VK_TEAM: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 2*h - 1; end;
+ VK_0: begin x := sw div 2 - w div 2 - 5*w - 1; y := sh - 1*h - 1 end;
+ VK_1: begin x := sw div 2 - w div 2 - 4*w - 1; y := sh - 1*h - 1 end;
+ VK_2: begin x := sw div 2 - w div 2 - 3*w - 1; y := sh - 1*h - 1 end;
+ VK_3: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 1*h - 1 end;
+ VK_4: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 1*h - 1 end;
+ VK_5: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 1*h - 1 end;
+ VK_6: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 1*h - 1 end;
+ VK_7: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 1*h - 1 end;
+ VK_8: begin x := sw div 2 - w div 2 + 3*w - 1; y := sh - 1*h - 1 end;
+ VK_9: begin x := sw div 2 - w div 2 + 4*w - 1; y := sh - 1*h - 1 end;
+ VK_A: begin x := sw div 2 - w div 2 + 5*w - 1; y := sh - 1*h - 1 end;
+ VK_CHAT: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 2*h - 1 end;
+ VK_ESCAPE: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 2*h - 1 end;
+ VK_CONSOLE: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 2*h - 1 end;
+ VK_STATUS: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 2*h - 1 end;
+ VK_TEAM: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 2*h - 1 end;
else
founded := false
end
VK_CONSOLE: result := 'CON';
VK_STATUS: result := 'STAT';
VK_TEAM: result := 'TEAM';
- VK_PREV: result := '<PREV';
+ VK_PREV: result := '<PREW';
VK_NEXT: result := 'NEXT>';
+ VK_LSTRAFE: result := '<';
+ VK_RSTRAFE: result := '>';
else
if (key > 0) and (key < e_MaxInputKeys) then
result := e_KeyNames[key]
procedure DrawRect(x, y, w, h: Integer);
begin
- e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 63);
+ e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 31);
end;
function IntersectControl(ctl, xx, yy: Integer): Boolean;
e_KeyUpDown(i, keyFinger[i] <> 0);
end;
+
+ (* emulate up+fire / donw+fire *)
+ if angleFireEnabled 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);
+ 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;
procedure g_Touch_Draw;
enabled := true;
{$ENDIF}
size := 1;
+ angleFire := true;
conRegVar('touch_enable', @enabled, 'enable/disable virtual buttons', 'draw buttons');
+ conRegVar('touch_anglefire', @angleFireEnabled, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
conRegVar('touch_size', @size, 0.1, 10, 'size of virtual buttons', 'button size');
conRegVar('touch_alt', @jab, 'althernative virtual buttons layout', 'althernative layout');
end.