made more keys bindable on Linux/FreeBSD and /bind now accepts uppercase hex digits

This commit is contained in:
myT 2020-04-04 03:20:03 +02:00
parent d5984db690
commit a5b6ee33da
3 changed files with 22 additions and 8 deletions

View file

@ -140,6 +140,8 @@ chg: r_fullbright is now latched again
chg: negative r_swapInterval values will request adaptive V-Sync when using an OpenGL back-end
fix: made more keys bindable on Linux/FreeBSD and /bind now accepts uppercase hex digits
fix: removing CVars through unset/cvar_trim/cvar_restart could leave data in an invalid state
fix: r_detailTextures 0 would mess up shaders where "detail" was used in a stage that isn't the last one

View file

@ -682,7 +682,7 @@ static int Key_StringToKeynum( const char* str )
if ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4) {
int n1, n2;
n1 = str[2];
n1 = tolower( str[2] );
if ( n1 >= '0' && n1 <= '9' ) {
n1 -= '0';
} else if ( n1 >= 'a' && n1 <= 'f' ) {
@ -691,7 +691,7 @@ static int Key_StringToKeynum( const char* str )
n1 = 0;
}
n2 = str[3];
n2 = tolower( str[3] );
if ( n2 >= '0' && n2 <= '9' ) {
n2 -= '0';
} else if ( n2 >= 'a' && n2 <= 'f' ) {
@ -748,8 +748,8 @@ const char* Key_KeynumToString( int keynum )
tinystr[0] = '0';
tinystr[1] = 'x';
tinystr[2] = i > 9 ? i - 10 + 'a' : i + '0';
tinystr[3] = j > 9 ? j - 10 + 'a' : j + '0';
tinystr[2] = i > 9 ? i - 10 + 'A' : i + '0';
tinystr[3] = j > 9 ? j - 10 + 'A' : j + '0';
tinystr[4] = 0;
return tinystr;

View file

@ -163,6 +163,10 @@ static int QuakeKeyFromSDLKey( SDL_Keysym key )
case SDLK_KP_PLUS: return K_KP_PLUS;
case SDLK_KP_MULTIPLY: return K_KP_STAR;
case SDLK_BACKSLASH: return K_BACKSLASH;
case SDLK_PAUSE: return K_PAUSE;
case SDLK_NUMLOCKCLEAR: return K_KP_NUMLOCK;
case SDLK_KP_EQUALS: return K_KP_EQUALS;
case SDLK_MENU: return K_MENU;
case SDLK_PERIOD: return '.';
case SDLK_COMMA: return ',';
case SDLK_EXCLAIM: return '!';
@ -186,11 +190,19 @@ static int QuakeKeyFromSDLKey( SDL_Keysym key )
case SDLK_LEFTBRACKET: return '[';
case SDLK_RIGHTBRACKET: return ']';
case SDLK_UNDERSCORE: return '_';
// missing:
// K_KP_NUMLOCK
// K_KP_EQUALS
default: return -1;
case SDLK_SEMICOLON: return ';';
// not handled:
// K_COMMAND (Apple)
// K_POWER (Apple)
// K_AUX1-16
// K_WIN
default: break;
}
if (sym >= 32 && sym <= 126)
return (int)sym;
return -1;
}