From 1250c0843a4a3ee3f4971138885f7f572f3f9d51 Mon Sep 17 00:00:00 2001 From: Craig Carnell <1188869+cscd98@users.noreply.github.com> Date: Sat, 8 Aug 2026 10:42:54 +0100 Subject: [PATCH] libretro: add option to disable default mouse bindings --- .../Core/DolphinLibretro/Common/Options.cpp | 14 ++++++++ Source/Core/DolphinLibretro/Common/Options.h | 1 + Source/Core/DolphinLibretro/Input.cpp | 32 +++++++++++++------ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinLibretro/Common/Options.cpp b/Source/Core/DolphinLibretro/Common/Options.cpp index be6b1934c875..3810a65c461c 100644 --- a/Source/Core/DolphinLibretro/Common/Options.cpp +++ b/Source/Core/DolphinLibretro/Common/Options.cpp @@ -1778,6 +1778,20 @@ static struct retro_core_option_v2_definition option_defs[] = { "disabled" #endif }, + { + Libretro::Options::retroarch_core::ENABLE_DEFAULT_MOUSE_BINDINGS, + "RetroArch core > Enable Default Mouse Bindings", + "Enable Default Mouse Bindings", + "Enable default Mouse Bindings, disable for more control on bindings.", + nullptr, + CATEGORY_RETROARCH_CORE, + { + { "disabled", nullptr }, + { "enabled", nullptr }, + { nullptr, nullptr } + }, + "enabled" + }, { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, {{0}}, nullptr } }; diff --git a/Source/Core/DolphinLibretro/Common/Options.h b/Source/Core/DolphinLibretro/Common/Options.h index 5679ad77dbf2..ddd01b3ec8b3 100644 --- a/Source/Core/DolphinLibretro/Common/Options.h +++ b/Source/Core/DolphinLibretro/Common/Options.h @@ -319,6 +319,7 @@ namespace retroarch_core { #endif constexpr const char ENABLE_LIBRETRO_VFS[] = "dolphin_libretro_vfs_enabled"; + constexpr const char ENABLE_DEFAULT_MOUSE_BINDINGS[] = "dolphin_default_mouse_bindings_enabled"; } // namespace wiimote diff --git a/Source/Core/DolphinLibretro/Input.cpp b/Source/Core/DolphinLibretro/Input.cpp index 8382eac763c6..1da73bbc7493 100644 --- a/Source/Core/DolphinLibretro/Input.cpp +++ b/Source/Core/DolphinLibretro/Input.cpp @@ -1213,6 +1213,18 @@ static WiimoteEmu::Wiimote* load_saved_controller_config(unsigned port, unsigned return nullptr; // nothing found, applies hard-coded defaults } +// returns retropad_expr on its own, with additional mouse bindings +static std::string bindMouse(const std::string& retropad_expr, const std::string& mouse_target) +{ + static const bool enable_default_mouse_bindings = + Libretro::Options::GetCached(Libretro::Options::retroarch_core::ENABLE_DEFAULT_MOUSE_BINDINGS, /*def=*/true); + + if (!enable_default_mouse_bindings) + return retropad_expr; + + return retropad_expr + " | `" + mouse_target + "`"; +} + void retro_set_controller_port_device_gc(unsigned port, unsigned device) { std::string devJoypad = Libretro::Input::GetQualifiedName(port, RETRO_DEVICE_JOYPAD); @@ -1413,12 +1425,12 @@ void retro_set_controller_port_device_wii(unsigned port, unsigned device) ncStick->SetControlExpression(1, "`" + devAnalog + ":Y0+`"); // Down ncStick->SetControlExpression(2, "`" + devAnalog + ":X0-`"); // Left ncStick->SetControlExpression(3, "`" + devAnalog + ":X0+`"); // Right - ncShake->SetControlExpression(0, "L2 | `" + devMouse + ":Middle`"); // Nunchuk shake X - ncShake->SetControlExpression(1, "L2 | `" + devMouse + ":Middle`"); // Nunchuk shake Y - ncShake->SetControlExpression(2, "L2 | `" + devMouse + ":Middle`"); // Nunchuk shake Z + ncShake->SetControlExpression(0, bindMouse("L2", devMouse + ":Middle")); // Nunchuk shake X + ncShake->SetControlExpression(1, bindMouse("L2", devMouse + ":Middle")); // Nunchuk shake Y + ncShake->SetControlExpression(2, bindMouse("L2", devMouse + ":Middle")); // Nunchuk shake Z - wmButtons->SetControlExpression(0, "A | `" + devMouse + ":Left`"); // A - wmButtons->SetControlExpression(1, "B | `" + devMouse + ":Right`"); // B + wmButtons->SetControlExpression(0, bindMouse("A", devMouse + ":Left")); // A + wmButtons->SetControlExpression(1, bindMouse("B", devMouse + ":Right")); // B wmButtons->SetControlExpression(2, "Start"); // 1 wmButtons->SetControlExpression(3, "Select"); // 2 wmButtons->SetControlExpression(4, "L"); // - @@ -1430,8 +1442,8 @@ void retro_set_controller_port_device_wii(unsigned port, unsigned device) { if (device == RETRO_DEVICE_WIIMOTE) { - wmButtons->SetControlExpression(0, "A | `" + devMouse + ":Left`"); // A - wmButtons->SetControlExpression(1, "B | `" + devMouse + ":Right`"); // B + wmButtons->SetControlExpression(0, bindMouse("A", devMouse + ":Left")); // A + wmButtons->SetControlExpression(1, bindMouse("B", devMouse + ":Right")); // B wmButtons->SetControlExpression(2, "X"); // 1 wmButtons->SetControlExpression(3, "Y"); // 2 } @@ -1506,9 +1518,9 @@ void retro_set_controller_port_device_wii(unsigned port, unsigned device) f.sideways = true; Libretro::Input::UpdateWiimoteMappings(f, port, device); - wmShake->SetControlExpression(0, "R2 | `" + devMouse + ":Middle`"); // Wiimote shake X - wmShake->SetControlExpression(1, "R2 | `" + devMouse + ":Middle`"); // Wiimote shake Y - wmShake->SetControlExpression(2, "R2 | `" + devMouse + ":Middle`"); // Wiimote shake Z + wmShake->SetControlExpression(0, bindMouse("L2", devMouse + ":Middle")); // Wiimote shake X + wmShake->SetControlExpression(1, bindMouse("L2", devMouse + ":Middle")); // Wiimote shake Y + wmShake->SetControlExpression(2, bindMouse("L2", devMouse + ":Middle")); // Wiimote shake Z } ControllerEmu::ControlGroup* wmOptions = wm->GetWiimoteGroup(WiimoteGroup::Options);