Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Richard Gobeille
EDuke32
Commits
c819ba04
Commit
c819ba04
authored
Apr 10, 2022
by
Dino Bollinger
Committed by
Richard Gobeille
Apr 11, 2022
Browse files
Duke3D: Prevent assigning both columns of keybinds to the same key
Instead it now switches the key from column 0 to 1 and vice-versa
parent
30baffe7
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/duke3d/src/menus.cpp
View file @
c819ba04
...
...
@@ -1956,18 +1956,18 @@ static void Menu_EraseMatchingBinds(const int32_t sc)
}
}
static
void
Menu_SetKeyboardScanCode
(
MenuCustom2Col_t
*
column
,
const
int32_t
sc
,
const
bool
eraseBinds
)
static
void
Menu_SetKeyboardScanCode
(
MenuCustom2Col_t
*
column
Entry
,
const
int32_t
colidx
,
const
int32_t
sc
,
const
bool
eraseBinds
)
{
char
key
[
2
];
key
[
0
]
=
ud
.
config
.
KeyboardKeys
[
column
->
linkIndex
][
0
];
key
[
1
]
=
ud
.
config
.
KeyboardKeys
[
column
->
linkIndex
][
1
];
key
[
0
]
=
ud
.
config
.
KeyboardKeys
[
column
Entry
->
linkIndex
][
0
];
key
[
1
]
=
ud
.
config
.
KeyboardKeys
[
column
Entry
->
linkIndex
][
1
];
if
(
eraseBinds
)
Menu_EraseMatchingBinds
(
sc
);
*
column
->
column
[
M_KEYBOARDKEYS
.
currentColumn
]
=
sc
;
*
column
Entry
->
column
[
colidx
]
=
sc
;
CONFIG_MapKey
(
column
->
linkIndex
,
ud
.
config
.
KeyboardKeys
[
column
->
linkIndex
][
0
],
key
[
0
],
ud
.
config
.
KeyboardKeys
[
column
->
linkIndex
][
1
],
key
[
1
]);
CONFIG_MapKey
(
column
Entry
->
linkIndex
,
ud
.
config
.
KeyboardKeys
[
column
Entry
->
linkIndex
][
0
],
key
[
0
],
ud
.
config
.
KeyboardKeys
[
column
Entry
->
linkIndex
][
1
],
key
[
1
]);
}
/*
...
...
@@ -3627,32 +3627,41 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
{
if
(
*
column
->
column
[
M_KEYBOARDKEYS
.
currentColumn
]
!=
sc
)
{
bool
alreadyAssigned
=
false
;
for
(
int
i
=
0
;
i
<
M_KEYBOARDKEYS
.
numEntries
;
i
++
)
if
(
*
column
->
column
[
M_KEYBOARDKEYS
.
currentColumn
^
1
]
==
sc
)
{
if
(
i
==
M_KEYBOARDKEYS
.
currentEntry
)
continue
;
auto
iterCol
=
(
MenuCustom2Col_t
*
)
M_KEYBOARDKEYS
.
entrylist
[
i
]
->
entry
;
if
((
*
iterCol
->
column
[
0
]
==
sc
)
||
(
*
iterCol
->
column
[
1
]
==
sc
))
Menu_SetKeyboardScanCode
(
column
,
M_KEYBOARDKEYS
.
currentColumn
^
1
,
0xFF
,
false
);
Menu_SetKeyboardScanCode
(
column
,
M_KEYBOARDKEYS
.
currentColumn
,
sc
,
false
);
}
else
{
bool
alreadyAssigned
=
false
;
for
(
int
i
=
0
;
i
<
M_KEYBOARDKEYS
.
numEntries
;
i
++
)
{
alreadyAssigned
=
true
;
break
;
if
(
i
==
M_KEYBOARDKEYS
.
currentEntry
)
continue
;
auto
iterCol
=
(
MenuCustom2Col_t
*
)
M_KEYBOARDKEYS
.
entrylist
[
i
]
->
entry
;
if
((
*
iterCol
->
column
[
0
]
==
sc
)
||
(
*
iterCol
->
column
[
1
]
==
sc
))
{
alreadyAssigned
=
true
;
break
;
}
}
}
S_PlaySound
(
PISTOL_BODYHIT
);
if
(
cvar_kbconfirm
&&
alreadyAssigned
)
{
s_saved_scancode
=
sc
;
s_saved_keycolumn
=
column
;
Menu_RefreshBoundGamefuncNames
(
sc
);
KB_ClearKeyDown
(
sc_N
);
KB_ClearKeyDown
(
sc_Y
);
Menu_Change
(
MENU_KEYOVERRIDEVERIFY
);
if
(
cvar_kbconfirm
&&
alreadyAssigned
)
{
s_saved_scancode
=
sc
;
s_saved_keycolumn
=
column
;
Menu_RefreshBoundGamefuncNames
(
sc
);
KB_ClearKeyDown
(
sc_N
);
KB_ClearKeyDown
(
sc_Y
);
Menu_Change
(
MENU_KEYOVERRIDEVERIFY
);
}
else
Menu_SetKeyboardScanCode
(
column
,
M_KEYBOARDKEYS
.
currentColumn
,
sc
,
false
);
}
else
Menu_SetKeyboardScanCode
(
column
,
sc
,
false
);
}
S_PlaySound
(
PISTOL_BODYHIT
);
KB_ClearKeyDown
(
sc
);
return
-
1
;
}
...
...
@@ -4563,7 +4572,7 @@ static void Menu_Verify(int32_t input)
case
MENU_KEYOVERRIDEVERIFY
:
Bassert
(
s_saved_keycolumn
!=
nullptr
);
if
(
input
)
Menu_SetKeyboardScanCode
(
s_saved_keycolumn
,
s_saved_scancode
,
input
==
1
);
Menu_SetKeyboardScanCode
(
s_saved_keycolumn
,
M_KEYBOARDKEYS
.
currentColumn
,
s_saved_scancode
,
input
==
1
);
DO_FREE_AND_NULL
(
s_override_gfstring
);
break
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment