diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2026-10-17 01:09:18 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2026-10-17 01:09:18 -0600 |
| commit | de4241861633949f2e80566cefd789defbc162c5 (patch) | |
| tree | ad8414d3dc4dfe204021a1b2abbbdae12d3183be /src/input/InputSource.cpp | |
| parent | 72960ca16f4723f96aaf4037b76072c230af8c11 (diff) | |
Added gamecube support
Diffstat (limited to 'src/input/InputSource.cpp')
| -rw-r--r-- | src/input/InputSource.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 <fstream> +#include <stdexcept> + +#ifdef GAMECUBE_SUPPORT +#include "gc/GameCubeInput.h" +#endif + +std::shared_ptr<InputSource> InputSource::Create(const std::optional<std::filesystem::path>& path, + std::vector<uint8_t>& 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<uint8_t>(std::istreambuf_iterator(input), {}); + input.close(); + } + + return std::make_shared<N64RomInput>(std::move(data)); +} |
