Skip to content

Commit 8375991

Browse files
committed
Only use RALT/RSHIFT/RCTRL bindings if they exist, otherwise fallback to default bindings.
1 parent 08ec047 commit 8375991

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

codemp/client/cl_keys.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,11 +655,12 @@ void Field_CharEvent( field_t *edit, int ch ) {
655655
return;
656656
}
657657

658-
if (ch == 'a' - 'a' + 1) { // ctrl-a moves field contents to clipboard
658+
if (ch == 'a' - 'a' + 1) { // ctrl-a clears field and copies contents to clipboard
659659
Sys_SetClipboardData(edit->buffer);
660660
Field_Clear(edit);
661661
return;
662662
}
663+
663664
if ( ch == 'q' - 'a' + 1 ) { // ctrl-q is home
664665
edit->cursor = 0;
665666
edit->scroll = 0;
@@ -685,7 +686,6 @@ void Field_CharEvent( field_t *edit, int ch ) {
685686

686687
if (ch == '"')
687688
max -= 2;
688-
689689
}
690690

691691
if ( kg.key_overstrikeMode ) {
@@ -1320,9 +1320,29 @@ void CL_ParseBinding( int key, qboolean down, unsigned time )
13201320

13211321
if( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == 0 )
13221322
return;
1323-
if( !kg.keys[keynames[key].upper].binding || !kg.keys[keynames[key].upper].binding[0] )
1323+
1324+
// for rshift/ralt/rctrl, prefer the specific rshift/rctrl/ralt bind if
1325+
// it exists; otherwise, fallback to the generic shift/ctrl/alt bind
1326+
const char *binding;
1327+
int genericKey = 0;
1328+
switch (key) {
1329+
case A_SHIFT2: genericKey = A_SHIFT; break;
1330+
case A_CTRL2: genericKey = A_CTRL; break;
1331+
case A_ALT2: genericKey = A_ALT; break;
1332+
}
1333+
if (genericKey) {
1334+
if (VALIDSTRING(kg.keys[keynames[key].upper].binding))
1335+
binding = kg.keys[keynames[key].upper].binding;
1336+
else
1337+
binding = kg.keys[keynames[genericKey].upper].binding;
1338+
}
1339+
else {
1340+
binding = kg.keys[keynames[key].upper].binding;
1341+
}
1342+
1343+
if (!VALIDSTRING(binding))
13241344
return;
1325-
Q_strncpyz( buf, kg.keys[keynames[key].upper].binding, sizeof( buf ) );
1345+
Q_strncpyz(buf, binding, sizeof(buf));
13261346

13271347
// run all bind commands if console, ui, etc aren't reading keys
13281348
allCommands = (qboolean)( Key_GetCatcher( ) == 0 );

0 commit comments

Comments
 (0)