Added SDL_HINT_MUTE_CONSOLE_KEYBOARD

This commit is contained in:
Sam Lantinga 2024-08-03 12:23:56 -07:00
parent afde1cc9c2
commit 746b8eb14b
4 changed files with 21 additions and 4 deletions

View File

@ -815,6 +815,8 @@ The following environment variables have been removed:
* SDL_HAPTIC_GAIN_MAX
* SDL_HIDAPI_DISABLE_LIBUSB - replaced with the hint SDL_HINT_HIDAPI_LIBUSB
* SDL_HIDAPI_JOYSTICK_DISABLE_UDEV - replaced with the hint SDL_HINT_HIDAPI_UDEV
* SDL_INPUT_FREEBSD_KEEP_KBD - replaced with the hint SDL_HINT_MUTE_CONSOLE_KEYBOARD
* SDL_INPUT_LINUX_KEEP_KBD - replaced with the hint SDL_HINT_MUTE_CONSOLE_KEYBOARD
* VITA_DISABLE_TOUCH_BACK - replaced with the hint SDL_HINT_VITA_ENABLE_BACK_TOUCH
* VITA_DISABLE_TOUCH_FRONT - replaced with the hint SDL_HINT_VITA_ENABLE_FRONT_TOUCH
* VITA_MODULE_PATH - replaced with the hint SDL_HINT_VITA_MODULE_PATH

View File

@ -2482,6 +2482,22 @@ extern "C" {
*/
#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS"
/**
* A variable controlling whether the keyboard should be muted on the console.
*
* Normally the keyboard is muted while SDL applications are running so that keyboard input doesn't show up as key strokes on the console. This hint allows you to turn that off for debugging purposes.
*
* The variable can be set to the following values:
*
* - "0": Allow keystrokes to go through to the console.
* - "1": Mute keyboard input so it doesn't show up on the console. (default)
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_MUTE_CONSOLE_KEYBOARD "SDL_MUTE_CONSOLE_KEYBOARD"
/**
* Tell SDL not to catch the SIGINT or SIGTERM signals on POSIX platforms.
*

View File

@ -264,8 +264,8 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
SDL_free(kbd->key_map);
kbd->key_map = &keymap_default_us_acc;
}
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
if (SDL_getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) {
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
/* Take keyboard from console and open the actual keyboard device.
* Ensures that the keystrokes do not leak through to the console.
*/

View File

@ -473,8 +473,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
}
if (muted) {
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
/* Mute the keyboard so keystrokes only generate evdev events
* and do not leak through to the console
*/