summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 372a9b5)
raw | patch | inline | side by side (parent: 372a9b5)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 26 Feb 2018 21:49:38 +0000 (00:49 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 17 Mar 2018 00:04:27 +0000 (02:04 +0200) |
diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas
index 0baad37ff55abaea386a336cfe7008aeed982f5c..1aae709d8706c719b0c27598e69da46a4c709d6b 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_MaxJoyKeys = e_MaxJoyBtns + e_MaxJoyAxes*2 + e_MaxJoyHats*4;
- e_MaxInputKeys = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys - 1;
+ e_MaxInputKeys = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys + e_MaxVirtKeys - 1;
// $$$..$$$ - 321 Keyboard buttons/keys
// $$$..$$$ - 4*32 Joystick buttons
// $$$..$$$ - 8*2 Joystick axes (- and +)
// $$$..$$$ - 4*4 Joystick hats (L U R D)
+ // $$$..$$$ - 32 Virtual buttons/keys
// these are apparently used in g_gui and g_game and elsewhere
IK_INVALID = 65535;
// TODO: think of something better than this shit
IK_LASTKEY = SDL_NUM_SCANCODES-1;
+ VK_FIRSTKEY = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys;
+ VK_LEFT = VK_FIRSTKEY + 0;
+ VK_RIGHT = VK_FIRSTKEY + 1;
+ VK_UP = VK_FIRSTKEY + 2;
+ VK_DOWN = VK_FIRSTKEY + 3;
+ VK_FIRE = VK_FIRSTKEY + 4;
+ VK_OPEN = VK_FIRSTKEY + 5;
+ VK_JUMP = VK_FIRSTKEY + 6;
+ VK_CHAT = VK_FIRSTKEY + 7;
+ VK_ESCAPE = VK_FIRSTKEY + 8;
+ VK_0 = VK_FIRSTKEY + 9;
+ VK_1 = VK_FIRSTKEY + 10;
+ VK_2 = VK_FIRSTKEY + 11;
+ VK_3 = VK_FIRSTKEY + 12;
+ VK_4 = VK_FIRSTKEY + 13;
+ VK_5 = VK_FIRSTKEY + 14;
+ VK_6 = VK_FIRSTKEY + 15;
+ VK_7 = VK_FIRSTKEY + 16;
+ VK_8 = VK_FIRSTKEY + 17;
+ VK_9 = VK_FIRSTKEY + 18;
+ VK_A = VK_FIRSTKEY + 19;
+ VK_B = VK_FIRSTKEY + 20;
+ VK_C = VK_FIRSTKEY + 21;
+ VK_D = VK_FIRSTKEY + 22;
+ VK_E = VK_FIRSTKEY + 23;
+ VK_F = VK_FIRSTKEY + 24;
+ VK_CONSOLE = VK_FIRSTKEY + 25;
+ VK_STATUS = VK_FIRSTKEY + 26;
+ VK_TEAM = VK_FIRSTKEY + 27;
+ VK_PREV = VK_FIRSTKEY + 28;
+ VK_NEXT = VK_FIRSTKEY + 29;
+ VK_STRAFE = VK_FIRSTKEY + 30;
+ VK_LASTKEY = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys + e_MaxVirtKeys - 1;
+
AX_MINUS = 0;
AX_PLUS = 1;
HAT_LEFT = 0;
JOYA_END = JOYA_BEG + e_MaxJoyAxes*2*e_MaxJoys;
JOYH_BEG = JOYA_END;
JOYH_END = JOYH_BEG + e_MaxJoyHats*4*e_MaxJoys;
+ VIRT_BEG = JOYH_END;
+ VIRT_END = VIRT_BEG + e_MaxVirtKeys;
type
TJoystick = record
var
KeyBuffer: array [0..e_MaxKbdKeys] of Boolean;
+ VirtBuffer: array [0..e_MaxVirtKeys] of Boolean;
Joysticks: array of TJoystick = nil;
function OpenJoysticks(): Byte;
i: Integer;
begin
for i := 0 to High(KeyBuffer) do KeyBuffer[i] := False;
+ for i := 0 to High(VirtBuffer) do VirtBuffer[i] := False;
end;
procedure e_KeyUpDown (key: Word; down: Boolean);
begin
- if (key > 0) and (key < Length(KeyBuffer)) then KeyBuffer[key] := down;
+ if (key > 0) and (key < Length(KeyBuffer)) then KeyBuffer[key] := down
+ else if (key >= VIRT_BEG) and (key < VIRT_END) then VirtBuffer[key - VIRT_BEG] := down
end;
e_KeyNames[k + i*4 + 3] := Format('JOY%d D%dD', [j, i]);
end;
end;
+
+ // vitrual keys
+ for i := 0 to e_MaxVirtKeys-1 do
+ e_KeyNames[VIRT_BEG + i] := 'VIRTUAL ' + IntToStr(i);
end;
function e_InitInput(): Boolean;
for d := Low(Joysticks[i].HatBuf[j]) to High(Joysticks[i].HatBuf[j]) do
Joysticks[i].HatBuf[j, d] := False;
end;
+ for i := Low(VirtBuffer) to High(VirtBuffer) do
+ VirtBuffer[i] := False;
end;
{
dir := Key mod 4;
Result := Joysticks[JoyI].HatBuf[Key div 4, dir];
end;
- end;
+ end
+
+ else if (Key >= VIRT_BEG) and (Key < VIRT_END) then
+ Result := VirtBuffer[Key - VIRT_BEG]
end;
procedure e_SetKeyState(key: Word; state: Integer);
dir := Key mod 4;
Joysticks[JoyI].HatBuf[Key div 4, dir] := (state <> 0);
end;
- end;
+ end
+
+ else if (Key >= VIRT_BEG) and (Key < VIRT_END) then
+ VirtBuffer[Key - VIRT_BEG] := (state <> 0)
end;
function e_AnyKeyPressed(): Boolean;
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 230e5b6e8cf4234d88c3a020fe854b79e8aaeb6d..2f3103a014017aa3e0fe150310f4624f953caf15 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
IK_DELETE:
if (Length(Line) > 0) and (CPos <= Length(Line)) then
Delete(Line, CPos, 1);
- IK_LEFT, IK_KPLEFT:
+ IK_LEFT, IK_KPLEFT, VK_LEFT:
if CPos > 1 then
CPos := CPos - 1;
- IK_RIGHT, IK_KPRIGHT:
+ IK_RIGHT, IK_KPRIGHT, VK_RIGHT:
if CPos <= Length(Line) then
CPos := CPos + 1;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_OPEN, VK_FIRE:
begin
if Cons_Shown then
g_Console_Process(Line)
IK_TAB:
if not gChatShow then
Complete();
- IK_DOWN, IK_KPDOWN:
+ IK_DOWN, IK_KPDOWN, VK_DOWN:
if not gChatShow then
if (CommandHistory <> nil) and
(CmdIndex < Length(CommandHistory)) then
Line := CommandHistory[CmdIndex];
CPos := Length(Line) + 1;
end;
- IK_UP, IK_KPUP:
+ IK_UP, IK_KPUP, VK_UP:
if not gChatShow then
if (CommandHistory <> nil) and
(CmdIndex <= Length(CommandHistory)) then
Line := CommandHistory[CmdIndex];
Cpos := Length(Line) + 1;
end;
- IK_PAGEUP, IK_KPPAGEUP: // PgUp
+ IK_PAGEUP, IK_KPPAGEUP, VK_PREV: // PgUp
if not gChatShow then Inc(conSkipLines);
- IK_PAGEDN, IK_KPPAGEDN: // PgDown
+ IK_PAGEDN, IK_KPPAGEDN, VK_NEXT: // PgDown
if not gChatShow and (conSkipLines > 0) then Dec(conSkipLines);
IK_HOME, IK_KPHOME:
CPos := 1;
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 5bceb41af2105b7821b43663e12a8930b1cbe518..80fb0531df35051f2b53f7eef73719392ca9460d 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
if (not g_Game_IsClient) and
(
(
- (e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE))
+ (
+ e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE) or
+ e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN)
+ )
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
and (g_ActiveWindow = nil)
)
g_ProcessMessages();
- if e_KeyPressed(IK_TAB) then
+ if e_KeyPressed(IK_TAB) or e_KeyPressed(VK_STATUS) then
begin
if not gStatsPressed then
begin
ProcessLoading(true);
- if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
+ if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then
begin
State := 0;
break;
diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas
index 6f4dfbe73c07022fc28be9e626340fe1b13a1348..96df55bc44e88dac950b19aee30557de087cf4dd 100644 (file)
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
if @FOnKeyDownEx <> nil then FOnKeyDownEx(self, Msg.wParam);
if Msg.Msg = WM_KEYDOWN then
- if Msg.wParam = IK_ESCAPE then
+ if (Msg.wParam = IK_ESCAPE) or (Msg.wParam = VK_ESCAPE) then
begin
g_GUI_HideWindow;
Exit;
case Msg.Msg of
WM_KEYDOWN:
case Msg.wParam of
- IK_RETURN, IK_KPRETURN: Click();
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: Click();
end;
end;
end;
case Msg.Msg of
WM_KEYDOWN:
case Msg.wParam of
- IK_UP, IK_KPUP:
+ IK_UP, IK_KPUP, VK_UP:
begin
repeat
Dec(FIndex);
g_Sound_PlayEx(MENU_CHANGESOUND);
end;
- IK_DOWN, IK_KPDOWN:
+ IK_DOWN, IK_KPDOWN, VK_DOWN:
begin
repeat
Inc(FIndex);
g_Sound_PlayEx(MENU_CHANGESOUND);
end;
- IK_RETURN, IK_KPRETURN: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click;
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click;
end;
end;
end;
case Msg.Msg of
WM_KEYDOWN:
case Msg.wParam of
- IK_RETURN, IK_KPRETURN: if @FOnClickEvent <> nil then FOnClickEvent();
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: if @FOnClickEvent <> nil then FOnClickEvent();
end;
end;
end;
WM_KEYDOWN:
begin
case Msg.wParam of
- IK_UP, IK_KPUP:
+ IK_UP, IK_KPUP, VK_UP:
begin
c := 0;
repeat
g_Sound_PlayEx(MENU_CHANGESOUND);
end;
- IK_DOWN, IK_KPDOWN:
+ IK_DOWN, IK_KPDOWN, VK_DOWN:
begin
c := 0;
repeat
g_Sound_PlayEx(MENU_CHANGESOUND);
end;
- IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT:
+ IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT, VK_LEFT, VK_RIGHT:
begin
if FIndex <> -1 then
if FItems[FIndex].Control <> nil then
FItems[FIndex].Control.OnMessage(Msg);
end;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
begin
if FIndex <> -1 then
begin
WM_KEYDOWN:
begin
case Msg.wParam of
- IK_LEFT, IK_KPLEFT:
+ IK_LEFT, IK_KPLEFT, VK_LEFT:
if FValue > 0 then
begin
Dec(FValue);
g_Sound_PlayEx(SCROLL_SUBSOUND);
if @FOnChangeEvent <> nil then FOnChangeEvent(Self);
end;
- IK_RIGHT, IK_KPRIGHT:
+ IK_RIGHT, IK_KPRIGHT, VK_RIGHT:
if FValue < FMax then
begin
Inc(FValue);
case Msg.Msg of
WM_KEYDOWN:
case Msg.wParam of
- IK_RETURN, IK_RIGHT, IK_KPRETURN, IK_KPRIGHT:
+ IK_RETURN, IK_RIGHT, IK_KPRETURN, IK_KPRIGHT, VK_FIRE, VK_OPEN, VK_RIGHT:
begin
if FIndex < High(FItems) then
Inc(FIndex)
FOnChangeEvent(Self);
end;
- IK_LEFT, IK_KPLEFT:
+ IK_LEFT, IK_KPLEFT, VK_LEFT:
begin
if FIndex > 0 then
Dec(FIndex)
IK_DELETE: Delete(FText, FCaretPos + 1, 1);
IK_END, IK_KPEND: FCaretPos := Length(FText);
IK_HOME, IK_KPHOME: FCaretPos := 0;
- IK_LEFT, IK_KPLEFT: if FCaretPos > 0 then Dec(FCaretPos);
- IK_RIGHT, IK_KPRIGHT: if FCaretPos < Length(FText) then Inc(FCaretPos);
- IK_RETURN, IK_KPRETURN:
+ IK_LEFT, IK_KPLEFT, VK_LEFT: if FCaretPos > 0 then Dec(FCaretPos);
+ IK_RIGHT, IK_KPRIGHT, VK_RIGHT: if FCaretPos < Length(FText) then Inc(FCaretPos);
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
with FWindow do
begin
if FActiveControl <> Self then
case Msg of
WM_KEYDOWN:
case wParam of
- IK_ESCAPE:
+ IK_ESCAPE, VK_ESCAPE:
begin
if FIsQuery then actDefCtl();
FIsQuery := False;
end;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
begin
if not FIsQuery then
begin
FKey := 0;
actDefCtl();
end
- else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) then // Not <Enter
+ else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) and (wParam <> VK_FIRE) and (wParam <> VK_OPEN) then // Not <Enter
begin
if e_KeyNames[wParam] <> '' then
FKey := wParam;
(key = IK_BACKSPACE) or
(key = IK_LEFT) or (key = IK_RIGHT) or
(key = IK_KPLEFT) or (key = IK_KPRIGHT) or
+ (key = VK_LEFT) or (key = VK_RIGHT) or
false; // oops
end;
case Msg of
WM_KEYDOWN:
case wParam of
- IK_ESCAPE:
+ IK_ESCAPE, VK_ESCAPE:
begin
if FIsQuery then actDefCtl();
FIsQuery := False;
end;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
begin
if not FIsQuery then
begin
actDefCtl();
end;
end;
- IK_LEFT, IK_KPLEFT:
+ IK_LEFT, IK_KPLEFT, VK_LEFT:
if not FIsQuery then
begin
FKeyIdx := 0;
actDefCtl();
end;
- IK_RIGHT, IK_KPRIGHT:
+ IK_RIGHT, IK_KPRIGHT, VK_RIGHT:
if not FIsQuery then
begin
FKeyIdx := 1;
if (FKeyIdx = 0) then FKey0 := 0 else FKey1 := 0;
actDefCtl();
end
- else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) then // Not <Enter
+ else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) and (wParam <> VK_FIRE) and (wParam <> VK_OPEN) then // Not <Enter
begin
if e_KeyNames[wParam] <> '' then
begin
FIndex := High(FItems);
FStartLine := Max(High(FItems)-FHeight+1, 0);
end;
- IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT:
+ IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_LEFT:
if FIndex > 0 then
begin
Dec(FIndex);
if FIndex < FStartLine then Dec(FStartLine);
if @FOnChangeEvent <> nil then FOnChangeEvent(Self);
end;
- IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT:
+ IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_RIGHT:
if FIndex < High(FItems) then
begin
Inc(FIndex);
if FIndex > FStartLine+FHeight-1 then Inc(FStartLine);
if @FOnChangeEvent <> nil then FOnChangeEvent(Self);
end;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
with FWindow do
begin
if FActiveControl <> Self then SetActive(Self)
FStartLine := High(FItems)-FHeight+1;
end;
- IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT:
+ IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT:
if FIndex > 0 then
begin
Dec(FIndex);
FOnChangeEvent(Self);
end;
- IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT:
+ IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT:
if FIndex < High(FItems) then
begin
Inc(FIndex);
FOnChangeEvent(Self);
end;
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
with FWindow do
begin
if FActiveControl <> Self then
case Msg of
WM_KEYDOWN:
case wParam of
- IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT:
+ IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT:
if FStartLine > 0 then
Dec(FStartLine);
- IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT:
+ IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT:
if FStartLine < Length(FLines)-FHeight then
Inc(FStartLine);
- IK_RETURN, IK_KPRETURN:
+ IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN:
with FWindow do
begin
if FActiveControl <> Self then
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 93655f66f8a7fe939e1338b31b9d517b2ca632da..07d2f48007b52a75ccd1c7b3befae8dac45b1708 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
if (g_ActiveWindow = nil) then g_Game_Pause(not gPause);
end;
- IK_BACKQUOTE: // <`/~/¨/¸>:
+ IK_BACKQUOTE, VK_CONSOLE: // <`/~/¨/¸>:
begin
g_Console_Switch();
end;
- IK_ESCAPE: // <Esc>:
+ IK_ESCAPE, VK_ESCAPE: // <Esc>:
begin
if gChatShow then
begin
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index 04382d340c0484ad0c5f2aed00cd78055b50e04c..b9f28b981c9bccac022b724867106534932cc390 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
ProcessLoading(true);
- if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
+ if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then
OuterLoop := False;
end;
ProcessLoading(true);
- if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
+ if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then
break;
end;
Result := msgStream;
index 05d79edd2647194b5ed45698221741b3bdc8feef..f4ce7984547a0362e13b66e2d6a2885a67b1ce1d 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
qm := g_ProcessMessages(); // this updates kbd
- if qm or e_KeyPressed(IK_ESCAPE) then
+ if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) then
begin
SL := nil;
gState := STATE_MENU;
Exit;
end;
- if e_KeyPressed(IK_SPACE) then
+ if e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_JUMP) then
begin
if not slFetched then
begin
if SL = nil then Exit;
- if e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) then
+ if e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) then
begin
if not slReturnPressed then
begin
else
slReturnPressed := False;
- if e_KeyPressed(IK_DOWN) or e_KeyPressed(IK_KPDOWN) then
+ if e_KeyPressed(IK_DOWN) or e_KeyPressed(IK_KPDOWN) or e_KeyPressed(VK_DOWN) then
begin
if not slDirPressed then
begin
end;
end;
- if e_KeyPressed(IK_UP) or e_KeyPressed(IK_KPUP) then
+ if e_KeyPressed(IK_UP) or e_KeyPressed(IK_KPUP) or e_KeyPressed(VK_UP) then
begin
if not slDirPressed then
begin
end;
end;
- if (not e_KeyPressed(IK_DOWN)) and (not e_KeyPressed(IK_UP)) and (not e_KeyPressed(IK_KPDOWN)) and (not e_KeyPressed(IK_KPUP)) then
+ if (not e_KeyPressed(IK_DOWN)) and (not e_KeyPressed(IK_UP)) and (not e_KeyPressed(IK_KPDOWN)) and (not e_KeyPressed(IK_KPUP)) and (not e_KeyPressed(VK_DOWN)) and (not e_KeyPressed(VK_UP)) then
slDirPressed := False;
end;
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index ee8518a7c8983419dc22c3972284353901e3a2f0..b3b2f5a3234ca3fdf5bb5b518cf3b97a1dfe7345 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
for i := 10 to High(KeyWeapon) do
KeyWeapon[i] := 0;
- KeyRight2 := 0;
- KeyLeft2 := 0;
- KeyUp2 := 0;
- KeyDown2 := 0;
- KeyFire2 := 0;
- KeyJump2 := 0;
- KeyNextWeapon2 := 0;
- KeyPrevWeapon2 := 0;
- KeyOpen2 := 0;
- KeyStrafe2 := 0;
+ KeyRight2 := VK_RIGHT;
+ KeyLeft2 := VK_LEFT;
+ KeyUp2 := VK_UP;
+ KeyDown2 := VK_DOWN;
+ KeyFire2 := VK_FIRE;
+ KeyJump2 := VK_JUMP;
+ KeyNextWeapon2 := VK_NEXT;
+ KeyPrevWeapon2 := VK_PREV;
+ KeyOpen2 := VK_OPEN;
+ KeyStrafe2 := VK_STRAFE;
for i := 0 to High(KeyWeapon2) do
- KeyWeapon2[i] := 0;
+ KeyWeapon2[i] := VK_0 + i;
end;
with gGameControls.P2Control do
diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas
index 0a02e577bf040487632ffbcbf09fd1e52540b38f..20aacd4bafa2fca0fd16b7ede30796302a953467 100644 (file)
--- a/src/game/g_touch.pas
+++ b/src/game/g_touch.pas
SysUtils,
e_log, e_graphics, e_input, g_options, g_game, g_main, g_weapons, g_console;
- const
- CTL_NONE = 0;
- CTL_LEFT = 1;
- CTL_RIGHT = 2;
- CTL_UP = 3;
- CTL_DOWN = 4;
- CTL_FIRE = 5;
- CTL_OPEN = 6;
- CTL_JUMP = 7;
- CTL_CHAT = 8;
- CTL_ESC = 9;
- CTL_W0 = 10;
- CTL_W1 = 11;
- CTL_W2 = 12;
- CTL_W3 = 13;
- CTL_W4 = 14;
- CTL_W5 = 15;
- CTL_W6 = 16;
- CTL_W7 = 17;
- CTL_W8 = 18;
- CTL_W9 = 19;
- CTL_W10 = 20;
- CTL_CON = 21;
- CTL_STAT = 22;
- CTL_TCHAT = 23;
- CTL_LAST = 23;
-
var
+ jab: Boolean;
size: Single;
enabled: Boolean;
- keyFinger: array [1..CTL_LAST] of Integer;
+ keyFinger: array [VK_FIRSTKEY..VK_LASTKEY] of Integer;
- procedure GetControlRect(control: Integer; out x, y, w, h: Integer; out founded: Boolean);
+ procedure GetKeyRect(key: Word; out x, y, w, h: Integer; out founded: Boolean);
var
sw, sh, sz: Integer;
dpi: Single;
founded := true;
sz := Trunc(size * dpi);
- x := 0; y := 0; w := sz; h := sz;
sw := gScreenWidth; sh := gScreenHeight;
- case control of
- CTL_LEFT: begin x := 0; y := sh div 2 - h div 2; end;
- CTL_RIGHT: begin x := w; y := sh div 2 - h div 2; end;
- CTL_UP: begin x := sw - w - 1; y := sh div 2 - h div 2 - h; end;
- CTL_DOWN: begin x := sw - w - 1; y := sh div 2 - h div 2 + h; end;
- CTL_FIRE: begin x := sw - 1*w - 1; y := sh div 2 - h div 2; end;
- CTL_OPEN: begin x := sw - 3*w - 1; y := sh div 2 - h div 2; end;
- CTL_JUMP: begin x := sw - 2*w - 1; y := sh div 2 - h div 2; end;
- else
- w := sz div 2; h := sz div 2;
- case control of
- CTL_W0: begin x := sw div 2 - w div 2 - 5*w - 1; y := sh - 1*h - 1; end;
- CTL_W1: begin x := sw div 2 - w div 2 - 4*w - 1; y := sh - 1*h - 1; end;
- CTL_W2: begin x := sw div 2 - w div 2 - 3*w - 1; y := sh - 1*h - 1; end;
- CTL_W3: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 1*h - 1; end;
- CTL_W4: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 1*h - 1; end;
- CTL_W5: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 1*h - 1; end;
- CTL_W6: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 1*h - 1; end;
- CTL_W7: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 1*h - 1; end;
- CTL_W8: begin x := sw div 2 - w div 2 + 3*w - 1; y := sh - 1*h - 1; end;
- CTL_W9: begin x := sw div 2 - w div 2 + 4*w - 1; y := sh - 1*h - 1; end;
- CTL_W10: begin x := sw div 2 - w div 2 + 5*w - 1; y := sh - 1*h - 1; end;
- CTL_CHAT: begin x := sw div 2 - w div 2 - 2*w - 1; y := sh - 2*h - 1; end;
- CTL_ESC: begin x := sw div 2 - w div 2 - 1*w - 1; y := sh - 2*h - 1; end;
- CTL_CON: begin x := sw div 2 - w div 2 + 0*w - 1; y := sh - 2*h - 1; end;
- CTL_STAT: begin x := sw div 2 - w div 2 + 1*w - 1; y := sh - 2*h - 1; end;
- CTL_TCHAT: begin x := sw div 2 - w div 2 + 2*w - 1; y := sh - 2*h - 1; end;
+ if jab then
+ begin
+ w := sz div 2; h := sz div 3;
+ case key of
+ VK_CONSOLE: begin x := 0; y := 0 end;
+ VK_ESCAPE: begin x := sw - w - 1; y := 0 end;
+ VK_CHAT: begin x := sw div 2 - w - 4; y := 0 end;
+ VK_TEAM: begin x := sw div 2 + 0 + 4; y := 0 end;
else
- founded := false
+ w := sz; h := sz * 2;
+ case key of
+ VK_LEFT: begin x := 0; y := sh - h - 1 end;
+ VK_RIGHT: begin x := w; y := sh - h - 1 end;
+ else
+ w := sz; h := sz;
+ case key of
+ VK_OPEN: begin h := sz; x := sw - 1*w - 1; y := sh - 1*h - 1 end;
+ VK_JUMP: begin h := sz; x := sw - 1*w - 1; y := sh - 2*h - 1 end;
+ VK_UP: begin h := sz div 2; x := sw - 2*w - 1; y := sh - 2*sz - 1 end;
+ VK_FIRE: begin h := sz; x := sw - 2*w - 1; y := sh - sz div 2 - sz - 1 end;
+ VK_DOWN: begin h := sz div 2; x := sw - 2*w - 1; y := sh - sz div 2 - 1 end;
+ VK_PREV: begin h := sz div 2; x := 0; y := sh - 3*sz - 1 end;
+ VK_NEXT: begin h := sz div 2; x := sw - w - 1; y := sh - 3*sz - 1 end;
+ else
+ founded := false
+ end
+ end
end
end
- end;
-
- function GetMenuKey(control: Integer): Word;
- begin
- case control of
- CTL_LEFT: result := IK_LEFT;
- CTL_RIGHT: result := IK_RIGHT;
- CTL_UP: result := IK_UP;
- CTL_DOWN: result := IK_DOWN;
- CTL_OPEN: result := IK_ENTER;
- CTL_FIRE: result := IK_ENTER;
- CTL_JUMP: result := IK_SPACE;
- CTL_ESC: result := IK_ESCAPE;
- CTL_W0: result := SDL_SCANCODE_0;
- CTL_W1: result := SDL_SCANCODE_1;
- CTL_W2: result := SDL_SCANCODE_2;
- CTL_W3: result := SDL_SCANCODE_3;
- CTL_W4: result := SDL_SCANCODE_4;
- CTL_W5: result := SDL_SCANCODE_5;
- CTL_W6: result := SDL_SCANCODE_6;
- CTL_W7: result := SDL_SCANCODE_7;
- CTL_W8: result := SDL_SCANCODE_8;
- CTL_W9: result := SDL_SCANCODE_9;
- CTL_CON: result := IK_GRAVE;
- else
- result := IK_INVALID;
- end
- end;
-
- function GetPlayerKey(control: Integer): Word;
- begin
- case control of
- CTL_LEFT: result := gGameControls.P1Control.KeyLeft;
- CTL_RIGHT: result := gGameControls.P1Control.KeyRight;
- CTL_UP: result := gGameControls.P1Control.KeyUp;
- CTL_DOWN: result := gGameControls.P1Control.KeyDown;
- CTL_OPEN: result := gGameControls.P1Control.KeyOpen;
- CTL_FIRE: result := gGameControls.P1Control.KeyFire;
- CTL_JUMP: result := gGameControls.P1Control.KeyJump;
- CTL_CHAT: result := gGameControls.GameControls.Chat;
- CTL_ESC: result := IK_ESCAPE;
- CTL_W0: result := gGameControls.P1Control.KeyWeapon[WEAPON_KASTET];
- CTL_W1: result := gGameControls.P1Control.KeyWeapon[WEAPON_SAW];
- CTL_W2: result := gGameControls.P1Control.KeyWeapon[WEAPON_PISTOL];
- CTL_W3: result := gGameControls.P1Control.KeyWeapon[WEAPON_SHOTGUN1];
- CTL_W4: result := gGameControls.P1Control.KeyWeapon[WEAPON_SHOTGUN2];
- CTL_W5: result := gGameControls.P1Control.KeyWeapon[WEAPON_CHAINGUN];
- CTL_W6: result := gGameControls.P1Control.KeyWeapon[WEAPON_ROCKETLAUNCHER];
- CTL_W7: result := gGameControls.P1Control.KeyWeapon[WEAPON_PLASMA];
- CTL_W8: result := gGameControls.P1Control.KeyWeapon[WEAPON_BFG];
- CTL_W9: result := gGameControls.P1Control.KeyWeapon[WEAPON_SUPERPULEMET];
- CTL_W10: result := gGameControls.P1Control.KeyWeapon[WEAPON_FLAMETHROWER];
- CTL_CON: result := IK_GRAVE;
- CTL_STAT: result := gGameControls.GameControls.Stat;
- CTL_TCHAT: result := gGameControls.GameControls.TeamChat;
else
- result := IK_INVALID
+ 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;
+ 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;
+ else
+ founded := false
+ end
+ end
end
end;
- function GetControlName(control: Integer): String;
+ function GetKeyName(key: Word): String;
begin
- case control of
- CTL_LEFT: result := 'LEFT';
- CTL_RIGHT: result := 'RIGHT';
- CTL_UP: result := 'UP';
- CTL_DOWN: result := 'DOWN';
- CTL_OPEN: result := 'OPEN';
- CTL_FIRE: result := 'FIRE';
- CTL_JUMP: result := 'JUMP';
- CTL_CHAT: result := 'CHAT';
- CTL_ESC: result := 'ESC';
- CTL_W0: result := '0';
- CTL_W1: result := '1';
- CTL_W2: result := '2';
- CTL_W3: result := '3';
- CTL_W4: result := '4';
- CTL_W5: result := '5';
- CTL_W6: result := '6';
- CTL_W7: result := '7';
- CTL_W8: result := '8';
- CTL_W9: result := '9';
- CTL_W10: result := '10';
- CTL_CON: result := 'CON';
- CTL_STAT: result := 'STAT';
- CTL_TCHAT: result := 'TEAM';
+ case key of
+ VK_LEFT: result := 'LEFT';
+ VK_RIGHT: result := 'RIGHT';
+ VK_UP: result := 'UP';
+ VK_DOWN: result := 'DOWN';
+ VK_FIRE: result := 'FIRE';
+ VK_OPEN: result := 'OPEN';
+ VK_JUMP: result := 'JUMP';
+ VK_CHAT: result := 'CHAT';
+ VK_ESCAPE: result := 'ESC';
+ VK_0: result := '0';
+ VK_1: result := '1';
+ VK_2: result := '2';
+ VK_3: result := '3';
+ VK_4: result := '4';
+ VK_5: result := '5';
+ VK_6: result := '6';
+ VK_7: result := '7';
+ VK_8: result := '8';
+ VK_9: result := '9';
+ VK_A: result := '10';
+ VK_B: result := '11';
+ VK_C: result := '12';
+ VK_D: result := '13';
+ VK_E: result := '14';
+ VK_F: result := '15';
+ VK_CONSOLE: result := 'CON';
+ VK_STATUS: result := 'STAT';
+ VK_TEAM: result := 'TEAM';
+ VK_PREV: result := '<PREV';
+ VK_NEXT: result := 'NEXT>';
else
- result := '(WAT?)'
+ if (key > 0) and (key < e_MaxInputKeys) then
+ result := e_KeyNames[key]
+ else
+ result := '<' + IntToStr(key) + '>'
end
end;
procedure DrawRect(x, y, w, h: Integer);
begin
- e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 127);
+ e_DrawQuad(x, y, x + w, y + h, 0, 255, 0, 63);
end;
function IntersectControl(ctl, xx, yy: Integer): Boolean;
x, y, w, h: Integer;
founded: Boolean;
begin
- GetControlRect(ctl, x, y, w, h, founded);
+ GetKeyRect(ctl, x, y, w, h, founded);
result := founded and (xx >= x) and (yy >= y) and (xx <= x + w) and (yy <= y + h);
end;
x := Trunc(ev.x * gScreenWidth);
y := Trunc(ev.y * gScreenHeight);
- for i := 1 to CTL_LAST do
+ for i := VK_FIRSTKEY to VK_LASTKEY do
begin
if IntersectControl(i, x, y) then
begin
keyFinger[i] := finger
else if ev.type_ = SDL_FINGERDOWN then
begin
- KeyPress(GetMenuKey(i));
+ KeyPress(i); // Menu events
keyFinger[i] := finger;
end
end
keyFinger[i] := 0
end;
- e_KeyUpDown(GetPlayerKey(i), keyFinger[i] <> 0);
- e_KeyUpDown(GetMenuKey(i), keyFinger[i] <> 0);
+ e_KeyUpDown(i, keyFinger[i] <> 0);
end;
end;
if SDL_IsTextInputActive() = SDL_True then
Exit;
- for i := 1 to CTL_LAST do
+ for i := VK_FIRSTKEY to VK_LASTKEY do
begin
- GetControlRect(i, x, y, w, h, founded);
+ GetKeyRect(i, x, y, w, h, founded);
if founded then
begin
DrawRect(x, y, w, h);
- e_TextureFontPrint(x, y, GetControlName(i), gStdFont)
+ e_TextureFontPrint(x, y, GetKeyName(i), gStdFont)
end;
end;
{$ENDIF}
size := 1;
conRegVar('touch_enable', @enabled, 'enable/disable virtual buttons', 'draw buttons');
conRegVar('touch_size', @size, 0.1, 10, 'size of virtual buttons', 'button size');
+ conRegVar('touch_alt', @jab, 'althernative virtual buttons layout', 'althernative layout');
end.