From de4241861633949f2e80566cefd789defbc162c5 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 17 Oct 2026 01:09:18 -0600 Subject: Added gamecube support --- src/input/InputSource.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/input/InputSource.cpp (limited to 'src/input/InputSource.cpp') diff --git a/src/input/InputSource.cpp b/src/input/InputSource.cpp new file mode 100644 index 0000000..73b79ec --- /dev/null +++ b/src/input/InputSource.cpp @@ -0,0 +1,34 @@ +#include "InputSource.h" +#include "N64RomInput.h" + +#include +#include + +#ifdef GAMECUBE_SUPPORT +#include "gc/GameCubeInput.h" +#endif + +std::shared_ptr InputSource::Create(const std::optional& path, + std::vector& data) { +#ifdef GAMECUBE_SUPPORT + if (path.has_value()) { + if (auto gc = GC::GameCubeInput::FromPath(path.value())) { + return gc; + } + } else if (auto gc = GC::GameCubeInput::FromMemory(data)) { + return gc; + } +#endif + + if (path.has_value()) { + std::error_code ec; + if (std::filesystem::is_directory(path.value(), ec)) { + throw std::runtime_error(path->string() + " is a directory, not a ROM or an extracted GameCube disc"); + } + std::ifstream input(path.value(), std::ios::binary); + data = std::vector(std::istreambuf_iterator(input), {}); + input.close(); + } + + return std::make_shared(std::move(data)); +} -- cgit v1.2.3