mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-17 11:43:19 +00:00
input: add emulated_pad_config template class
This commit is contained in:
parent
36831a3d6a
commit
4d26170bd6
@ -393,6 +393,7 @@ target_sources(rpcs3_emu PRIVATE
|
||||
Io/pad_config.cpp
|
||||
Io/pad_config_types.cpp
|
||||
Io/PadHandler.cpp
|
||||
Io/pad_types.cpp
|
||||
Io/usb_device.cpp
|
||||
Io/usb_vfs.cpp
|
||||
Io/Infinity.cpp
|
||||
|
@ -1,78 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "buzz_config.h"
|
||||
|
||||
LOG_CHANNEL(buzz_log, "BUZZ");
|
||||
|
||||
std::optional<buzz_btn> cfg_buzzer::find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool cfg_buzz::load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/buzz.yml";
|
||||
buzz_log.notice("Loading buzz config: %s", cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (cfg_buzzer* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (cfg_buzzer* player : players)
|
||||
{
|
||||
const auto set_button = [&player](pad_button pbtn, buzz_btn bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
player->buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
};
|
||||
set_button(player->red, buzz_btn::red);
|
||||
set_button(player->yellow, buzz_btn::yellow);
|
||||
set_button(player->green, buzz_btn::green);
|
||||
set_button(player->orange, buzz_btn::orange);
|
||||
set_button(player->blue, buzz_btn::blue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cfg_buzz::save() const
|
||||
{
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/buzz.yml";
|
||||
buzz_log.notice("Saving buzz config to '%s'", cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
buzz_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
buzz_log.error("Failed to save buzz config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
#include "emulated_pad_config.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -14,32 +13,18 @@ enum class buzz_btn
|
||||
blue
|
||||
};
|
||||
|
||||
struct cfg_buzzer final : cfg::node
|
||||
struct cfg_buzzer final : public emulated_pad_config<buzz_btn>
|
||||
{
|
||||
cfg_buzzer(node* owner, const std::string& name) : cfg::node(owner, name) {}
|
||||
cfg_buzzer(node* owner, const std::string& name) : emulated_pad_config(owner, name) {}
|
||||
|
||||
cfg::_enum<pad_button> red{ this, "Red", pad_button::R1 };
|
||||
cfg::_enum<pad_button> yellow{ this, "Yellow", pad_button::cross };
|
||||
cfg::_enum<pad_button> green{ this, "Green", pad_button::circle };
|
||||
cfg::_enum<pad_button> orange{ this, "Orange", pad_button::square };
|
||||
cfg::_enum<pad_button> blue{ this, "Blue", pad_button::triangle };
|
||||
|
||||
std::map<u32, std::map<u32, buzz_btn>> buttons;
|
||||
std::optional<buzz_btn> find_button(u32 offset, u32 keycode) const;
|
||||
cfg_pad_btn<buzz_btn> red{ this, "Red", buzz_btn::red, pad_button::R1 };
|
||||
cfg_pad_btn<buzz_btn> yellow{ this, "Yellow", buzz_btn::yellow, pad_button::cross };
|
||||
cfg_pad_btn<buzz_btn> green{ this, "Green", buzz_btn::green, pad_button::circle };
|
||||
cfg_pad_btn<buzz_btn> orange{ this, "Orange", buzz_btn::orange, pad_button::square };
|
||||
cfg_pad_btn<buzz_btn> blue{ this, "Blue", buzz_btn::blue, pad_button::triangle };
|
||||
};
|
||||
|
||||
struct cfg_buzz final : cfg::node
|
||||
struct cfg_buzz final : public emulated_pads_config<cfg_buzzer>
|
||||
{
|
||||
cfg_buzzer player1{ this, "Player 1" };
|
||||
cfg_buzzer player2{ this, "Player 2" };
|
||||
cfg_buzzer player3{ this, "Player 3" };
|
||||
cfg_buzzer player4{ this, "Player 4" };
|
||||
cfg_buzzer player5{ this, "Player 5" };
|
||||
cfg_buzzer player6{ this, "Player 6" };
|
||||
cfg_buzzer player7{ this, "Player 7" };
|
||||
|
||||
std::array<cfg_buzzer*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load();
|
||||
void save() const;
|
||||
cfg_buzz() : emulated_pads_config<cfg_buzzer>("buzz") {};
|
||||
};
|
||||
|
134
rpcs3/Emu/Io/emulated_pad_config.h
Normal file
134
rpcs3/Emu/Io/emulated_pad_config.h
Normal file
@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
LOG_CHANNEL(cfg_log, "CFG");
|
||||
|
||||
template <typename T>
|
||||
class cfg_pad_btn : public cfg::_enum<pad_button>
|
||||
{
|
||||
public:
|
||||
cfg_pad_btn(cfg::node* owner, const std::string& name, T id, pad_button value, bool dynamic = false)
|
||||
: cfg::_enum<pad_button>(owner, name, value, dynamic)
|
||||
, m_btn_id(id)
|
||||
{};
|
||||
|
||||
T btn_id() const
|
||||
{
|
||||
return m_btn_id;
|
||||
}
|
||||
|
||||
private:
|
||||
T m_btn_id;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct emulated_pad_config : cfg::node
|
||||
{
|
||||
using cfg::node::node;
|
||||
|
||||
std::map<u32, std::map<u32, T>> buttons;
|
||||
|
||||
std::optional<T> find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void set_button(const cfg_pad_btn<T>& pbtn, T bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
}
|
||||
|
||||
void set_buttons()
|
||||
{
|
||||
for (const auto& n : get_nodes())
|
||||
{
|
||||
const auto& node = static_cast<cfg_pad_btn<T>*>(n);
|
||||
set_button(*node, node->btn_id());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct emulated_pads_config : cfg::node
|
||||
{
|
||||
emulated_pads_config(std::string id) : cfg_id(std::move(id)) {}
|
||||
|
||||
std::string cfg_id;
|
||||
|
||||
T player1{ this, "Player 1" };
|
||||
T player2{ this, "Player 2" };
|
||||
T player3{ this, "Player 3" };
|
||||
T player4{ this, "Player 4" };
|
||||
T player5{ this, "Player 5" };
|
||||
T player6{ this, "Player 6" };
|
||||
T player7{ this, "Player 7" };
|
||||
|
||||
std::array<T*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fmt::format("%sconfig/%s.yml", fs::get_config_dir(), cfg_id);
|
||||
cfg_log.notice("Loading %s config: %s", cfg_id, cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (T* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (T* player : players)
|
||||
{
|
||||
player->set_buttons();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void save() const
|
||||
{
|
||||
const std::string cfg_name = fmt::format("%sconfig/%s.yml", fs::get_config_dir(), cfg_id);
|
||||
cfg_log.notice("Saving %s config to '%s'", cfg_id, cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
cfg_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
cfg_log.error("Failed to save %s config to '%s' (error=%s)", cfg_id, cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
||||
};
|
@ -1,81 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "gem_config.h"
|
||||
|
||||
LOG_CHANNEL(cellGem);
|
||||
|
||||
std::optional<gem_btn> cfg_gem::find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool cfg_gems::load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/gem.yml";
|
||||
cellGem.notice("Loading gem config: %s", cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (cfg_gem* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (cfg_gem* player : players)
|
||||
{
|
||||
const auto set_button = [&player](pad_button pbtn, gem_btn bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
player->buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
};
|
||||
set_button(player->start, gem_btn::start);
|
||||
set_button(player->select, gem_btn::select);
|
||||
set_button(player->triangle, gem_btn::triangle);
|
||||
set_button(player->circle, gem_btn::circle);
|
||||
set_button(player->cross, gem_btn::cross);
|
||||
set_button(player->square, gem_btn::square);
|
||||
set_button(player->move, gem_btn::move);
|
||||
set_button(player->t, gem_btn::t);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cfg_gems::save() const
|
||||
{
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/gem.yml";
|
||||
cellGem.notice("Saving gem config to '%s'", cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
cellGem.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
cellGem.error("Failed to save gem config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
#include "emulated_pad_config.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -17,35 +16,21 @@ enum class gem_btn
|
||||
t,
|
||||
};
|
||||
|
||||
struct cfg_gem final : cfg::node
|
||||
struct cfg_gem final : public emulated_pad_config<gem_btn>
|
||||
{
|
||||
cfg_gem(node* owner, const std::string& name) : cfg::node(owner, name) {}
|
||||
cfg_gem(node* owner, const std::string& name) : emulated_pad_config(owner, name) {}
|
||||
|
||||
cfg::_enum<pad_button> start{ this, "Start", pad_button::start };
|
||||
cfg::_enum<pad_button> select{ this, "Select", pad_button::select };
|
||||
cfg::_enum<pad_button> triangle{ this, "Triangle", pad_button::triangle };
|
||||
cfg::_enum<pad_button> circle{ this, "Circle", pad_button::circle };
|
||||
cfg::_enum<pad_button> cross{ this, "Cross", pad_button::cross };
|
||||
cfg::_enum<pad_button> square{ this, "Square", pad_button::square };
|
||||
cfg::_enum<pad_button> move{ this, "Move", pad_button::R1 };
|
||||
cfg::_enum<pad_button> t{ this, "T", pad_button::R2 };
|
||||
|
||||
std::map<u32, std::map<u32, gem_btn>> buttons;
|
||||
std::optional<gem_btn> find_button(u32 offset, u32 keycode) const;
|
||||
cfg_pad_btn<gem_btn> start{ this, "Start", gem_btn::start, pad_button::start };
|
||||
cfg_pad_btn<gem_btn> select{ this, "Select", gem_btn::select, pad_button::select };
|
||||
cfg_pad_btn<gem_btn> triangle{ this, "Triangle", gem_btn::triangle, pad_button::triangle };
|
||||
cfg_pad_btn<gem_btn> circle{ this, "Circle", gem_btn::circle, pad_button::circle };
|
||||
cfg_pad_btn<gem_btn> cross{ this, "Cross", gem_btn::cross, pad_button::cross };
|
||||
cfg_pad_btn<gem_btn> square{ this, "Square", gem_btn::square, pad_button::square };
|
||||
cfg_pad_btn<gem_btn> move{ this, "Move", gem_btn::move, pad_button::R1 };
|
||||
cfg_pad_btn<gem_btn> t{ this, "T", gem_btn::t, pad_button::R2 };
|
||||
};
|
||||
|
||||
struct cfg_gems final : cfg::node
|
||||
struct cfg_gems final : public emulated_pads_config<cfg_gem>
|
||||
{
|
||||
cfg_gem player1{ this, "Player 1" };
|
||||
cfg_gem player2{ this, "Player 2" };
|
||||
cfg_gem player3{ this, "Player 3" };
|
||||
cfg_gem player4{ this, "Player 4" };
|
||||
cfg_gem player5{ this, "Player 5" };
|
||||
cfg_gem player6{ this, "Player 6" };
|
||||
cfg_gem player7{ this, "Player 7" };
|
||||
|
||||
std::array<cfg_gem*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load();
|
||||
void save() const;
|
||||
cfg_gems() : emulated_pads_config<cfg_gem>("gem") {};
|
||||
};
|
||||
|
@ -1,86 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "ghltar_config.h"
|
||||
|
||||
LOG_CHANNEL(ghltar_log, "GHLTAR");
|
||||
|
||||
std::optional<ghltar_btn> cfg_ghltar::find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool cfg_ghltars::load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/ghltar.yml";
|
||||
ghltar_log.notice("Loading ghltar config: %s", cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (cfg_ghltar* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (cfg_ghltar* player : players)
|
||||
{
|
||||
const auto set_button = [&player](pad_button pbtn, ghltar_btn bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
player->buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
};
|
||||
set_button(player->w1, ghltar_btn::w1);
|
||||
set_button(player->w2, ghltar_btn::w2);
|
||||
set_button(player->w3, ghltar_btn::w3);
|
||||
set_button(player->b1, ghltar_btn::b1);
|
||||
set_button(player->b2, ghltar_btn::b2);
|
||||
set_button(player->b3, ghltar_btn::b3);
|
||||
set_button(player->start, ghltar_btn::start);
|
||||
set_button(player->hero_power, ghltar_btn::hero_power);
|
||||
set_button(player->ghtv, ghltar_btn::ghtv);
|
||||
set_button(player->strum_down, ghltar_btn::strum_down);
|
||||
set_button(player->strum_up, ghltar_btn::strum_up);
|
||||
set_button(player->dpad_left, ghltar_btn::dpad_left);
|
||||
set_button(player->dpad_right, ghltar_btn::dpad_right);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cfg_ghltars::save() const
|
||||
{
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/ghltar.yml";
|
||||
ghltar_log.notice("Saving ghltar config to '%s'", cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
ghltar_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
ghltar_log.error("Failed to save ghltar config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
#include "emulated_pad_config.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -22,40 +21,26 @@ enum class ghltar_btn
|
||||
dpad_right
|
||||
};
|
||||
|
||||
struct cfg_ghltar final : cfg::node
|
||||
struct cfg_ghltar final : public emulated_pad_config<ghltar_btn>
|
||||
{
|
||||
cfg_ghltar(node* owner, const std::string& name) : cfg::node(owner, name) {}
|
||||
cfg_ghltar(node* owner, const std::string& name) : emulated_pad_config(owner, name) {}
|
||||
|
||||
cfg::_enum<pad_button> w1{ this, "W1", pad_button::square };
|
||||
cfg::_enum<pad_button> w2{ this, "W2", pad_button::L1 };
|
||||
cfg::_enum<pad_button> w3{ this, "W3", pad_button::R1 };
|
||||
cfg::_enum<pad_button> b1{ this, "B1", pad_button::cross };
|
||||
cfg::_enum<pad_button> b2{ this, "B2", pad_button::circle };
|
||||
cfg::_enum<pad_button> b3{ this, "B3", pad_button::triangle };
|
||||
cfg::_enum<pad_button> start{ this, "Start", pad_button::start };
|
||||
cfg::_enum<pad_button> hero_power{ this, "Hero Power", pad_button::select };
|
||||
cfg::_enum<pad_button> ghtv{ this, "GHTV", pad_button::L3 };
|
||||
cfg::_enum<pad_button> strum_down{ this, "Strum Down", pad_button::dpad_down };
|
||||
cfg::_enum<pad_button> strum_up{ this, "Strum Up", pad_button::dpad_up };
|
||||
cfg::_enum<pad_button> dpad_left{ this, "D-Pad Left", pad_button::dpad_left };
|
||||
cfg::_enum<pad_button> dpad_right{ this, "D-Pad Right", pad_button::dpad_right };
|
||||
|
||||
std::map<u32, std::map<u32, ghltar_btn>> buttons;
|
||||
std::optional<ghltar_btn> find_button(u32 offset, u32 keycode) const;
|
||||
cfg_pad_btn<ghltar_btn> w1{ this, "W1", ghltar_btn::w1, pad_button::square };
|
||||
cfg_pad_btn<ghltar_btn> w2{ this, "W2", ghltar_btn::w2, pad_button::L1 };
|
||||
cfg_pad_btn<ghltar_btn> w3{ this, "W3", ghltar_btn::w3, pad_button::R1 };
|
||||
cfg_pad_btn<ghltar_btn> b1{ this, "B1", ghltar_btn::b1, pad_button::cross };
|
||||
cfg_pad_btn<ghltar_btn> b2{ this, "B2", ghltar_btn::b2, pad_button::circle };
|
||||
cfg_pad_btn<ghltar_btn> b3{ this, "B3", ghltar_btn::b3, pad_button::triangle };
|
||||
cfg_pad_btn<ghltar_btn> start{ this, "Start", ghltar_btn::start, pad_button::start };
|
||||
cfg_pad_btn<ghltar_btn> hero_power{ this, "Hero Power", ghltar_btn::hero_power, pad_button::select };
|
||||
cfg_pad_btn<ghltar_btn> ghtv{ this, "GHTV", ghltar_btn::ghtv, pad_button::L3 };
|
||||
cfg_pad_btn<ghltar_btn> strum_down{ this, "Strum Down", ghltar_btn::strum_down, pad_button::dpad_down };
|
||||
cfg_pad_btn<ghltar_btn> strum_up{ this, "Strum Up", ghltar_btn::strum_up, pad_button::dpad_up };
|
||||
cfg_pad_btn<ghltar_btn> dpad_left{ this, "D-Pad Left", ghltar_btn::dpad_left, pad_button::dpad_left };
|
||||
cfg_pad_btn<ghltar_btn> dpad_right{ this, "D-Pad Right", ghltar_btn::dpad_right, pad_button::dpad_right };
|
||||
};
|
||||
|
||||
struct cfg_ghltars final : cfg::node
|
||||
struct cfg_ghltars final : public emulated_pads_config<cfg_ghltar>
|
||||
{
|
||||
cfg_ghltar player1{ this, "Player 1" };
|
||||
cfg_ghltar player2{ this, "Player 2" };
|
||||
cfg_ghltar player3{ this, "Player 3" };
|
||||
cfg_ghltar player4{ this, "Player 4" };
|
||||
cfg_ghltar player5{ this, "Player 5" };
|
||||
cfg_ghltar player6{ this, "Player 6" };
|
||||
cfg_ghltar player7{ this, "Player 7" };
|
||||
|
||||
std::array<cfg_ghltar*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load();
|
||||
void save() const;
|
||||
cfg_ghltars() : emulated_pads_config<cfg_ghltar>("ghltar") {};
|
||||
};
|
||||
|
@ -1,86 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "turntable_config.h"
|
||||
|
||||
LOG_CHANNEL(turntable_log, "TURN");
|
||||
|
||||
std::optional<turntable_btn> cfg_turntable::find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool cfg_turntables::load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/turntable.yml";
|
||||
turntable_log.notice("Loading turntable config: %s", cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (cfg_turntable* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (cfg_turntable* player : players)
|
||||
{
|
||||
const auto set_button = [&player](pad_button pbtn, turntable_btn bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
player->buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
};
|
||||
set_button(player->red, turntable_btn::red);
|
||||
set_button(player->green, turntable_btn::green);
|
||||
set_button(player->blue, turntable_btn::blue);
|
||||
set_button(player->dpad_up, turntable_btn::dpad_up);
|
||||
set_button(player->dpad_down, turntable_btn::dpad_down);
|
||||
set_button(player->dpad_left, turntable_btn::dpad_left);
|
||||
set_button(player->dpad_right, turntable_btn::dpad_right);
|
||||
set_button(player->start, turntable_btn::start);
|
||||
set_button(player->select, turntable_btn::select);
|
||||
set_button(player->square, turntable_btn::square);
|
||||
set_button(player->circle, turntable_btn::circle);
|
||||
set_button(player->cross, turntable_btn::cross);
|
||||
set_button(player->triangle, turntable_btn::triangle);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cfg_turntables::save() const
|
||||
{
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/turntable.yml";
|
||||
turntable_log.notice("Saving turntable config to '%s'", cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
turntable_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
turntable_log.error("Failed to save turntable config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
#include "emulated_pad_config.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -22,40 +21,26 @@ enum class turntable_btn
|
||||
triangle
|
||||
};
|
||||
|
||||
struct cfg_turntable final : cfg::node
|
||||
struct cfg_turntable final : public emulated_pad_config<turntable_btn>
|
||||
{
|
||||
cfg_turntable(node* owner, const std::string& name) : cfg::node(owner, name) {}
|
||||
cfg_turntable(node* owner, const std::string& name) : emulated_pad_config(owner, name) {}
|
||||
|
||||
cfg::_enum<pad_button> blue{ this, "Blue", pad_button::square };
|
||||
cfg::_enum<pad_button> green{ this, "Green", pad_button::cross };
|
||||
cfg::_enum<pad_button> red{ this, "Red", pad_button::circle };
|
||||
cfg::_enum<pad_button> dpad_up{ this, "D-Pad Up", pad_button::dpad_up };
|
||||
cfg::_enum<pad_button> dpad_down{ this, "D-Pad Down", pad_button::dpad_down };
|
||||
cfg::_enum<pad_button> dpad_left{ this, "D-Pad Left", pad_button::dpad_left };
|
||||
cfg::_enum<pad_button> dpad_right{ this, "D-Pad Right", pad_button::dpad_right };
|
||||
cfg::_enum<pad_button> start{ this, "Start", pad_button::start };
|
||||
cfg::_enum<pad_button> select{ this, "Select", pad_button::select };
|
||||
cfg::_enum<pad_button> square{ this, "Square", pad_button::R2 };
|
||||
cfg::_enum<pad_button> circle{ this, "Circle", pad_button::L1 };
|
||||
cfg::_enum<pad_button> cross{ this, "Cross", pad_button::R1 };
|
||||
cfg::_enum<pad_button> triangle{ this, "Triangle", pad_button::triangle };
|
||||
|
||||
std::map<u32, std::map<u32, turntable_btn>> buttons;
|
||||
std::optional<turntable_btn> find_button(u32 offset, u32 keycode) const;
|
||||
cfg_pad_btn<turntable_btn> blue{ this, "Blue", turntable_btn::blue, pad_button::square };
|
||||
cfg_pad_btn<turntable_btn> green{ this, "Green", turntable_btn::green, pad_button::cross };
|
||||
cfg_pad_btn<turntable_btn> red{ this, "Red", turntable_btn::red, pad_button::circle };
|
||||
cfg_pad_btn<turntable_btn> dpad_up{ this, "D-Pad Up", turntable_btn::dpad_up, pad_button::dpad_up };
|
||||
cfg_pad_btn<turntable_btn> dpad_down{ this, "D-Pad Down", turntable_btn::dpad_down, pad_button::dpad_down };
|
||||
cfg_pad_btn<turntable_btn> dpad_left{ this, "D-Pad Left", turntable_btn::dpad_left, pad_button::dpad_left };
|
||||
cfg_pad_btn<turntable_btn> dpad_right{ this, "D-Pad Right", turntable_btn::dpad_right, pad_button::dpad_right };
|
||||
cfg_pad_btn<turntable_btn> start{ this, "Start", turntable_btn::start, pad_button::start };
|
||||
cfg_pad_btn<turntable_btn> select{ this, "Select", turntable_btn::select, pad_button::select };
|
||||
cfg_pad_btn<turntable_btn> square{ this, "Square", turntable_btn::square, pad_button::R2 };
|
||||
cfg_pad_btn<turntable_btn> circle{ this, "Circle", turntable_btn::circle, pad_button::L1 };
|
||||
cfg_pad_btn<turntable_btn> cross{ this, "Cross", turntable_btn::cross, pad_button::R1 };
|
||||
cfg_pad_btn<turntable_btn> triangle{ this, "Triangle", turntable_btn::triangle, pad_button::triangle };
|
||||
};
|
||||
|
||||
struct cfg_turntables final : cfg::node
|
||||
struct cfg_turntables final : public emulated_pads_config<cfg_turntable>
|
||||
{
|
||||
cfg_turntable player1{ this, "Player 1" };
|
||||
cfg_turntable player2{ this, "Player 2" };
|
||||
cfg_turntable player3{ this, "Player 3" };
|
||||
cfg_turntable player4{ this, "Player 4" };
|
||||
cfg_turntable player5{ this, "Player 5" };
|
||||
cfg_turntable player6{ this, "Player 6" };
|
||||
cfg_turntable player7{ this, "Player 7" };
|
||||
|
||||
std::array<cfg_turntable*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load();
|
||||
void save() const;
|
||||
cfg_turntables() : emulated_pads_config<cfg_turntable>("turntable") {};
|
||||
};
|
||||
|
@ -1,87 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "usio_config.h"
|
||||
|
||||
LOG_CHANNEL(usio_log, "USIO");
|
||||
|
||||
std::optional<usio_btn> cfg_usio::find_button(u32 offset, u32 keycode) const
|
||||
{
|
||||
if (const auto it = buttons.find(offset); it != buttons.cend())
|
||||
{
|
||||
if (const auto it2 = it->second.find(keycode); it2 != it->second.cend())
|
||||
{
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool cfg_usios::load()
|
||||
{
|
||||
bool result = false;
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/usio.yml";
|
||||
usio_log.notice("Loading usio config: %s", cfg_name);
|
||||
|
||||
from_default();
|
||||
|
||||
for (cfg_usio* player : players)
|
||||
{
|
||||
player->buttons.clear();
|
||||
}
|
||||
|
||||
if (fs::file cfg_file{ cfg_name, fs::read })
|
||||
{
|
||||
if (std::string content = cfg_file.to_string(); !content.empty())
|
||||
{
|
||||
result = from_string(content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
for (cfg_usio* player : players)
|
||||
{
|
||||
const auto set_button = [&player](pad_button pbtn, usio_btn bbtn)
|
||||
{
|
||||
const u32 offset = pad_button_offset(pbtn);
|
||||
const u32 keycode = pad_button_keycode(pbtn);
|
||||
player->buttons[(offset >> 8) & 0xFF][keycode & 0xFF] = bbtn;
|
||||
};
|
||||
set_button(player->test, usio_btn::test);
|
||||
set_button(player->coin, usio_btn::coin);
|
||||
set_button(player->enter, usio_btn::enter);
|
||||
set_button(player->up, usio_btn::up);
|
||||
set_button(player->down, usio_btn::down);
|
||||
set_button(player->service, usio_btn::service);
|
||||
set_button(player->strong_hit_side_left, usio_btn::strong_hit_side_left);
|
||||
set_button(player->strong_hit_side_right, usio_btn::strong_hit_side_right);
|
||||
set_button(player->strong_hit_center_left, usio_btn::strong_hit_center_left);
|
||||
set_button(player->strong_hit_center_right, usio_btn::strong_hit_center_right);
|
||||
set_button(player->small_hit_side_left, usio_btn::small_hit_side_left);
|
||||
set_button(player->small_hit_side_right, usio_btn::small_hit_side_right);
|
||||
set_button(player->small_hit_center_left, usio_btn::small_hit_center_left);
|
||||
set_button(player->small_hit_center_right, usio_btn::small_hit_center_right);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void cfg_usios::save() const
|
||||
{
|
||||
const std::string cfg_name = fs::get_config_dir() + "config/usio.yml";
|
||||
usio_log.notice("Saving usio config to '%s'", cfg_name);
|
||||
|
||||
if (!fs::create_path(fs::get_parent_dir(cfg_name)))
|
||||
{
|
||||
usio_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
|
||||
fs::pending_file cfg_file(cfg_name);
|
||||
|
||||
if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
|
||||
{
|
||||
usio_log.error("Failed to save usio config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Config.h"
|
||||
#include "pad_types.h"
|
||||
#include "emulated_pad_config.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -23,41 +22,27 @@ enum class usio_btn
|
||||
small_hit_center_right
|
||||
};
|
||||
|
||||
struct cfg_usio final : cfg::node
|
||||
struct cfg_usio final : public emulated_pad_config<usio_btn>
|
||||
{
|
||||
cfg_usio(node* owner, const std::string& name) : cfg::node(owner, name) {}
|
||||
cfg_usio(node* owner, const std::string& name) : emulated_pad_config(owner, name) {}
|
||||
|
||||
cfg::_enum<pad_button> test{ this, "Test", pad_button::select };
|
||||
cfg::_enum<pad_button> coin{ this, "Coin", pad_button::dpad_left };
|
||||
cfg::_enum<pad_button> enter{ this, "Enter", pad_button::start };
|
||||
cfg::_enum<pad_button> up{ this, "Up", pad_button::dpad_up };
|
||||
cfg::_enum<pad_button> down{ this, "Down", pad_button::dpad_down };
|
||||
cfg::_enum<pad_button> service{ this, "Service", pad_button::dpad_right };
|
||||
cfg::_enum<pad_button> strong_hit_side_left{ this, "Strong Hit Side Left", pad_button::square };
|
||||
cfg::_enum<pad_button> strong_hit_side_right{ this, "Strong Hit Side Right", pad_button::circle };
|
||||
cfg::_enum<pad_button> strong_hit_center_left{ this, "Strong Hit Center Left", pad_button::triangle };
|
||||
cfg::_enum<pad_button> strong_hit_center_right{ this, "Strong Hit Center Right", pad_button::cross };
|
||||
cfg::_enum<pad_button> small_hit_side_left{ this, "Small Hit Side Left", pad_button::L2 };
|
||||
cfg::_enum<pad_button> small_hit_side_right{ this, "Small Hit Side Right", pad_button::R2 };
|
||||
cfg::_enum<pad_button> small_hit_center_left{ this, "Small Hit Center Left", pad_button::L1 };
|
||||
cfg::_enum<pad_button> small_hit_center_right{ this, "Small Hit Center Right", pad_button::R1 };
|
||||
|
||||
std::map<u32, std::map<u32, usio_btn>> buttons;
|
||||
std::optional<usio_btn> find_button(u32 offset, u32 keycode) const;
|
||||
cfg_pad_btn<usio_btn> test{ this, "Test", usio_btn::test, pad_button::select };
|
||||
cfg_pad_btn<usio_btn> coin{ this, "Coin", usio_btn::coin, pad_button::dpad_left };
|
||||
cfg_pad_btn<usio_btn> enter{ this, "Enter", usio_btn::enter, pad_button::start };
|
||||
cfg_pad_btn<usio_btn> up{ this, "Up", usio_btn::up, pad_button::dpad_up };
|
||||
cfg_pad_btn<usio_btn> down{ this, "Down", usio_btn::down, pad_button::dpad_down };
|
||||
cfg_pad_btn<usio_btn> service{ this, "Service", usio_btn::service, pad_button::dpad_right };
|
||||
cfg_pad_btn<usio_btn> strong_hit_side_left{ this, "Strong Hit Side Left", usio_btn::strong_hit_side_left, pad_button::square };
|
||||
cfg_pad_btn<usio_btn> strong_hit_side_right{ this, "Strong Hit Side Right", usio_btn::strong_hit_side_right, pad_button::circle };
|
||||
cfg_pad_btn<usio_btn> strong_hit_center_left{ this, "Strong Hit Center Left", usio_btn::strong_hit_center_left, pad_button::triangle };
|
||||
cfg_pad_btn<usio_btn> strong_hit_center_right{ this, "Strong Hit Center Right", usio_btn::strong_hit_center_right, pad_button::cross };
|
||||
cfg_pad_btn<usio_btn> small_hit_side_left{ this, "Small Hit Side Left", usio_btn::small_hit_side_left, pad_button::L2 };
|
||||
cfg_pad_btn<usio_btn> small_hit_side_right{ this, "Small Hit Side Right", usio_btn::small_hit_side_right, pad_button::R2 };
|
||||
cfg_pad_btn<usio_btn> small_hit_center_left{ this, "Small Hit Center Left", usio_btn::small_hit_center_left, pad_button::L1 };
|
||||
cfg_pad_btn<usio_btn> small_hit_center_right{ this, "Small Hit Center Right", usio_btn::small_hit_center_right, pad_button::R1 };
|
||||
};
|
||||
|
||||
struct cfg_usios final : cfg::node
|
||||
struct cfg_usios final : public emulated_pads_config<cfg_usio>
|
||||
{
|
||||
cfg_usio player1{ this, "Player 1" };
|
||||
cfg_usio player2{ this, "Player 2" };
|
||||
cfg_usio player3{ this, "Player 3" };
|
||||
cfg_usio player4{ this, "Player 4" };
|
||||
cfg_usio player5{ this, "Player 5" };
|
||||
cfg_usio player6{ this, "Player 6" };
|
||||
cfg_usio player7{ this, "Player 7" };
|
||||
|
||||
std::array<cfg_usio*, 7> players{ &player1, &player2, &player3, &player4, &player5, &player6, &player7 }; // Thanks gcc!
|
||||
|
||||
bool load();
|
||||
void save() const;
|
||||
cfg_usios() : emulated_pads_config<cfg_usio>("usio") {};
|
||||
};
|
||||
|
@ -68,9 +68,7 @@
|
||||
<ClCompile Include="Emu\Cell\Modules\sys_crashdump.cpp" />
|
||||
<ClCompile Include="Emu\Cell\Modules\HLE_PATCHES.cpp" />
|
||||
<ClCompile Include="Emu\games_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\buzz_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\camera_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\ghltar_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\midi_config_types.cpp" />
|
||||
<ClCompile Include="Emu\Io\pad_types.cpp" />
|
||||
<ClCompile Include="Emu\Io\RB3MidiGuitar.cpp" />
|
||||
@ -79,14 +77,12 @@
|
||||
<ClCompile Include="Emu\Io\Turntable.cpp" />
|
||||
<ClCompile Include="Emu\Io\GHLtar.cpp" />
|
||||
<ClCompile Include="Emu\Io\Buzz.cpp" />
|
||||
<ClCompile Include="Emu\Io\turntable_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\usio.cpp" />
|
||||
<ClCompile Include="Emu\Audio\AudioBackend.cpp" />
|
||||
<ClCompile Include="Emu\Io\interception.cpp" />
|
||||
<ClCompile Include="Emu\Io\KeyboardHandler.cpp" />
|
||||
<ClCompile Include="Emu\Io\pad_config.cpp" />
|
||||
<ClCompile Include="Emu\Io\pad_config_types.cpp" />
|
||||
<ClCompile Include="Emu\Io\usio_config.cpp" />
|
||||
<ClCompile Include="Emu\IPC_config.cpp" />
|
||||
<ClCompile Include="Emu\IPC_socket.cpp" />
|
||||
<ClCompile Include="Emu\localized_string.cpp" />
|
||||
@ -512,6 +508,8 @@
|
||||
<ClInclude Include="Emu\Io\buzz_config.h" />
|
||||
<ClInclude Include="Emu\Io\camera_config.h" />
|
||||
<ClInclude Include="Emu\Io\camera_handler_base.h" />
|
||||
<ClInclude Include="Emu\Io\emulated_pad_config.h" />
|
||||
<ClInclude Include="Emu\Io\gem_config.h" />
|
||||
<ClInclude Include="Emu\Io\ghltar_config.h" />
|
||||
<ClInclude Include="Emu\Io\midi_config_types.h" />
|
||||
<ClInclude Include="Emu\Io\music_handler_base.h" />
|
||||
|
@ -1162,21 +1162,9 @@
|
||||
<ClCompile Include="Emu\Io\midi_config_types.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Io\buzz_config.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Io\pad_types.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Io\turntable_config.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Io\ghltar_config.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Io\usio_config.cpp">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Crypto\aes.h">
|
||||
@ -2371,6 +2359,12 @@
|
||||
<ClInclude Include="Emu\Io\usio_config.h">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Io\gem_config.h">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Io\emulated_pad_config.h">
|
||||
<Filter>Emu\Io</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">
|
||||
|
Loading…
x
Reference in New Issue
Block a user