From 2740a6f761a2441d186b4c4ddeec7b831bbc7491 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Sun, 7 Jan 2024 20:55:39 -0500 Subject: [PATCH] Add option to disable gamepads and remove leftover code --- lang/Czech.ini | 1 + lang/Dutch.ini | 1 + lang/English.ini | 1 + lang/French.ini | 1 + lang/German.ini | 1 + lang/Italian.ini | 1 + lang/Polish.ini | 1 + lang/Portuguese.ini | 1 + lang/Russian.ini | 1 + lang/Spanish.ini | 1 + src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + src/pc/controller/controller_sdl1.c | 1 + src/pc/controller/controller_sdl2.c | 1 + src/pc/djui/djui_panel_controls.c | 1 + src/pc/djui/djui_unicode.c | 3 --- 16 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lang/Czech.ini b/lang/Czech.ini index e1e6a9b7..fb097b7e 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -81,6 +81,7 @@ CONTROLS = "OVLADANI" N64_BINDS = "N64 Ovládání" EXTRA_BINDS = "Extra Ovládání" BACKGROUND_GAMEPAD = "Ovladač v pozadí" +DISABLE_GAMEPADS = "Zakažte gamepady" GAMEPAD = "Použít ovladač" DEADZONE = "Deadzone" RUMBLE_STRENGTH = "Síla vibrace" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 22e87a2e..9d037640 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -81,6 +81,7 @@ CONTROLS = "CONTROLES" N64_BINDS = "N64 Toetsen" EXTRA_BINDS = "Extra Toetsen" BACKGROUND_GAMEPAD = "Achtergrond Gamepad" +DISABLE_GAMEPADS = "Gamepads uitschakelen" GAMEPAD = "Gamepad" DEADZONE = "Doode-zone" RUMBLE_STRENGTH = "Rommel Kracht" diff --git a/lang/English.ini b/lang/English.ini index 11f332e8..2da41c11 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -81,6 +81,7 @@ CONTROLS = "CONTROLS" N64_BINDS = "N64 Binds" EXTRA_BINDS = "Extra Binds" BACKGROUND_GAMEPAD = "Background Gamepad" +DISABLE_GAMEPADS = "Disable Gamepads" GAMEPAD = "Gamepad" DEADZONE = "Deadzone" RUMBLE_STRENGTH = "Rumble Strength" diff --git a/lang/French.ini b/lang/French.ini index 73e0de5b..8f1a2395 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -81,6 +81,7 @@ CONTROLS = "CONTRÔLES" N64_BINDS = "Touches N64" EXTRA_BINDS = "Touches Supplémentaires" BACKGROUND_GAMEPAD = "Manette en arrière plan" +DISABLE_GAMEPADS = "Désactiver les manettes de jeu" GAMEPAD = "Manette" DEADZONE = "Zone Morte" RUMBLE_STRENGTH = "Vibrations" diff --git a/lang/German.ini b/lang/German.ini index 14358654..4417d479 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -81,6 +81,7 @@ CONTROLS = "STEUERUNG" N64_BINDS = "N64-Einstellungen" EXTRA_BINDS = "Zusätzliche Einstellungen" BACKGROUND_GAMEPAD = "Hintergrund-Gamepad" +DISABLE_GAMEPADS = "Gamepads deaktivieren" GAMEPAD = "Gamepad" DEADZONE = "Tote Zone" RUMBLE_STRENGTH = "Vibration-Stärke" diff --git a/lang/Italian.ini b/lang/Italian.ini index b4f32643..0038fc9d 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -80,6 +80,7 @@ CONTROLS = "CONTROLLI" N64_BINDS = "Comandi N64" EXTRA_BINDS = "Comandi Extra" BACKGROUND_GAMEPAD = "Azione in Background" +DISABLE_GAMEPADS = "Disabilita i gamepad" GAMEPAD = "Controller" DEADZONE = "Zona Morta" RUMBLE_STRENGTH = "Intesità Vibrazione" diff --git a/lang/Polish.ini b/lang/Polish.ini index 72f285a7..37783358 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -81,6 +81,7 @@ CONTROLS = "STEROWANIE" N64_BINDS = "Przypisania N64" EXTRA_BINDS = "Dodatkowe Przypisania" BACKGROUND_GAMEPAD = "Gamepad w tle" +DISABLE_GAMEPADS = "Wyłącz gamepady" GAMEPAD = "Gamepad" DEADZONE = "Martwa Strefa" RUMBLE_STRENGTH = "Sila Wibracji" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index a26771ea..1542f260 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -81,6 +81,7 @@ CONTROLS = "CONTROLES" N64_BINDS = "N64" EXTRA_BINDS = "Outros" BACKGROUND_GAMEPAD = "Controle de fundo" +DISABLE_GAMEPADS = "Desativar gamepads" GAMEPAD = "Controle" DEADZONE = "Deadzone" RUMBLE_STRENGTH = "Força de vibração" diff --git a/lang/Russian.ini b/lang/Russian.ini index 4851328b..8b8446d1 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -80,6 +80,7 @@ CONTROLS = "CONTROLS" N64_BINDS = "Кнопки N64" EXTRA_BINDS = "Дополнительные кнопки" BACKGROUND_GAMEPAD = "Фоновый ввод" +DISABLE_GAMEPADS = "Отключить геймпады" GAMEPAD = "Геймпад" DEADZONE = "Mёртвая зона" RUMBLE_STRENGTH = "Вибрация" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index e8e32acd..2c5f700f 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -81,6 +81,7 @@ CONTROLS = "CONTROLES" N64_BINDS = "Botones de N64" EXTRA_BINDS = "Botones Adicionales" BACKGROUND_GAMEPAD = "Mando en segundo plano" +DISABLE_GAMEPADS = "Desactivar gamepads" GAMEPAD = "Mando" DEADZONE = "Zona muerta" RUMBLE_STRENGTH = "Fuerza de vibración" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 03ba1603..71eca46f 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -150,6 +150,7 @@ bool configCtxProfiler = false; unsigned int configInterpolationMode = 1; unsigned int configGamepadNumber = 0; bool configBackgroundGamepad = true; +bool configDisableGamepads = false; bool configDebugPrint = false; bool configDebugInfo = false; bool configDebugError = false; @@ -269,6 +270,7 @@ static const struct ConfigOption options[] = { {.name = "interpolation_mode", .type = CONFIG_TYPE_UINT , .uintValue = &configInterpolationMode}, {.name = "gamepad_number", .type = CONFIG_TYPE_UINT , .uintValue = &configGamepadNumber}, {.name = "background_gamepad", .type = CONFIG_TYPE_UINT , .boolValue = &configBackgroundGamepad}, + {.name = "disable_gamepads", .type = CONFIG_TYPE_BOOL , .boolValue = &configDisableGamepads}, {.name = "debug_print", .type = CONFIG_TYPE_BOOL , .boolValue = &configDebugPrint}, {.name = "debug_info", .type = CONFIG_TYPE_BOOL , .boolValue = &configDebugInfo}, {.name = "debug_error", .type = CONFIG_TYPE_BOOL , .boolValue = &configDebugError}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 063f5419..c9cef7eb 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -64,6 +64,7 @@ extern unsigned int configStickDeadzone; extern unsigned int configRumbleStrength; extern unsigned int configGamepadNumber; extern bool configBackgroundGamepad; +extern bool configDisableGamepads; extern unsigned int configCameraXSens; extern unsigned int configCameraYSens; extern unsigned int configCameraAggr; diff --git a/src/pc/controller/controller_sdl1.c b/src/pc/controller/controller_sdl1.c index 36cf450f..d4991536 100644 --- a/src/pc/controller/controller_sdl1.c +++ b/src/pc/controller/controller_sdl1.c @@ -168,6 +168,7 @@ static void controller_sdl_read(OSContPad *pad) { last_mouse = (mouse_buttons ^ mouse) & mouse; mouse_buttons = mouse; + if (configDisableGamepads) { return; } if (!sdl_joy) return; SDL_JoystickUpdate(); diff --git a/src/pc/controller/controller_sdl2.c b/src/pc/controller/controller_sdl2.c index 56748f63..7393177f 100644 --- a/src/pc/controller/controller_sdl2.c +++ b/src/pc/controller/controller_sdl2.c @@ -206,6 +206,7 @@ static void controller_sdl_read(OSContPad *pad) { SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, sBackgroundGamepad ? "1" : "0"); } + if (configDisableGamepads) { return; } SDL_GameControllerUpdate(); diff --git a/src/pc/djui/djui_panel_controls.c b/src/pc/djui/djui_panel_controls.c index f9d7d1f4..568c5613 100644 --- a/src/pc/djui/djui_panel_controls.c +++ b/src/pc/djui/djui_panel_controls.c @@ -19,6 +19,7 @@ void djui_panel_controls_create(struct DjuiBase* caller) { djui_button_create(body, DLANG(CONTROLS, N64_BINDS), DJUI_BUTTON_STYLE_NORMAL, djui_panel_controls_n64_create); djui_button_create(body, DLANG(CONTROLS, EXTRA_BINDS), DJUI_BUTTON_STYLE_NORMAL, djui_panel_controls_extra_create); djui_checkbox_create(body, DLANG(CONTROLS, BACKGROUND_GAMEPAD), &configBackgroundGamepad, NULL); + djui_checkbox_create(body, DLANG(CONTROLS, DISABLE_GAMEPADS), &configDisableGamepads, NULL); #ifdef HAVE_SDL2 int numJoys = SDL_NumJoysticks(); diff --git a/src/pc/djui/djui_unicode.c b/src/pc/djui/djui_unicode.c index e8eb5ca7..afd52f15 100644 --- a/src/pc/djui/djui_unicode.c +++ b/src/pc/djui/djui_unicode.c @@ -307,9 +307,6 @@ f32 djui_unicode_get_sprite_width(char* text, const f32 font_widths[]) { if (glyph) { if (glyph->width) { // use the custom width - if (font_widths[0] < 1) { - return glyph->width / 32.0f; - } return glyph->width; } if ((u8)glyph->base < (u8)'!') {