mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 18:40:36 +00:00
input: use global configs
This commit is contained in:
parent
4d26170bd6
commit
64437a531b
@ -134,6 +134,8 @@ using gun_thread = named_thread<gun_handler>;
|
||||
|
||||
#endif
|
||||
|
||||
cfg_gems g_cfg_gem;
|
||||
|
||||
struct gem_config_data
|
||||
{
|
||||
public:
|
||||
@ -141,7 +143,6 @@ public:
|
||||
|
||||
static constexpr auto thread_name = "Gem Thread"sv;
|
||||
|
||||
cfg_gems gem_cfg;
|
||||
atomic_t<u8> state = 0;
|
||||
|
||||
struct gem_color
|
||||
@ -290,7 +291,7 @@ public:
|
||||
|
||||
gem_config_data()
|
||||
{
|
||||
if (!gem_cfg.load())
|
||||
if (!g_cfg_gem.load())
|
||||
{
|
||||
cellGem.notice("Could not load gem config. Using defaults.");
|
||||
}
|
||||
@ -327,7 +328,7 @@ public:
|
||||
{
|
||||
save(ar);
|
||||
|
||||
if (!ar.is_writing() && !gem_cfg.load())
|
||||
if (!ar.is_writing() && !g_cfg_gem.load())
|
||||
{
|
||||
cellGem.notice("Could not load gem config. Using defaults.");
|
||||
}
|
||||
@ -648,8 +649,7 @@ static void ds3_input_to_pad(const u32 port_no, be_t<u16>& digital_buttons, be_t
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& gem = g_fxo->get<gem_config>();
|
||||
const auto& cfg = ::at32(gem.gem_cfg.players, port_no);
|
||||
const auto& cfg = ::at32(g_cfg_gem.players, port_no);
|
||||
|
||||
for (const Button& button : pad->m_buttons)
|
||||
{
|
||||
|
@ -18,17 +18,26 @@
|
||||
#include "Emu/Io/Skylander.h"
|
||||
#include "Emu/Io/Infinity.h"
|
||||
#include "Emu/Io/GHLtar.h"
|
||||
#include "Emu/Io/ghltar_config.h"
|
||||
#include "Emu/Io/Buzz.h"
|
||||
#include "Emu/Io/buzz_config.h"
|
||||
#include "Emu/Io/Turntable.h"
|
||||
#include "Emu/Io/turntable_config.h"
|
||||
#include "Emu/Io/RB3MidiKeyboard.h"
|
||||
#include "Emu/Io/RB3MidiGuitar.h"
|
||||
#include "Emu/Io/usio.h"
|
||||
#include "Emu/Io/usio_config.h"
|
||||
#include "Emu/Io/midi_config_types.h"
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
LOG_CHANNEL(sys_usbd);
|
||||
|
||||
cfg_buzz g_cfg_buzz;
|
||||
cfg_ghltars g_cfg_ghltar;
|
||||
cfg_turntables g_cfg_turntable;
|
||||
cfg_usios g_cfg_usio;
|
||||
|
||||
template <>
|
||||
void fmt_class_string<libusb_transfer>::format(std::string& out, u64 arg)
|
||||
{
|
||||
@ -314,6 +323,11 @@ usb_handler_thread::usb_handler_thread()
|
||||
|
||||
if (!found_usio && !found_h050) // Only one of these two IO boards should be present at the same time; otherwise, an exception will be thrown by the game.
|
||||
{
|
||||
if (!g_cfg_usio.load())
|
||||
{
|
||||
sys_usbd.notice("Could not load usio config. Using defaults.");
|
||||
}
|
||||
|
||||
sys_usbd.notice("Adding emulated v406 usio");
|
||||
usb_devices.push_back(std::make_shared<usb_device_usio>(get_new_location()));
|
||||
}
|
||||
@ -342,6 +356,11 @@ usb_handler_thread::usb_handler_thread()
|
||||
|
||||
if (g_cfg.io.ghltar == ghltar_handler::one_controller || g_cfg.io.ghltar == ghltar_handler::two_controllers)
|
||||
{
|
||||
if (!g_cfg_ghltar.load())
|
||||
{
|
||||
sys_usbd.notice("Could not load ghltar config. Using defaults.");
|
||||
}
|
||||
|
||||
sys_usbd.notice("Adding emulated GHLtar (1 player)");
|
||||
usb_devices.push_back(std::make_shared<usb_device_ghltar>(0, get_new_location()));
|
||||
}
|
||||
@ -353,6 +372,11 @@ usb_handler_thread::usb_handler_thread()
|
||||
|
||||
if (g_cfg.io.turntable == turntable_handler::one_controller || g_cfg.io.turntable == turntable_handler::two_controllers)
|
||||
{
|
||||
if (!g_cfg_turntable.load())
|
||||
{
|
||||
sys_usbd.notice("Could not load turntable config. Using defaults.");
|
||||
}
|
||||
|
||||
sys_usbd.notice("Adding emulated turntable (1 player)");
|
||||
usb_devices.push_back(std::make_shared<usb_device_turntable>(0, get_new_location()));
|
||||
}
|
||||
@ -364,6 +388,11 @@ usb_handler_thread::usb_handler_thread()
|
||||
|
||||
if (g_cfg.io.buzz == buzz_handler::one_controller || g_cfg.io.buzz == buzz_handler::two_controllers)
|
||||
{
|
||||
if (!g_cfg_buzz.load())
|
||||
{
|
||||
sys_usbd.notice("Could not load buzz config. Using defaults.");
|
||||
}
|
||||
|
||||
sys_usbd.notice("Adding emulated Buzz! buzzer (1-4 players)");
|
||||
usb_devices.push_back(std::make_shared<usb_device_buzz>(0, 3, get_new_location()));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "Buzz.h"
|
||||
#include "Emu/Cell/lv2/sys_usbd.h"
|
||||
#include "Emu/Io/buzz_config.h"
|
||||
#include "Input/pad_thread.h"
|
||||
|
||||
LOG_CHANNEL(buzz_log, "BUZZ");
|
||||
@ -17,11 +18,6 @@ usb_device_buzz::usb_device_buzz(u32 first_controller, u32 last_controller, cons
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_INTERFACE, UsbDeviceInterface{0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_HID, UsbDeviceHID{0x0111, 0x33, 0x01, 0x22, 0x004e}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_ENDPOINT, UsbDeviceEndpoint{0x81, 0x03, 0x0008, 0x0A}));
|
||||
|
||||
if (!m_cfg.load())
|
||||
{
|
||||
buzz_log.notice("Could not load buzz config. Using defaults.");
|
||||
}
|
||||
}
|
||||
|
||||
usb_device_buzz::~usb_device_buzz()
|
||||
@ -77,12 +73,12 @@ void usb_device_buzz::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpoint*/
|
||||
const auto handler = pad::get_current_handler();
|
||||
const auto& pads = handler->GetPads();
|
||||
ensure(pads.size() > m_last_controller);
|
||||
ensure(m_cfg.players.size() > m_last_controller);
|
||||
ensure(g_cfg_buzz.players.size() > m_last_controller);
|
||||
|
||||
for (u32 i = m_first_controller, index = 0; i <= m_last_controller; i++, index++)
|
||||
{
|
||||
const auto& pad = pads[i];
|
||||
const cfg_buzzer* cfg = m_cfg.players[i];
|
||||
const cfg_buzzer* cfg = g_cfg_buzz.players[i];
|
||||
|
||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Emu/Io/usb_device.h"
|
||||
#include "Emu/Io/buzz_config.h"
|
||||
|
||||
class usb_device_buzz : public usb_device_emulated
|
||||
{
|
||||
@ -15,5 +14,4 @@ public:
|
||||
private:
|
||||
u32 m_first_controller;
|
||||
u32 m_last_controller;
|
||||
cfg_buzz m_cfg;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "GHLtar.h"
|
||||
#include "Emu/Cell/lv2/sys_usbd.h"
|
||||
#include "Emu/Io/ghltar_config.h"
|
||||
#include "Input/pad_thread.h"
|
||||
|
||||
LOG_CHANNEL(ghltar_log, "GHLTAR");
|
||||
@ -16,11 +17,6 @@ usb_device_ghltar::usb_device_ghltar(u32 controller_index, const std::array<u8,
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_HID, UsbDeviceHID{0x0111, 0x00, 0x01, 0x22, 0x001d}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_ENDPOINT, UsbDeviceEndpoint{0x81, 0x03, 0x0020, 0x01}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_ENDPOINT, UsbDeviceEndpoint{0x01, 0x03, 0x0020, 0x01}));
|
||||
|
||||
if (!m_cfg.load())
|
||||
{
|
||||
ghltar_log.notice("Could not load ghltar config. Using defaults.");
|
||||
}
|
||||
}
|
||||
|
||||
usb_device_ghltar::~usb_device_ghltar()
|
||||
@ -115,7 +111,7 @@ void usb_device_ghltar::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpoint
|
||||
std::lock_guard lock(pad::g_pad_mutex);
|
||||
const auto handler = pad::get_current_handler();
|
||||
const auto& pad = ::at32(handler->GetPads(), m_controller_index);
|
||||
const auto& cfg = ::at32(m_cfg.players, m_controller_index);
|
||||
const auto& cfg = ::at32(g_cfg_ghltar.players, m_controller_index);
|
||||
|
||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Emu/Io/usb_device.h"
|
||||
#include "Emu/Io/ghltar_config.h"
|
||||
|
||||
class usb_device_ghltar : public usb_device_emulated
|
||||
{
|
||||
@ -14,5 +13,4 @@ public:
|
||||
|
||||
private:
|
||||
u32 m_controller_index;
|
||||
cfg_ghltars m_cfg;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "Turntable.h"
|
||||
#include "Emu/Cell/lv2/sys_usbd.h"
|
||||
#include "Emu/Io/turntable_config.h"
|
||||
#include "Input/pad_thread.h"
|
||||
|
||||
LOG_CHANNEL(turntable_log, "TURN");
|
||||
@ -16,11 +17,6 @@ usb_device_turntable::usb_device_turntable(u32 controller_index, const std::arra
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_HID, UsbDeviceHID{0x0110, 0x00, 0x01, 0x22, 0x0089}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_ENDPOINT, UsbDeviceEndpoint{0x81, 0x03, 0x0040, 0x0a}));
|
||||
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_ENDPOINT, UsbDeviceEndpoint{0x02, 0x03, 0x0040, 0x0a}));
|
||||
|
||||
if (!m_cfg.load())
|
||||
{
|
||||
turntable_log.notice("Could not load turntable config. Using defaults.");
|
||||
}
|
||||
}
|
||||
|
||||
usb_device_turntable::~usb_device_turntable()
|
||||
@ -128,7 +124,7 @@ void usb_device_turntable::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpo
|
||||
const auto handler = pad::get_current_handler();
|
||||
const auto& pads = handler->GetPads();
|
||||
const auto& pad = ::at32(pads, m_controller_index);
|
||||
const auto& cfg = ::at32(m_cfg.players, m_controller_index);
|
||||
const auto& cfg = ::at32(g_cfg_turntable.players, m_controller_index);
|
||||
|
||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||
return;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Emu/Io/usb_device.h"
|
||||
#include "Emu/Io/turntable_config.h"
|
||||
|
||||
class usb_device_turntable : public usb_device_emulated
|
||||
{
|
||||
@ -14,5 +13,4 @@ public:
|
||||
|
||||
private:
|
||||
u32 m_controller_index;
|
||||
cfg_turntables m_cfg;
|
||||
};
|
||||
|
@ -28,3 +28,5 @@ struct cfg_buzz final : public emulated_pads_config<cfg_buzzer>
|
||||
{
|
||||
cfg_buzz() : emulated_pads_config<cfg_buzzer>("buzz") {};
|
||||
};
|
||||
|
||||
extern cfg_buzz g_cfg_buzz;
|
||||
|
@ -34,3 +34,5 @@ struct cfg_gems final : public emulated_pads_config<cfg_gem>
|
||||
{
|
||||
cfg_gems() : emulated_pads_config<cfg_gem>("gem") {};
|
||||
};
|
||||
|
||||
extern cfg_gems g_cfg_gem;
|
||||
|
@ -44,3 +44,5 @@ struct cfg_ghltars final : public emulated_pads_config<cfg_ghltar>
|
||||
{
|
||||
cfg_ghltars() : emulated_pads_config<cfg_ghltar>("ghltar") {};
|
||||
};
|
||||
|
||||
extern cfg_ghltars g_cfg_ghltar;
|
||||
|
@ -44,3 +44,5 @@ struct cfg_turntables final : public emulated_pads_config<cfg_turntable>
|
||||
{
|
||||
cfg_turntables() : emulated_pads_config<cfg_turntable>("turntable") {};
|
||||
};
|
||||
|
||||
extern cfg_turntables g_cfg_turntable;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "usio.h"
|
||||
#include "Input/pad_thread.h"
|
||||
#include "Emu/Io/usio_config.h"
|
||||
#include "Emu/IdManager.h"
|
||||
|
||||
LOG_CHANNEL(usio_log, "USIO");
|
||||
@ -81,11 +82,6 @@ usb_device_usio::usb_device_usio(const std::array<u8, 7>& location)
|
||||
g_fxo->get<usio_memory>().last_game_status.clear();
|
||||
g_fxo->get<usio_memory>().last_game_status.resize(0x28);
|
||||
load_backup();
|
||||
|
||||
if (!m_cfg.load())
|
||||
{
|
||||
usio_log.notice("Could not load usio config. Using defaults.");
|
||||
}
|
||||
}
|
||||
|
||||
usb_device_usio::~usb_device_usio()
|
||||
@ -172,7 +168,7 @@ void usb_device_usio::translate_input()
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& cfg = ::at32(m_cfg.players, pad_number);
|
||||
const auto& cfg = ::at32(g_cfg_usio.players, pad_number);
|
||||
const std::size_t offset = (player * 8ULL);
|
||||
|
||||
for (const Button& button : pad->m_buttons)
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "Emu/system_utils.hpp"
|
||||
#include "Emu/Io/usb_device.h"
|
||||
#include "Emu/Io/usio_config.h"
|
||||
|
||||
class usb_device_usio : public usb_device_emulated
|
||||
{
|
||||
@ -29,5 +28,4 @@ private:
|
||||
le_t<u16> coin_counter = 0;
|
||||
const std::string usio_backup_path = rpcs3::utils::get_hdd1_dir() + "/caches/usiobackup.bin";
|
||||
std::vector<u8> response;
|
||||
cfg_usios m_cfg;
|
||||
};
|
||||
|
@ -46,3 +46,5 @@ struct cfg_usios final : public emulated_pads_config<cfg_usio>
|
||||
{
|
||||
cfg_usios() : emulated_pads_config<cfg_usio>("usio") {};
|
||||
};
|
||||
|
||||
extern cfg_usios g_cfg_usio;
|
||||
|
Loading…
x
Reference in New Issue
Block a user