From 84fa2f88d5d832ed9cc932fd2860d74467e242e1 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sun, 7 Apr 2019 01:01:08 +0300 Subject: [PATCH] added navigation in menu using joysticks --- src/engine/e_input.pas | 59 ++++++++++++++---- src/game/g_console.pas | 14 ++--- src/game/g_game.pas | 7 ++- src/game/g_gui.pas | 128 ++++++++++++++++++++++----------------- src/game/g_main.pas | 2 +- src/game/g_net.pas | 6 +- src/game/g_netmaster.pas | 28 ++++++--- 7 files changed, 159 insertions(+), 85 deletions(-) diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas index 1f1ba16..ea34841 100644 --- a/src/engine/e_input.pas +++ b/src/engine/e_input.pas @@ -37,6 +37,16 @@ const // $$$..$$$ - 4*4 Joystick hats (L U R D) // $$$..$$$ - 48 Virtual buttons/keys + KBRD_END = e_MaxKbdKeys; + JOYK_BEG = KBRD_END; + JOYK_END = JOYK_BEG + e_MaxJoyBtns*e_MaxJoys; + JOYA_BEG = JOYK_END; + 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; + // these are apparently used in g_gui and g_game and elsewhere IK_INVALID = 0; IK_ESCAPE = SDL_SCANCODE_ESCAPE; @@ -182,6 +192,44 @@ const HAT_RIGHT = 2; HAT_DOWN = 3; + JOY0_ATTACK = JOYK_BEG + 0*e_MaxJoyBtns + 0; + JOY1_ATTACK = JOYK_BEG + 1*e_MaxJoyBtns + 0; + JOY2_ATTACK = JOYK_BEG + 2*e_MaxJoyBtns + 0; + JOY3_ATTACK = JOYK_BEG + 3*e_MaxJoyBtns + 0; + JOY0_NEXT = JOYK_BEG + 0*e_MaxJoyBtns + 1; + JOY1_NEXT = JOYK_BEG + 1*e_MaxJoyBtns + 1; + JOY2_NEXT = JOYK_BEG + 2*e_MaxJoyBtns + 1; + JOY3_NEXT = JOYK_BEG + 3*e_MaxJoyBtns + 1; + JOY0_JUMP = JOYK_BEG + 0*e_MaxJoyBtns + 2; + JOY1_JUMP = JOYK_BEG + 1*e_MaxJoyBtns + 2; + JOY2_JUMP = JOYK_BEG + 2*e_MaxJoyBtns + 2; + JOY3_JUMP = JOYK_BEG + 3*e_MaxJoyBtns + 2; + JOY0_ACTIVATE = JOYK_BEG + 0*e_MaxJoyBtns + 3; + JOY1_ACTIVATE = JOYK_BEG + 1*e_MaxJoyBtns + 3; + JOY2_ACTIVATE = JOYK_BEG + 2*e_MaxJoyBtns + 3; + JOY3_ACTIVATE = JOYK_BEG + 3*e_MaxJoyBtns + 3; + JOY0_PREV = JOYK_BEG + 0*e_MaxJoyBtns + 4; + JOY1_PREV = JOYK_BEG + 1*e_MaxJoyBtns + 4; + JOY2_PREV = JOYK_BEG + 2*e_MaxJoyBtns + 4; + JOY3_PREV = JOYK_BEG + 3*e_MaxJoyBtns + 4; + + JOY0_LEFT = JOYA_BEG + 0*e_MaxJoyAxes*2 + 0*2 + AX_MINUS; + JOY1_LEFT = JOYA_BEG + 1*e_MaxJoyAxes*2 + 0*2 + AX_MINUS; + JOY2_LEFT = JOYA_BEG + 2*e_MaxJoyAxes*2 + 0*2 + AX_MINUS; + JOY3_LEFT = JOYA_BEG + 3*e_MaxJoyAxes*2 + 0*2 + AX_MINUS; + JOY0_RIGHT = JOYA_BEG + 0*e_MaxJoyAxes*2 + 0*2 + AX_PLUS; + JOY1_RIGHT = JOYA_BEG + 1*e_MaxJoyAxes*2 + 0*2 + AX_PLUS; + JOY2_RIGHT = JOYA_BEG + 2*e_MaxJoyAxes*2 + 0*2 + AX_PLUS; + JOY3_RIGHT = JOYA_BEG + 3*e_MaxJoyAxes*2 + 0*2 + AX_PLUS; + JOY0_UP = JOYA_BEG + 0*e_MaxJoyAxes*2 + 1*2 + AX_MINUS; + JOY1_UP = JOYA_BEG + 1*e_MaxJoyAxes*2 + 1*2 + AX_MINUS; + JOY2_UP = JOYA_BEG + 2*e_MaxJoyAxes*2 + 1*2 + AX_MINUS; + JOY3_UP = JOYA_BEG + 3*e_MaxJoyAxes*2 + 1*2 + AX_MINUS; + JOY0_DOWN = JOYA_BEG + 0*e_MaxJoyAxes*2 + 1*2 + AX_PLUS; + JOY1_DOWN = JOYA_BEG + 1*e_MaxJoyAxes*2 + 1*2 + AX_PLUS; + JOY2_DOWN = JOYA_BEG + 2*e_MaxJoyAxes*2 + 1*2 + AX_PLUS; + JOY3_DOWN = JOYA_BEG + 3*e_MaxJoyAxes*2 + 1*2 + AX_PLUS; + function e_InitInput: Boolean; procedure e_ReleaseInput; procedure e_UnpressAllKeys; @@ -203,17 +251,6 @@ var implementation -const - KBRD_END = e_MaxKbdKeys; - JOYK_BEG = KBRD_END; - JOYK_END = JOYK_BEG + e_MaxJoyBtns*e_MaxJoys; - JOYA_BEG = JOYK_END; - 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; - var InputBuffer: array [0..e_MaxInputKeys - 1] of Boolean; diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 2de108c..e3cc3b3 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -1264,13 +1264,13 @@ begin IK_DELETE: if (Length(Line) > 0) and (CPos <= Length(Line)) then Delete(Line, CPos, 1); - IK_LEFT, IK_KPLEFT, VK_LEFT: + IK_LEFT, IK_KPLEFT, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if CPos > 1 then CPos := CPos - 1; - IK_RIGHT, IK_KPRIGHT, VK_RIGHT: + IK_RIGHT, IK_KPRIGHT, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if CPos <= Length(Line) then CPos := CPos + 1; - IK_RETURN, IK_KPRETURN, VK_OPEN, VK_FIRE: + IK_RETURN, IK_KPRETURN, VK_OPEN, VK_FIRE, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: begin if Cons_Shown then g_Console_Process(Line) @@ -1307,7 +1307,7 @@ begin IK_TAB: if not gChatShow then Complete(); - IK_DOWN, IK_KPDOWN, VK_DOWN: + IK_DOWN, IK_KPDOWN, VK_DOWN, JOY0_DOWN, JOY1_DOWN, JOY2_DOWN, JOY3_DOWN: if not gChatShow then if (CommandHistory <> nil) and (CmdIndex < Length(CommandHistory)) then @@ -1317,7 +1317,7 @@ begin Line := CommandHistory[CmdIndex]; CPos := Length(Line) + 1; end; - IK_UP, IK_KPUP, VK_UP: + IK_UP, IK_KPUP, VK_UP, JOY0_UP, JOY1_UP, JOY2_UP, JOY3_UP: if not gChatShow then if (CommandHistory <> nil) and (CmdIndex <= Length(CommandHistory)) then @@ -1327,9 +1327,9 @@ begin Line := CommandHistory[CmdIndex]; Cpos := Length(Line) + 1; end; - IK_PAGEUP, IK_KPPAGEUP, VK_PREV: // PgUp + IK_PAGEUP, IK_KPPAGEUP, VK_PREV, JOY0_PREV, JOY1_PREV, JOY2_PREV, JOY3_PREV: // PgUp if not gChatShow then Inc(conSkipLines); - IK_PAGEDN, IK_KPPAGEDN, VK_NEXT: // PgDown + IK_PAGEDN, IK_KPPAGEDN, VK_NEXT, JOY0_NEXT, JOY1_NEXT, JOY2_NEXT, JOY3_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 6ef5895..7e1249d 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1668,7 +1668,9 @@ begin ( ( e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE) or - e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) + e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) or + e_KeyPressed(JOY0_ATTACK) or e_KeyPressed(JOY1_ATTACK) or + e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK) ) and (not gJustChatted) and (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) @@ -4640,7 +4642,8 @@ begin ProcessLoading(true); - if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then + if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) or + e_KeyPressed(JOY0_JUMP) or e_KeyPressed(JOY1_JUMP) or e_KeyPressed(JOY2_JUMP) or e_KeyPressed(JOY3_JUMP) then begin State := 0; break; diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index bc33eff..8a599fd 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -835,11 +835,15 @@ begin if @FOnKeyDownEx <> nil then FOnKeyDownEx(self, Msg.wParam); if Msg.Msg = WM_KEYDOWN then - if (Msg.wParam = IK_ESCAPE) or (Msg.wParam = VK_ESCAPE) then - begin - g_GUI_HideWindow; - Exit; - end; + begin + case Msg.wParam of + IK_ESCAPE, VK_ESCAPE, JOY0_JUMP, JOY1_JUMP, JOY2_JUMP, JOY3_JUMP: + begin + g_GUI_HideWindow; + Exit + end + end + end end; procedure TGUIWindow.SetActive(Control: TGUIControl); @@ -966,7 +970,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: Click(); + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: Click(); end; end; end; @@ -1180,7 +1184,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_UP, IK_KPUP, VK_UP: + IK_UP, IK_KPUP, VK_UP, JOY0_UP, JOY1_UP, JOY2_UP, JOY3_UP: begin repeat Dec(FIndex); @@ -1189,7 +1193,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_DOWN, IK_KPDOWN, VK_DOWN: + IK_DOWN, IK_KPDOWN, VK_DOWN, JOY0_DOWN, JOY1_DOWN, JOY2_DOWN, JOY3_DOWN: begin repeat Inc(FIndex); @@ -1198,7 +1202,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click; + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click; end; end; end; @@ -1275,7 +1279,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: if @FOnClickEvent <> nil then FOnClickEvent(); + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: if @FOnClickEvent <> nil then FOnClickEvent(); end; end; end; @@ -1527,7 +1531,7 @@ begin WM_KEYDOWN: begin case Msg.wParam of - IK_UP, IK_KPUP, VK_UP: + IK_UP, IK_KPUP, VK_UP,JOY0_UP, JOY1_UP, JOY2_UP, JOY3_UP: begin c := 0; repeat @@ -1548,7 +1552,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_DOWN, IK_KPDOWN, VK_DOWN: + IK_DOWN, IK_KPDOWN, VK_DOWN, JOY0_DOWN, JOY1_DOWN, JOY2_DOWN, JOY3_DOWN: begin c := 0; repeat @@ -1569,13 +1573,15 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT, VK_LEFT, VK_RIGHT: + IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT, VK_LEFT, VK_RIGHT, + JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT, + JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: begin if FIndex <> -1 then if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg); end; - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: begin if FIndex <> -1 then begin @@ -2104,14 +2110,14 @@ begin WM_KEYDOWN: begin case Msg.wParam of - IK_LEFT, IK_KPLEFT, VK_LEFT: + IK_LEFT, IK_KPLEFT, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if FValue > 0 then begin Dec(FValue); g_Sound_PlayEx(SCROLL_SUBSOUND); if @FOnChangeEvent <> nil then FOnChangeEvent(Self); end; - IK_RIGHT, IK_KPRIGHT, VK_RIGHT: + IK_RIGHT, IK_KPRIGHT, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if FValue < FMax then begin Inc(FValue); @@ -2188,7 +2194,9 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN, IK_RIGHT, IK_KPRETURN, IK_KPRIGHT, VK_FIRE, VK_OPEN, VK_RIGHT: + IK_RETURN, IK_RIGHT, IK_KPRETURN, IK_KPRIGHT, VK_FIRE, VK_OPEN, VK_RIGHT, + JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT, + JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: begin if FIndex < High(FItems) then Inc(FIndex) @@ -2199,7 +2207,8 @@ begin FOnChangeEvent(Self); end; - IK_LEFT, IK_KPLEFT, VK_LEFT: + IK_LEFT, IK_KPLEFT, VK_LEFT, + JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: begin if FIndex > 0 then Dec(FIndex) @@ -2306,9 +2315,9 @@ begin IK_DELETE: Delete(FText, FCaretPos + 1, 1); IK_END, IK_KPEND: FCaretPos := Length(FText); IK_HOME, IK_KPHOME: FCaretPos := 0; - 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: + IK_LEFT, IK_KPLEFT, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if FCaretPos > 0 then Dec(FCaretPos); + IK_RIGHT, IK_KPRIGHT, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if FCaretPos < Length(FText) then Inc(FCaretPos); + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: with FWindow do begin if FActiveControl <> Self then @@ -2407,12 +2416,12 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_ESCAPE, VK_ESCAPE: + IK_ESCAPE, VK_ESCAPE, JOY0_JUMP, JOY1_JUMP, JOY2_JUMP, JOY3_JUMP: begin if FIsQuery then actDefCtl(); FIsQuery := False; end; - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: begin if not FIsQuery then begin @@ -2446,12 +2455,16 @@ begin FKey := 0; actDefCtl(); end - else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) and (wParam <> VK_FIRE) and (wParam <> VK_OPEN) then // Not '' then - FKey := wParam; - FIsQuery := False; - actDefCtl(); + case wParam of + IK_ENTER, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: // Not '' then + FKey := wParam; + FIsQuery := False; + actDefCtl(); + end end; end; end; @@ -2526,12 +2539,14 @@ end; function TGUIKeyRead2.WantActivationKey (key: LongInt): Boolean; begin - result := - (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 + case key of + IK_BACKSPACE, IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT, VK_LEFT, VK_RIGHT, + JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT, + JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: + result := True + else + result := False + end end; procedure TGUIKeyRead2.OnMessage(var Msg: TMessage); @@ -2554,12 +2569,12 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_ESCAPE, VK_ESCAPE: + IK_ESCAPE, VK_ESCAPE, JOY0_JUMP, JOY1_JUMP, JOY2_JUMP, JOY3_JUMP: begin if FIsQuery then actDefCtl(); FIsQuery := False; end; - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: begin if not FIsQuery then begin @@ -2584,13 +2599,13 @@ begin actDefCtl(); end; end; - IK_LEFT, IK_KPLEFT, VK_LEFT: + IK_LEFT, IK_KPLEFT, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if not FIsQuery then begin FKeyIdx := 0; actDefCtl(); end; - IK_RIGHT, IK_KPRIGHT, VK_RIGHT: + IK_RIGHT, IK_KPRIGHT, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if not FIsQuery then begin FKeyIdx := 1; @@ -2605,14 +2620,19 @@ begin if (FKeyIdx = 0) then FKey0 := 0 else FKey1 := 0; actDefCtl(); end - else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) and (wParam <> VK_FIRE) and (wParam <> VK_OPEN) then // Not '' then - begin - if (FKeyIdx = 0) then FKey0 := wParam else FKey1 := wParam; - end; - FIsQuery := False; - actDefCtl(); + case wParam of + IK_ENTER, IK_KPRETURN, VK_FIRE, VK_OPEN, + JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: // Not '' then + begin + if (FKeyIdx = 0) then FKey0 := wParam else FKey1 := wParam; + end; + FIsQuery := False; + actDefCtl() + end end; end; end; @@ -3022,21 +3042,21 @@ begin FIndex := High(FItems); FStartLine := Max(High(FItems)-FHeight+1, 0); end; - IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_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, VK_RIGHT: + IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_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, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: with FWindow do begin if FActiveControl <> Self then SetActive(Self) @@ -3178,7 +3198,7 @@ begin FStartLine := High(FItems)-FHeight+1; end; - IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if FIndex > 0 then begin Dec(FIndex); @@ -3188,7 +3208,7 @@ begin FOnChangeEvent(Self); end; - IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT: + IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if FIndex < High(FItems) then begin Inc(FIndex); @@ -3198,7 +3218,7 @@ begin FOnChangeEvent(Self); end; - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: with FWindow do begin if FActiveControl <> Self then @@ -3379,13 +3399,13 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT, VK_UP, VK_LEFT, JOY0_LEFT, JOY1_LEFT, JOY2_LEFT, JOY3_LEFT: if FStartLine > 0 then Dec(FStartLine); - IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT: + IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT, VK_DOWN, VK_RIGHT, JOY0_RIGHT, JOY1_RIGHT, JOY2_RIGHT, JOY3_RIGHT: if FStartLine < Length(FLines)-FHeight then Inc(FStartLine); - IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN: + IK_RETURN, IK_KPRETURN, VK_FIRE, VK_OPEN, JOY0_ATTACK, JOY1_ATTACK, JOY2_ATTACK, JOY3_ATTACK: with FWindow do begin if FActiveControl <> Self then diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 7f5d5b9..5daed9b 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -502,7 +502,7 @@ begin g_Console_Switch() end; - IK_ESCAPE, VK_ESCAPE: // : + IK_ESCAPE, VK_ESCAPE, JOY0_JUMP, JOY1_JUMP, JOY2_JUMP, JOY3_JUMP: // : begin if gChatShow then begin diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 7c21ea5..76a9181 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -822,7 +822,8 @@ begin ProcessLoading(true); - if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then + if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) or + e_KeyPressed(JOY0_JUMP) or e_KeyPressed(JOY1_JUMP) or e_KeyPressed(JOY2_JUMP) or e_KeyPressed(JOY3_JUMP) then OuterLoop := False; end; @@ -985,7 +986,8 @@ begin ProcessLoading(true); - if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then + if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) or + e_KeyPressed(JOY0_JUMP) or e_KeyPressed(JOY1_JUMP) or e_KeyPressed(JOY2_JUMP) or e_KeyPressed(JOY3_JUMP) then break; end; Result := msgStream; diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 4137d8b..4ca51eb 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -707,7 +707,8 @@ begin qm := g_ProcessMessages(); // this updates kbd - if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) then + if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) or + e_KeyPressed(JOY0_JUMP) or e_KeyPressed(JOY1_JUMP) or e_KeyPressed(JOY2_JUMP) or e_KeyPressed(JOY3_JUMP) then begin SL := nil; ST := nil; @@ -719,7 +720,8 @@ begin Exit; end; - if e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_JUMP) then + if e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_JUMP) or + e_KeyPressed(JOY0_ACTIVATE) or e_KeyPressed(JOY1_ACTIVATE) or e_KeyPressed(JOY2_ACTIVATE) or e_KeyPressed(JOY3_ACTIVATE) then begin if not slFetched then begin @@ -746,7 +748,8 @@ begin if SL = nil then Exit; - if e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) then + if e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) or + e_KeyPressed(JOY0_ATTACK) or e_KeyPressed(JOY1_ATTACK) or e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK) then begin if not slReturnPressed then begin @@ -773,7 +776,8 @@ begin else slReturnPressed := False; - if e_KeyPressed(IK_DOWN) or e_KeyPressed(IK_KPDOWN) or e_KeyPressed(VK_DOWN) then + if e_KeyPressed(IK_DOWN) or e_KeyPressed(IK_KPDOWN) or e_KeyPressed(VK_DOWN) or + e_KeyPressed(JOY0_DOWN) or e_KeyPressed(JOY1_DOWN) or e_KeyPressed(JOY2_DOWN) or e_KeyPressed(JOY3_DOWN) then begin if not slDirPressed then begin @@ -783,7 +787,8 @@ begin end; end; - if e_KeyPressed(IK_UP) or e_KeyPressed(IK_KPUP) or e_KeyPressed(VK_UP) then + if e_KeyPressed(IK_UP) or e_KeyPressed(IK_KPUP) or e_KeyPressed(VK_UP) or + e_KeyPressed(JOY0_UP) or e_KeyPressed(JOY1_UP) or e_KeyPressed(JOY2_UP) or e_KeyPressed(JOY3_UP) then begin if not slDirPressed then begin @@ -794,7 +799,8 @@ begin end; end; - if e_KeyPressed(IK_RIGHT) or e_KeyPressed(IK_KPRIGHT) or e_KeyPressed(VK_RIGHT) then + if e_KeyPressed(IK_RIGHT) or e_KeyPressed(IK_KPRIGHT) or e_KeyPressed(VK_RIGHT) or + e_KeyPressed(JOY0_RIGHT) or e_KeyPressed(JOY1_RIGHT) or e_KeyPressed(JOY2_RIGHT) or e_KeyPressed(JOY3_RIGHT) then begin if not slDirPressed then begin @@ -804,7 +810,8 @@ begin end; end; - if e_KeyPressed(IK_LEFT) or e_KeyPressed(IK_KPLEFT) or e_KeyPressed(VK_LEFT) then + if e_KeyPressed(IK_LEFT) or e_KeyPressed(IK_KPLEFT) or e_KeyPressed(VK_LEFT) or + e_KeyPressed(JOY0_LEFT) or e_KeyPressed(JOY1_LEFT) or e_KeyPressed(JOY2_LEFT) or e_KeyPressed(JOY3_LEFT) then begin if not slDirPressed then begin @@ -826,7 +833,12 @@ begin (not e_KeyPressed(VK_DOWN)) and (not e_KeyPressed(VK_UP)) and (not e_KeyPressed(VK_RIGHT)) and - (not e_KeyPressed(VK_LEFT)) then + (not e_KeyPressed(VK_LEFT)) and + (not e_KeyPressed(JOY0_UP)) and (not e_KeyPressed(JOY1_UP)) and (not e_KeyPressed(JOY2_UP)) and (not e_KeyPressed(JOY3_UP)) and + (not e_KeyPressed(JOY0_DOWN)) and (not e_KeyPressed(JOY1_DOWN)) and (not e_KeyPressed(JOY2_DOWN)) and (not e_KeyPressed(JOY3_DOWN)) and + (not e_KeyPressed(JOY0_LEFT)) and (not e_KeyPressed(JOY1_LEFT)) and (not e_KeyPressed(JOY2_LEFT)) and (not e_KeyPressed(JOY3_LEFT)) and + (not e_KeyPressed(JOY0_RIGHT)) and (not e_KeyPressed(JOY1_RIGHT)) and (not e_KeyPressed(JOY2_RIGHT)) and (not e_KeyPressed(JOY3_RIGHT)) + then slDirPressed := False; end; -- 2.29.2