Add emulated Guitar Hero Live guitar controller in Settings I/O tab

This commit is contained in:
shockdude 2021-10-15 22:57:37 -07:00 committed by Megamouse
parent 9ba9d9424e
commit 590483b81f
11 changed files with 63 additions and 8 deletions

View file

@ -236,10 +236,15 @@ usb_handler_thread::usb_handler_thread()
usb_devices.push_back(std::make_shared<usb_device_skylander>());
}
if (!found_ghltar)
if (g_cfg.io.ghltar == ghltar_handler::one_controller || g_cfg.io.ghltar == ghltar_handler::two_controllers)
{
sys_usbd.notice("Adding emulated GHLtar");
usb_devices.push_back(std::make_shared<usb_device_ghltar>());
sys_usbd.notice("Adding emulated GHLtar (1 player)");
usb_devices.push_back(std::make_shared<usb_device_ghltar>(0));
}
if (g_cfg.io.ghltar == ghltar_handler::two_controllers)
{
sys_usbd.notice("Adding emulated GHLtar (2 players)");
usb_devices.push_back(std::make_shared<usb_device_ghltar>(1));
}
if (g_cfg.io.turntable == turntable_handler::one_controller || g_cfg.io.turntable == turntable_handler::two_controllers)

View file

@ -7,7 +7,7 @@
LOG_CHANNEL(ghltar_log);
usb_device_ghltar::usb_device_ghltar()
usb_device_ghltar::usb_device_ghltar(int controller_index) : m_controller_index(controller_index)
{
device = UsbDescriptorNode(USB_DESCRIPTOR_DEVICE, UsbDeviceDescriptor{0x0200, 0x00, 0x00, 0x00, 0x20, 0x12BA, 0x074B, 0x0100, 0x01, 0x02, 0x00, 0x01});
auto& config0 = device.add_node(UsbDescriptorNode(USB_DESCRIPTOR_CONFIG, UsbDeviceConfiguration{0x0029, 0x01, 0x01, 0x00, 0x80, 0x96}));
@ -98,7 +98,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 = handler->GetPads()[6];
const auto& pad = handler->GetPads()[m_controller_index];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return;

View file

@ -4,8 +4,11 @@
class usb_device_ghltar : public usb_device_emulated
{
private:
int m_controller_index;
public:
usb_device_ghltar();
usb_device_ghltar(int controller_index);
~usb_device_ghltar();
void control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, u32 buf_size, u8* buf, UsbTransfer* transfer) override;

View file

@ -246,6 +246,7 @@ struct cfg_root : cfg::node
cfg::_enum<move_handler> move{ this, "Move", move_handler::null };
cfg::_enum<buzz_handler> buzz{ this, "Buzz emulated controller", buzz_handler::null };
cfg::_enum<turntable_handler> turntable{this, "Turntable emulated controller", turntable_handler::null};
cfg::_enum<ghltar_handler> ghltar{this, "GHLtar emulated controller", ghltar_handler::null};
} io{ this };
struct node_sys : cfg::node

View file

@ -405,6 +405,22 @@ void fmt_class_string<turntable_handler>::format(std::string& out, u64 arg)
});
}
template <>
void fmt_class_string<ghltar_handler>::format(std::string& out, u64 arg)
{
format_enum(out, arg, [](auto value)
{
switch (value)
{
case ghltar_handler::null: return "Null";
case ghltar_handler::one_controller: return "1 controller";
case ghltar_handler::two_controllers: return "2 controllers";
}
return unknown;
});
}
template <>
void fmt_class_string<ppu_decoder_type>::format(std::string& out, u64 arg)
{

View file

@ -109,6 +109,13 @@ enum class turntable_handler
two_controllers,
};
enum class ghltar_handler
{
null,
one_controller,
two_controllers,
};
enum class microphone_handler
{
null,

View file

@ -1038,6 +1038,14 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_
case turntable_handler::two_controllers: return tr("2 controllers", "Turntable handler");
}
break;
case emu_settings_type::GHLtar:
switch (static_cast<ghltar_handler>(index))
{
case ghltar_handler::null: return tr("Null", "GHLtar handler");
case ghltar_handler::one_controller: return tr("1 controller", "GHLtar handler");
case ghltar_handler::two_controllers: return tr("2 controllers", "GHLtar handler");
}
break;
case emu_settings_type::InternetStatus:
switch (static_cast<np_internet_status>(index))
{

View file

@ -128,6 +128,7 @@ enum class emu_settings_type
Move,
Buzz,
Turntable,
GHLtar,
// Misc
ExitRPCS3OnFinish,
@ -281,6 +282,7 @@ inline static const QMap<emu_settings_type, cfg_location> settings_location =
{ emu_settings_type::Move, { "Input/Output", "Move" }},
{ emu_settings_type::Buzz, { "Input/Output", "Buzz emulated controller" }},
{ emu_settings_type::Turntable, { "Input/Output", "Turntable emulated controller" }},
{ emu_settings_type::GHLtar, { "Input/Output", "GHLtar emulated controller" }},
// Misc
{ emu_settings_type::ExitRPCS3OnFinish, { "Miscellaneous", "Exit RPCS3 when process finishes" }},

View file

@ -964,6 +964,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_emu_settings->EnhanceComboBox(ui->turntableBox, emu_settings_type::Turntable);
SubscribeTooltip(ui->gb_turntable_emulated, tooltips.settings.turntable);
m_emu_settings->EnhanceComboBox(ui->ghltarBox, emu_settings_type::GHLtar);
SubscribeTooltip(ui->gb_ghltar_emulated, tooltips.settings.ghltar);
// _____ _ _______ _
// / ____| | | |__ __| | |
// | (___ _ _ ___| |_ ___ _ __ ___ | | __ _| |__

View file

@ -1508,10 +1508,19 @@
</widget>
</item>
<item>
<widget class="QWidget" name="inputTabSpacerWidget" native="true"/>
<widget class="QGroupBox" name="gb_ghltar_emulated">
<property name="title">
<string>Guitar Hero Live emulated guitar</string>
</property>
<layout class="QVBoxLayout" name="gb_ghltar_emulated_layout">
<item>
<widget class="QComboBox" name="ghltarBox"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="inputTabSpacerWidget2" native="true"/>
<widget class="QWidget" name="inputTabSpacerWidget" native="true"/>
</item>
</layout>
</item>

View file

@ -197,6 +197,7 @@ public:
const QString move = tr("PlayStation Move support.\nFake: Experimental! This maps Move controls to DS3 controller mappings.\nMouse: Emulate PSMove with Mouse handler.");
const QString buzz = tr("Buzz! support.\nSelect 1 or 2 controllers if the game requires Buzz! controllers and you don't have real controllers.\nSelect Null if the game has support for DualShock or if you have real Buzz! controllers.");
const QString turntable = tr("DJ Hero Turntable controller support.\nSelect 1 or 2 controllers if the game requires DJ Hero Turntable controllers and you don't have real turntable controllers.\nSelect Null if the game has support for DualShock or if you have real turntable controllers.\nA real turntable controller can be used at the same time as an emulated turntable controller.");
const QString ghltar = tr("Guitar Hero Live (GHL) Guitar controller support.\nSelect 1 or 2 controllers if the game requires GHL Guitar controllers and you don't have real guitar controllers.\nSelect Null if the game has support for DualShock or if you have real guitar controllers.\nA real guitar controller can be used at the same time as an emulated guitar controller.");
// network