Skip to content

Commit f292143

Browse files
committed
libretro: triforce support
1 parent be058fd commit f292143

7 files changed

Lines changed: 75 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,12 @@ if(LIBRETRO)
505505
if(APPLE)
506506
set(MACOS_CODE_SIGNING OFF CACHE BOOL "" FORCE)
507507
set(USE_BUNDLED_MOLTENVK OFF CACHE BOOL "" FORCE)
508+
set(USE_SYSTEM_CURL OFF CACHE BOOL "" FORCE)
508509
set(USE_SYSTEM_GLSLANG OFF CACHE BOOL "" FORCE)
509510
set(USE_SYSTEM_LZ4 OFF CACHE BOOL "" FORCE)
510511
set(USE_SYSTEM_LIBLZMA OFF CACHE BOOL "" FORCE)
511512
set(USE_SYSTEM_LZO OFF CACHE BOOL "" FORCE)
513+
set(USE_SYSTEM_MINIZIP_NG OFF CACHE BOOL "" FORCE)
512514
set(USE_SYSTEM_ZSTD OFF CACHE BOOL "" FORCE)
513515
set(USE_SYSTEM_ZLIB OFF CACHE BOOL "" FORCE)
514516
endif()

Source/Core/Core/BootManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ bool BootCore(Core::System& system, std::unique_ptr<BootParameters> boot,
205205
case DiscIO::Region::PAL:
206206
ipl_path = EUR_DIR DIR_SEP GC_IPL;
207207
break;
208+
case DiscIO::Region::DEV:
209+
ipl_path = DEV_DIR DIR_SEP GC_IPL;
208210
default:
209211
break;
210212
}
@@ -242,6 +244,7 @@ bool BootCore(Core::System& system, std::unique_ptr<BootParameters> boot,
242244
std::move(boot->boot_session_data)),
243245
wsi);
244246
}
247+
245248
return Core::Init(system, std::move(boot), wsi);
246249
}
247250

Source/Core/DolphinLibretro/Boot.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Core/ConfigManager.h"
1616
#include "Core/Core.h"
1717
#include "Core/HW/DVD/DVDInterface.h"
18+
#include "Core/HW/EXI/EXI_Device.h"
1819
#include "Core/HW/VideoInterface.h"
1920
#include "Core/HW/WiimoteReal/WiimoteReal.h"
2021
#include "Core/PowerPC/PowerPC.h"
@@ -199,6 +200,20 @@ bool retro_load_game(const struct retro_game_info* game)
199200
Config::SetBase(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED,
200201
Libretro::GetOption<bool>(Libretro::Options::main_bluetooth::BLUETOOTH_PASSTHROUGH, /*def=*/false));
201202

203+
// SYSCONF (GC)
204+
{
205+
const std::string value =
206+
Libretro::GetOption<std::string>(
207+
sysconf_gc::SP1_DEVICE,
208+
"255" // ExpansionInterface::EXIDeviceType::None
209+
);
210+
211+
const int device_int = std::stoi(value);
212+
const auto device = static_cast<ExpansionInterface::EXIDeviceType>(device_int);
213+
214+
Config::SetBase(Config::MAIN_SERIAL_PORT_1, device);
215+
}
216+
202217
// SYSCONF.IPL
203218
Config::SetBase(Config::SYSCONF_WIDESCREEN,
204219
Libretro::GetOption<bool>(sysconf::WIDESCREEN, /*def=*/true));

Source/Core/DolphinLibretro/Common/Options.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ static std::unordered_map<std::string, bool> optionDirty;
1414
static constexpr const char* CATEGORY_CORE = "core";
1515
static constexpr const char* CATEGORY_AUDIO = "audio";
1616
static constexpr const char* CATEGORY_INTERFACE = "interface";
17+
static constexpr const char* CATEGORY_GC = "sysconf_gc";
1718
static constexpr const char* CATEGORY_SYSCONF = "sysconf";
1819
static constexpr const char* CATEGORY_GFX_HARDWARE = "graphics_hardware";
1920
static constexpr const char* CATEGORY_GFX_SETTINGS = "graphics_settings";
@@ -38,9 +39,14 @@ static const struct retro_core_option_v2_category option_cats[] = {
3839
"Interface",
3940
"Configure on-screen display and logging."
4041
},
42+
{
43+
CATEGORY_GC,
44+
"System Configuration - Gamecube",
45+
"Configure Gamecube system settings."
46+
},
4147
{
4248
CATEGORY_SYSCONF,
43-
"System Configuration",
49+
"System Configuration - Wii",
4450
"Configure Wii system settings."
4551
},
4652
{
@@ -412,6 +418,31 @@ static struct retro_core_option_v2_definition option_defs[] = {
412418
"0"
413419
},
414420

421+
// ========== SYSCONF (GC) ==========
422+
{
423+
Libretro::Options::sysconf_gc::SP1_DEVICE,
424+
"System Configuration (GC) > SP1 Device",
425+
"SP1 Device",
426+
"Select the device connected to the GameCube SP1 slot.",
427+
nullptr,
428+
CATEGORY_GC,
429+
{
430+
{ "255", "None" }, // EXIDeviceType::None
431+
{ "0", "Dummy" }, // EXIDeviceType::Dummy
432+
{ "5", "Ethernet" }, // EXIDeviceType::Ethernet
433+
{ "10", "Ethernet XLink" }, // EXIDeviceType::EthernetXLink
434+
{ "11", "Ethernet TapServer" },// EXIDeviceType::EthernetTapServer
435+
{ "12", "Ethernet Built-In" }, // EXIDeviceType::EthernetBuiltIn
436+
#ifdef HAVE_CPPIPC
437+
{ "14", "Ethernet IPC" }, // EXIDeviceType::EthernetIPC
438+
#endif
439+
{ "13", "Modem TapServer" }, // EXIDeviceType::ModemTapServer
440+
{ "6", "Baseboard" }, // EXIDeviceType::Baseboard
441+
{ nullptr, nullptr }
442+
},
443+
"255" // default: None
444+
},
445+
415446
// ========== SYSCONF.IPL ==========
416447
{
417448
Libretro::Options::sysconf::WIDESCREEN,

Source/Core/DolphinLibretro/Common/Options.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ namespace main_bluetooth {
158158
} // namespace bluetooth
159159

160160
// ======================================================
161-
// System Configuration (SYSCONF)
161+
// System Configuration (SYSCONF) - GC
162+
// ======================================================
163+
namespace sysconf_gc {
164+
constexpr const char SP1_DEVICE[] = "dolphin_gc_sp1";
165+
}
166+
167+
// ======================================================
168+
// System Configuration (SYSCONF) - Wii
162169
// ======================================================
163170
namespace sysconf {
164171
constexpr const char WIDESCREEN[] = "dolphin_widescreen";

Source/Core/DolphinLibretro/Input.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static struct retro_input_descriptor descGC[] = {
7575
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L-Analog"},
7676
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R-Analog"},
7777
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z"},
78+
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Triforce - Test"},
79+
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Triforce - Coin"},
7880
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start"},
7981
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X,
8082
"Control Stick X"},
@@ -727,7 +729,10 @@ void retro_set_controller_port_device_gc(unsigned port, unsigned device)
727729
if (device == RETRO_DEVICE_GC_ON_WII) // Disconnect Wii device if we're using GC controller as device type to avoid conflict
728730
WiimoteCommon::OnSourceChanged(port, WiimoteSource::None);
729731

730-
Config::SetBaseOrCurrent(Config::GetInfoForSIDevice(port > 3 ? port - 4 : port), SerialInterface::SIDEVICE_GC_CONTROLLER);
732+
Core::System& system = Core::System::GetInstance();
733+
734+
Config::SetBaseOrCurrent(Config::GetInfoForSIDevice(port > 3 ? port - 4 : port),
735+
system.IsTriforce() ? SerialInterface::SIDEVICE_AM_BASEBOARD : SerialInterface::SIDEVICE_GC_CONTROLLER);
731736
si.ChangeDevice(Config::Get(Config::GetInfoForSIDevice(port > 3 ? port - 4 : port)), port > 3 ? port - 4 : port);
732737

733738
GCPad* gcPad = (GCPad*)Pad::GetConfig()->GetController(port > 3 ? port - 4 : port);
@@ -743,6 +748,7 @@ void retro_set_controller_port_device_gc(unsigned port, unsigned device)
743748
ControllerEmu::ControlGroup* gcTriggers = gcPad->GetGroup(PadGroup::Triggers);
744749
ControllerEmu::ControlGroup* gcRumble = gcPad->GetGroup(PadGroup::Rumble);
745750
ControllerEmu::ControlGroup* gcOptions = gcPad->GetGroup(PadGroup::Options);
751+
ControllerEmu::ControlGroup* gcTriforce = gcPad->GetGroup(PadGroup::Triforce);
746752
#if 0
747753
ControllerEmu::ControlGroup* gcMic = gcPad->GetGroup(PadGroup::Mic);
748754
#endif
@@ -772,6 +778,10 @@ void retro_set_controller_port_device_gc(unsigned port, unsigned device)
772778
"`" + devAnalog + ":Trigger0+`|L3"); // L-trigger Soft Press
773779
gcTriggers->SetControlExpression(3,
774780
"`" + devAnalog + ":Trigger1+`|R3"); // R-trigger Soft Press
781+
gcTriforce->SetControlExpression(0, "L"); // Test
782+
gcTriforce->SetControlExpression(1, "`" + devAnalog + ":Trigger0+`&`" + devAnalog + ":Trigger1+`"); // Service
783+
gcTriforce->SetControlExpression(2, "Select"); // Coin
784+
775785
bool enableRumble = Libretro::Options::GetCached<bool>(Libretro::Options::sysconf::ENABLE_RUMBLE);
776786
if (enableRumble)
777787
gcRumble->SetControlExpression(0, "Rumble");

Source/Core/DolphinLibretro/Main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ bool retro_unserialize(const void* data, size_t size)
333333

334334
unsigned retro_get_region(void)
335335
{
336+
Core::System& system = Core::System::GetInstance();
337+
336338
if (DiscIO::IsNTSC(SConfig::GetInstance().m_region) ||
337-
(Core::System::GetInstance().IsWii() && Config::Get(Config::SYSCONF_PAL60)))
339+
(Core::System::GetInstance().IsWii() && Config::Get(Config::SYSCONF_PAL60)) ||
340+
system.IsTriforce())
338341
return RETRO_REGION_NTSC;
339342

340343
return RETRO_REGION_PAL;

0 commit comments

Comments
 (0)