From: Ketmar Dark Date: Wed, 6 Apr 2016 21:06:33 +0000 (+0300) Subject: keypad now works in menus X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=e06da872a0a072eea1117350ed6c14a709328807;p=d2df-sdl.git keypad now works in menus --- diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas index 618199d..b16508f 100644 --- a/src/engine/e_input.pas +++ b/src/engine/e_input.pas @@ -26,20 +26,28 @@ const IK_INVALID = 65535; IK_ESCAPE = SDL_SCANCODE_ESCAPE; IK_RETURN = SDL_SCANCODE_RETURN; + IK_KPRETURN= SDL_SCANCODE_KP_ENTER; IK_ENTER = SDL_SCANCODE_RETURN; IK_UP = SDL_SCANCODE_UP; + IK_KPUP = SDL_SCANCODE_KP_8; IK_DOWN = SDL_SCANCODE_DOWN; + IK_KPDOWN = SDL_SCANCODE_KP_2; IK_LEFT = SDL_SCANCODE_LEFT; + IK_KPLEFT = SDL_SCANCODE_KP_4; IK_RIGHT = SDL_SCANCODE_RIGHT; + IK_KPRIGHT = SDL_SCANCODE_KP_6; IK_DELETE = SDL_SCANCODE_DELETE; IK_HOME = SDL_SCANCODE_HOME; + IK_KPHOME = SDL_SCANCODE_KP_7; IK_INSERT = SDL_SCANCODE_INSERT; IK_SPACE = SDL_SCANCODE_SPACE; IK_CONTROL = SDL_SCANCODE_LCTRL; IK_SHIFT = SDL_SCANCODE_LSHIFT; IK_TAB = SDL_SCANCODE_TAB; IK_PAGEUP = SDL_SCANCODE_PAGEUP; + IK_KPPAGEUP= SDL_SCANCODE_KP_9; IK_PAGEDN = SDL_SCANCODE_PAGEDOWN; + IK_KPPAGEDN= SDL_SCANCODE_KP_3; IK_F2 = SDL_SCANCODE_F2; IK_F3 = SDL_SCANCODE_F3; IK_F4 = SDL_SCANCODE_F4; @@ -50,6 +58,7 @@ const IK_F9 = SDL_SCANCODE_F9; IK_F10 = SDL_SCANCODE_F10; IK_END = SDL_SCANCODE_END; + IK_KPEND = SDL_SCANCODE_KP_1; IK_BACKSPACE = SDL_SCANCODE_BACKSPACE; IK_BACKQUOTE = SDL_SCANCODE_GRAVE; IK_GRAVE = SDL_SCANCODE_GRAVE; diff --git a/src/game/g_console.pas b/src/game/g_console.pas index fc78ef0..4898bfb 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -666,13 +666,13 @@ begin IK_DELETE: if (Length(Line) > 0) and (CPos <= Length(Line)) then Delete(Line, CPos, 1); - IK_LEFT: + IK_LEFT, IK_KPLEFT: if CPos > 1 then CPos := CPos - 1; - IK_RIGHT: + IK_RIGHT, IK_KPRIGHT: if CPos <= Length(Line) then CPos := CPos + 1; - IK_RETURN: + IK_RETURN, IK_KPRETURN: begin if Cons_Shown then g_Console_Process(Line) @@ -708,7 +708,7 @@ begin IK_TAB: if not gChatShow then Complete(); - IK_DOWN: + IK_DOWN, IK_KPDOWN: if not gChatShow then if (CommandHistory <> nil) and (CmdIndex < Length(CommandHistory)) then @@ -718,7 +718,7 @@ begin Line := CommandHistory[CmdIndex]; CPos := Length(Line) + 1; end; - IK_UP: + IK_UP, IK_KPUP: if not gChatShow then if (CommandHistory <> nil) and (CmdIndex <= Length(CommandHistory)) then @@ -728,15 +728,15 @@ begin Line := CommandHistory[CmdIndex]; Cpos := Length(Line) + 1; end; - IK_PAGEUP: // PgUp + IK_PAGEUP, IK_KPPAGEUP: // PgUp if not gChatShow then IncMax(OffSet, Length(ConsoleHistory)-1); - IK_PAGEDN: // PgDown + IK_PAGEDN, IK_KPPAGEDN: // PgDown if not gChatShow then DecMin(OffSet, 0); - IK_HOME: + IK_HOME, IK_KPHOME: CPos := 1; - IK_END: + IK_END, IK_KPEND: CPos := Length(Line) + 1; end; end; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 70dba84..265533e 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1230,7 +1230,7 @@ begin if (not g_Game_IsClient) and ( ( - (e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_SPACE)) + (e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE)) and (not gJustChatted) and (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) ) diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index ba095b7..7eaed7b 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -883,7 +883,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN: Click(); + IK_RETURN, IK_KPRETURN: Click(); end; end; end; @@ -1097,7 +1097,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_UP: + IK_UP, IK_KPUP: begin repeat Dec(FIndex); @@ -1106,7 +1106,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_DOWN: + IK_DOWN, IK_KPDOWN: begin repeat Inc(FIndex); @@ -1115,7 +1115,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_RETURN: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click; + IK_RETURN, IK_KPRETURN: if (FIndex <> -1) and FButtons[FIndex].FEnabled then FButtons[FIndex].Click; end; end; end; @@ -1182,7 +1182,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN: if @FOnClickEvent <> nil then FOnClickEvent(); + IK_RETURN, IK_KPRETURN: if @FOnClickEvent <> nil then FOnClickEvent(); end; end; end; @@ -1416,7 +1416,7 @@ begin WM_KEYDOWN: begin case Msg.wParam of - IK_UP: + IK_UP, IK_KPUP: begin c := 0; repeat @@ -1437,7 +1437,7 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_DOWN: + IK_DOWN, IK_KPDOWN: begin c := 0; repeat @@ -1458,13 +1458,13 @@ begin g_Sound_PlayEx(MENU_CHANGESOUND); end; - IK_LEFT, IK_RIGHT: + IK_LEFT, IK_RIGHT, IK_KPLEFT, IK_KPRIGHT: begin if FIndex <> -1 then if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg); end; - IK_RETURN: + IK_RETURN, IK_KPRETURN: begin if FIndex <> -1 then if FItems[FIndex].Control <> nil then @@ -1903,14 +1903,14 @@ begin WM_KEYDOWN: begin case Msg.wParam of - IK_LEFT: + IK_LEFT, IK_KPLEFT: if FValue > 0 then begin Dec(FValue); g_Sound_PlayEx(SCROLL_SUBSOUND); if @FOnChangeEvent <> nil then FOnChangeEvent(Self); end; - IK_RIGHT: + IK_RIGHT, IK_KPRIGHT: if FValue < FMax then begin Inc(FValue); @@ -1987,7 +1987,7 @@ begin case Msg.Msg of WM_KEYDOWN: case Msg.wParam of - IK_RETURN, IK_RIGHT: + IK_RETURN, IK_RIGHT, IK_KPRETURN, IK_KPRIGHT: begin if FIndex < High(FItems) then Inc(FIndex) @@ -1998,7 +1998,7 @@ begin FOnChangeEvent(Self); end; - IK_LEFT: + IK_LEFT, IK_KPLEFT: begin if FIndex > 0 then Dec(FIndex) @@ -2097,11 +2097,11 @@ begin if FCaretPos > 0 then Dec(FCaretPos); end; IK_DELETE: Delete(FText, FCaretPos + 1, 1); - IK_END: FCaretPos := Length(FText); - IK_HOME: FCaretPos := 0; - IK_LEFT: if FCaretPos > 0 then Dec(FCaretPos); - IK_RIGHT: if FCaretPos < Length(FText) then Inc(FCaretPos); - IK_RETURN: + 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: with FWindow do begin if FActiveControl <> Self then @@ -2191,7 +2191,7 @@ begin FIsQuery := False; end; - IK_RETURN: + IK_RETURN, IK_KPRETURN: begin if not FIsQuery then begin @@ -2216,7 +2216,7 @@ begin end; MESSAGE_DIKEY: - if FIsQuery and (wParam <> IK_ENTER) then // Not IK_ENTER) and (wParam <> IK_KPRETURN) then // Not '' then FKey := wParam; @@ -2615,31 +2615,31 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_HOME: + IK_HOME, IK_KPHOME: begin FIndex := 0; FStartLine := 0; end; - IK_END: + IK_END, IK_KPEND: begin FIndex := High(FItems); FStartLine := Max(High(FItems)-FHeight+1, 0); end; - IK_UP, IK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT: 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_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT: 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_RETURN, IK_KPRETURN: with FWindow do begin if FActiveControl <> Self then SetActive(Self) @@ -2739,7 +2739,7 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_HOME: + IK_HOME, IK_KPHOME: begin FIndex := 0; FStartLine := 0; @@ -2747,7 +2747,7 @@ begin FOnChangeEvent(Self); end; - IK_END: + IK_END, IK_KPEND: begin FIndex := High(FItems); FStartLine := Max(High(FItems)-FHeight+1, 0); @@ -2755,7 +2755,7 @@ begin FOnChangeEvent(Self); end; - IK_PAGEUP: + IK_PAGEUP, IK_KPPAGEUP: begin if FIndex > FHeight then FIndex := FIndex-FHeight @@ -2768,7 +2768,7 @@ begin FStartLine := 0; end; - IK_PAGEDN: + IK_PAGEDN, IK_KPPAGEDN: begin if FIndex < High(FItems)-FHeight then FIndex := FIndex+FHeight @@ -2781,7 +2781,7 @@ begin FStartLine := High(FItems)-FHeight+1; end; - IK_UP, IK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT: if FIndex > 0 then begin Dec(FIndex); @@ -2791,7 +2791,7 @@ begin FOnChangeEvent(Self); end; - IK_DOWN, IK_RIGHT: + IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT: if FIndex < High(FItems) then begin Inc(FIndex); @@ -2801,7 +2801,7 @@ begin FOnChangeEvent(Self); end; - IK_RETURN: + IK_RETURN, IK_KPRETURN: with FWindow do begin if FActiveControl <> Self then @@ -2977,13 +2977,13 @@ begin case Msg of WM_KEYDOWN: case wParam of - IK_UP, IK_LEFT: + IK_UP, IK_LEFT, IK_KPUP, IK_KPLEFT: if FStartLine > 0 then Dec(FStartLine); - IK_DOWN, IK_RIGHT: + IK_DOWN, IK_RIGHT, IK_KPDOWN, IK_KPRIGHT: if FStartLine < Length(FLines)-FHeight then Inc(FStartLine); - IK_RETURN: + IK_RETURN, IK_KPRETURN: with FWindow do begin if FActiveControl <> Self then diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 194a1ed..a1b9b6f 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -526,7 +526,7 @@ begin if SL = nil then Exit; - if e_KeyPressed(IK_RETURN) then + if e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) then begin if not slReturnPressed then begin @@ -550,7 +550,7 @@ begin else slReturnPressed := False; - if e_KeyPressed(IK_DOWN) then + if e_KeyPressed(IK_DOWN) or e_KeyPressed(IK_KPDOWN) then begin if not slDirPressed then begin @@ -560,7 +560,7 @@ begin end; end; - if e_KeyPressed(IK_UP) then + if e_KeyPressed(IK_UP) or e_KeyPressed(IK_KPUP) then begin if not slDirPressed then begin @@ -571,7 +571,7 @@ begin end; end; - if (not e_KeyPressed(IK_DOWN)) and (not e_KeyPressed(IK_UP)) 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)) then slDirPressed := False; end;