segatools-configurator/games/io.cpp
2024-04-14 17:37:36 +07:00

191 lines
5.5 KiB
C++

//
// Created by beerpsi on 4/14/2024.
//
#include <unordered_map>
#include <windows.h>
#include "io.h"
#include "chuni/io.h"
#include "chusan/io.h"
#include "mai2/io.h"
#include "mercury/io.h"
#include "mu3/io.h"
namespace games {
static bool IO_INITIALIZED = false;
static std::vector<std::string> games;
static std::unordered_map<std::string, HWFamily> hw_family;
static std::unordered_map<std::string, std::vector<Button>> buttons;
static std::unordered_map<std::string, std::vector<std::string>> file_hints;
static void initialize() {
if (IO_INITIALIZED) {
return;
}
const std::string chuni("CHUNITHM");
games.push_back(chuni);
hw_family.insert({ chuni, HW_FAMILY_AMEX });
buttons.insert({ chuni, chuni::get_buttons() });
file_hints[chuni].emplace_back("chuniApp.exe");
const std::string chusan("CHUNITHM NEW!!");
games.push_back(chusan);
hw_family.insert({ chusan, HW_FAMILY_ALLS });
buttons.insert({ chusan, chusan::get_buttons() });
file_hints[chusan].emplace_back("chusanApp.exe");
const std::string mai2("maimai DX");
games.push_back(mai2);
hw_family.insert({ mai2, HW_FAMILY_ALLS });
buttons.insert({ mai2, mai2::get_buttons() });
file_hints[mai2].emplace_back("Sinmai.exe");
const std::string mu3("O.N.G.E.K.I.");
games.push_back(mu3);
hw_family.insert({ mu3, HW_FAMILY_ALLS });
buttons.insert({ mu3, mu3::get_buttons() });
file_hints[mu3].emplace_back("mu3.exe");
const std::string mercury("WACCA");
games.push_back(mercury);
hw_family.insert({ mercury, HW_FAMILY_ALLS });
buttons.insert({ mercury, mercury::get_buttons() });
file_hints[mercury].emplace_back("../WindowsNoEditor/Mercury/Binaries/Win64/Mercury-Win64-Shipping.exe");
IO_INITIALIZED = true;
}
const std::vector<std::string> &get_games() {
initialize();
return games;
}
HWFamily get_hw_family(const std::string &game) {
initialize();
auto it = hw_family.find(game);
if (it == hw_family.end()) {
return HW_FAMILY_UNKNOWN;
}
return it->second;
}
std::vector<Button> *get_buttons(const std::string &game) {
initialize();
auto it = buttons.find(game);
if (it == buttons.end()) {
return nullptr;
}
return &it->second;
}
std::vector<Button> &get_sw_buttons(const std::string &game) {
auto it = hw_family.find(game);
static std::vector<Button> io3_alls_buttons;
static std::vector<Button> io4_alls_buttons;
static std::vector<Button> placeholder;
if (it == hw_family.end()) {
return placeholder;
}
if (it->second == HW_FAMILY_AMEX || game == "CHUNITHM NEW!!") {
if (!io3_alls_buttons.empty()) {
return io3_alls_buttons;
}
io3_alls_buttons.emplace_back(
"Test",
"io3",
"test",
VK_F1,
GetPrivateProfileIntA("io3", "test", VK_F1, ".\\segatools.ini")
);
io3_alls_buttons.emplace_back(
"Service",
"io3",
"service",
VK_F2,
GetPrivateProfileIntA("io3", "service", VK_F2, ".\\segatools.ini")
);
io3_alls_buttons.emplace_back(
"Coin",
"io3",
"coin",
VK_F3,
GetPrivateProfileIntA("io3", "coin", VK_F3, ".\\segatools.ini")
);
io3_alls_buttons.emplace_back(
"Scan Aime card",
"aime",
"scan",
VK_RETURN,
GetPrivateProfileIntA("aime", "scan", VK_RETURN, ".\\segatools.ini")
);
return io3_alls_buttons;
}
if (it->second == HW_FAMILY_ALLS) {
if (!io4_alls_buttons.empty()) {
return io4_alls_buttons;
}
io4_alls_buttons.emplace_back(
"Test",
"io4",
"test",
VK_F1,
GetPrivateProfileIntA("io4", "test", VK_F1, ".\\segatools.ini")
);
io4_alls_buttons.emplace_back(
"Service",
"io4",
"service",
VK_F2,
GetPrivateProfileIntA("io4", "service", VK_F2, ".\\segatools.ini")
);
io4_alls_buttons.emplace_back(
"Coin",
"io4",
"coin",
VK_F3,
GetPrivateProfileIntA("io4", "coin", VK_F3, ".\\segatools.ini")
);
io4_alls_buttons.emplace_back(
"Scan Aime card",
"aime",
"scan",
VK_RETURN,
GetPrivateProfileIntA("aime", "scan", VK_RETURN, ".\\segatools.ini")
);
return io4_alls_buttons;
}
return placeholder;
}
std::vector<std::string> *get_game_file_hints(const std::string &game) {
initialize();
auto it = file_hints.find(game);
if (it == file_hints.end()) {
return nullptr;
}
return &it->second;
}
}