Skip to content

Commit 87e4b14

Browse files
committed
libretro: add hotkey for upright toggle, rename wiimote to wiimote (upright)
1 parent c16d425 commit 87e4b14

5 files changed

Lines changed: 48 additions & 9 deletions

File tree

Source/Core/DolphinLibretro/Common/Options.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,31 @@ static struct retro_core_option_v2_definition option_defs[] = {
14831483
},
14841484
"L3"
14851485
},
1486+
{
1487+
Libretro::Options::wiimote::HOTKEY_UPRIGHT_TOGGLE,
1488+
"WiiMote Upright > Toggle Button",
1489+
"Upright Toggle Button",
1490+
"Button used to toggle upright mode. Can be disabled.",
1491+
nullptr,
1492+
CATEGORY_WIIMOTE,
1493+
{
1494+
{ MODIFIER_DISABLED_CONTROL, "Disabled" },
1495+
{ "L3", nullptr },
1496+
{ "R3", nullptr },
1497+
{ "L1", nullptr },
1498+
{ "R1", nullptr },
1499+
{ "L2", nullptr },
1500+
{ "R2", nullptr },
1501+
{ "A", nullptr },
1502+
{ "B", nullptr },
1503+
{ "X", nullptr },
1504+
{ "Y", nullptr },
1505+
{ "Start", nullptr },
1506+
{ "Select", nullptr },
1507+
{ nullptr, nullptr }
1508+
},
1509+
"Disabled"
1510+
},
14861511

14871512
// ========== Wiimote IR ==========
14881513
{

Source/Core/DolphinLibretro/Common/Options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ namespace wiimote {
293293

294294
// General and options
295295
constexpr const char HOTKEY_SIDEWAYS_TOGGLE[] = "dolphin_hotkey_sideways_toggle";
296+
constexpr const char HOTKEY_UPRIGHT_TOGGLE[] = "dolphin_hotkey_upright_toggle";
296297

297298
// Motion simulation
298299
constexpr const char IR_MODE[] = "dolphin_ir_mode";

Source/Core/DolphinLibretro/Input.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static struct retro_input_descriptor descWiimote[] = {
207207
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Shake Wiimote"},
208208
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "+"},
209209
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "-"},
210-
//{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "Sideways Toggle"},
210+
//{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "Sideways Toggle"}, // see: HOTKEY_SIDEWAYS_TOGGLE
211211
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "Home"},
212212
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X,
213213
"Tilt Left/Right"},
@@ -228,7 +228,7 @@ static struct retro_input_descriptor descWiimoteSideways[] = {
228228
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Shake Wiimote"},
229229
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "+"},
230230
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "-"},
231-
//{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "Sideways Toggle"},
231+
//{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "Sideways Toggle"}, // see: HOTKEY_SIDEWAYS_TOGGLE
232232
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "Home"},
233233
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X,
234234
"Tilt Left/Right"},
@@ -569,7 +569,7 @@ void InitStage2()
569569
if (Libretro::Options::GetCached<int>(Libretro::Options::sysconf::ALT_GC_PORTS_ON_WII))
570570
{
571571
static struct retro_controller_description wiimote_desc[] = {
572-
{"WiiMote", RETRO_DEVICE_WIIMOTE},
572+
{"WiiMote (upright)", RETRO_DEVICE_WIIMOTE},
573573
{"WiiMote (sideways)", RETRO_DEVICE_WIIMOTE_SW},
574574
{"WiiMote + Nunchuk", RETRO_DEVICE_WIIMOTE_NC},
575575
{"WiiMote + Classic Controller", RETRO_DEVICE_WIIMOTE_CC},
@@ -600,7 +600,7 @@ void InitStage2()
600600
else // Both Wii devices and GC controllers listed in ports 1-4, ports 5-8 are unused
601601
{
602602
static struct retro_controller_description wii_and_gc_desc[] = {
603-
{"WiiMote", RETRO_DEVICE_WIIMOTE},
603+
{"WiiMote (upright)", RETRO_DEVICE_WIIMOTE},
604604
{"WiiMote (sideways)", RETRO_DEVICE_WIIMOTE_SW},
605605
{"WiiMote + Nunchuk", RETRO_DEVICE_WIIMOTE_NC},
606606
{"WiiMote + Classic Controller", RETRO_DEVICE_WIIMOTE_CC},
@@ -1054,22 +1054,31 @@ void UpdateWiimoteMappings(const WiimoteUpdateFlags& f, unsigned port, unsigned
10541054
->SetValue(swingAngle); // Swing/Angle
10551055
}
10561056

1057+
ControllerEmu::ControlGroup* wmHotkeys = wm->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Hotkeys);
1058+
10571059
// Sideways toggle
1058-
if (f.sideways)
1060+
if (wmHotkeys && f.sideways)
10591061
{
1060-
ControllerEmu::ControlGroup* wmHotkeys = wm->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Hotkeys);
10611062
std::string sidewaysToggle =
10621063
Libretro::Options::GetCached<std::string>(Libretro::Options::wiimote::HOTKEY_SIDEWAYS_TOGGLE);
10631064

10641065
wmHotkeys->SetControlExpression(0,
10651066
sidewaysToggle != MODIFIER_DISABLED_CONTROL ? sidewaysToggle : ""); // Sideways Toggle (L3 default)
1067+
}
10661068

1069+
// Upright toggle
1070+
if (wmHotkeys && f.upright)
1071+
{
1072+
std::string uprightToggle =
1073+
Libretro::Options::GetCached<std::string>(Libretro::Options::wiimote::HOTKEY_UPRIGHT_TOGGLE);
1074+
1075+
wmHotkeys->SetControlExpression(1,
1076+
uprightToggle != MODIFIER_DISABLED_CONTROL ? uprightToggle : ""); // Upright Toggle
1077+
}
10671078
#if 0
1068-
wmHotkeys->SetControlExpression(1, ""); // Upright Toggle
10691079
wmHotkeys->SetControlExpression(2, ""); // Sideways Hold
10701080
wmHotkeys->SetControlExpression(3, ""); // Upright Hold
10711081
#endif
1072-
}
10731082

10741083
// Rumble
10751084
if (f.rumble)
@@ -1231,6 +1240,7 @@ void refresh_all_wiimote_flags(unsigned port, unsigned device)
12311240
{
12321241
WiimoteUpdateFlags f;
12331242
f.sideways = true;
1243+
f.upright = true;
12341244
f.irModifier = true;
12351245
f.swingModifier = true;
12361246
f.irMode = true;
@@ -1623,6 +1633,7 @@ void retro_set_controller_port_device_wii(unsigned port, unsigned device)
16231633
f.irModifier = true;
16241634
f.swingModifier = true;
16251635
f.sideways = true;
1636+
f.upright = true;
16261637
// Raised at setup so the option applies on a cold boot.
16271638
f.irPassthrough = true;
16281639
Libretro::Input::UpdateWiimoteMappings(f, port, device);

Source/Core/DolphinLibretro/Input.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct WiimoteUpdateFlags
1616
bool irModifier = false;
1717
bool swingModifier = false;
1818
bool swingAngle = false;
19-
bool sideways = false;
19+
bool sideways = false; // hotkey
20+
bool upright = false; // hotkey
2021
bool rumble = false;
2122
bool gcMicBtn = false;
2223
bool irPassthrough = false;

Source/Core/DolphinLibretro/Main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ void retro_run(void)
389389
flags.swingModifier = Libretro::Options::IsUpdated(Libretro::Options::wiimote::SWING_MODIFIER);
390390
flags.swingAngle = Libretro::Options::IsUpdated(Libretro::Options::wiimote::SWING_ANGLE);
391391
flags.sideways = Libretro::Options::IsUpdated(Libretro::Options::wiimote::HOTKEY_SIDEWAYS_TOGGLE);
392+
flags.upright = Libretro::Options::IsUpdated(Libretro::Options::wiimote::HOTKEY_UPRIGHT_TOGGLE);
392393
flags.irPassthrough = Libretro::Options::IsUpdated(Libretro::Options::wiimote::IR_PASSTHROUGH);
393394
}
394395

0 commit comments

Comments
 (0)