Skip to content

Commit

Permalink
Refix bug #1106 Space and Ctrl cause Enter to appear pressed, Alt cau…
Browse files Browse the repository at this point in the history
…ses ESC to appear pressed

git-svn-id: https://rpg.hamsterrepublic.com/source/wip@12393 7d344553-34f0-0310-a9b1-970ce8f1c3a2
  • Loading branch information
rversteegen committed Sep 8, 2021
1 parent 5d32d65 commit 0fda876
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions allmodex.bas
Expand Up @@ -1796,7 +1796,8 @@ end function
'Reads replayed state, if any (real_keys = NO)
'key: any scancode, including cc* constants and joystick buttons
'player: 0 for any input device, 1 is first joystick + keyboard, 2-4 are other joysticks
function player_keyval(key as KBScancode, player as integer, repeat_wait as integer = 0, repeat_rate as integer = 0) as KeyBits
'check_keyboard: pass false to ignore keyboard input
function player_keyval(key as KBScancode, player as integer, repeat_wait as integer = 0, repeat_rate as integer = 0, check_keyboard as bool = YES) as KeyBits
BUG_IF(player < 0, "Invalid player " & player, 0)
BUG_IF(key < scKEYVAL_FIRST orelse key > scKEYVAL_LAST, "bad scancode " & key, 0)

Expand All @@ -1805,7 +1806,7 @@ function player_keyval(key as KBScancode, player as integer, repeat_wait as inte
if player = 0 then
'Merge all inputs
for player = 1 to num_joysticks()
ret or= player_keyval(key, player, repeat_wait, repeat_rate)
ret or= player_keyval(key, player, repeat_wait, repeat_rate, check_keyboard)
next
return ret
end if
Expand All @@ -1826,20 +1827,20 @@ function player_keyval(key as KBScancode, player as integer, repeat_wait as inte
'this doesn't check all joystick buttons, only ones mapped to carray
'TODO: scAny should be turned into ccAny, so we can remove this block
ret = inputst->joys(joynum).anykey(*inputst)
if player = 1 then
if player = 1 andalso check_keyboard then
'In future, ignore any keys mapped to other players?
ret or= inputst->kb.anykey(*inputst)
end if

else 'key <= ccHIGHEST
'TODO: This is missing repeat_wait/repeat_rate support
ret = inputst->joys(joynum).carray(key)
if player = 1 then
if player = 1 andalso check_keyboard then
ret or= inputst->kb.carray(key)
end if
end if
elseif key <= scLAST then 'Keyboard key
if player = 1 then
if player = 1 andalso check_keyboard then
ret = keyval_or_numpad_ex(key, repeat_wait, repeat_rate)
end if
else 'Joystick button
Expand Down
2 changes: 1 addition & 1 deletion allmodex.bi
Expand Up @@ -513,7 +513,7 @@ DECLARE FUNCTION keyval_ex (key as KBScancode, repeat_wait as integer = 0, repea
DECLARE FUNCTION real_keyval (key as KBScancode) as KeyBits
DECLARE FUNCTION keyval (key as KBScancode) as KeyBits
DECLARE FUNCTION carray alias "KEYVAL" (key as KBScancode) as KeyBits
DECLARE FUNCTION player_keyval (key as KBScancode, player as integer, repeat_wait as integer = 0, repeat_rate as integer = 0) as KeyBits
DECLARE FUNCTION player_keyval (key as KBScancode, player as integer, repeat_wait as integer = 0, repeat_rate as integer = 0, check_keyboard as bool = YES) as KeyBits
DECLARE FUNCTION slowkey (key as KBScancode, ms as integer) as bool
DECLARE FUNCTION getinputtext () as string

Expand Down
12 changes: 6 additions & 6 deletions scriptcommands.bas
Expand Up @@ -412,12 +412,12 @@ FUNCTION script_keyval (byval key as KBScancode, byval player as integer = 0) as

IF prefbit(47) = NO THEN '!Map joystick controls to keyboard keys for scripts
SELECT CASE key
CASE scUp: ret OR= player_keyval(ccUp, player)
CASE scDown: ret OR= player_keyval(ccDown, player)
CASE scLeft: ret OR= player_keyval(ccLeft, player)
CASE scRight: ret OR= player_keyval(ccRight, player)
CASE scEnter: ret OR= player_keyval(ccUse, player)
CASE scEsc: ret OR= player_keyval(ccMenu, player)
CASE scUp: ret OR= player_keyval(ccUp, player, , , NO) 'check_keyboard=NO
CASE scDown: ret OR= player_keyval(ccDown, player, , , NO)
CASE scLeft: ret OR= player_keyval(ccLeft, player, , , NO)
CASE scRight: ret OR= player_keyval(ccRight, player, , , NO)
CASE scEnter: ret OR= player_keyval(ccUse, player, , , NO)
CASE scEsc: ret OR= player_keyval(ccMenu, player, , , NO)
END SELECT
END IF

Expand Down

0 comments on commit 0fda876

Please sign in to comment.