diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index 674bb36196..af527ad3e3 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/System.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUModule.h" @@ -394,7 +394,7 @@ error_code cellPadPeriphGetInfo(vm::ptr info) info->port_setting[i] = config->port_setting[i]; info->device_capability[i] = pads[i]->m_device_capability; info->device_type[i] = pads[i]->m_device_type; - info->pclass_type[i] = CELL_PAD_PCLASS_TYPE_STANDARD; + info->pclass_type[i] = pads[i]->m_class_type; info->pclass_profile[i] = 0x0; } @@ -429,7 +429,7 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr data) return CELL_PAD_ERROR_NO_DEVICE; // todo: support for 'unique' controllers, which goes in offsets 24+ in padData - data->pclass_type = CELL_PAD_PCLASS_TYPE_STANDARD; + data->pclass_type = pad->m_class_type; data->pclass_profile = 0x0; return cellPadGetData(port_no, vm::get_addr(&data->cellpad_data)); diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index cca98f5a5c..73970e9e0e 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -169,6 +169,7 @@ struct Pad u32 m_port_status; u32 m_device_capability; u32 m_device_type; + u32 m_class_type; // Cable State: 0 - 1 plugged in ? u8 m_cable_state; @@ -212,11 +213,12 @@ struct Pad u16 m_sensor_z; u16 m_sensor_g; - void Init(u32 port_status, u32 device_capability, u32 device_type) + void Init(u32 port_status, u32 device_capability, u32 device_type, u32 class_type) { m_port_status = port_status; m_device_capability = device_capability; m_device_type = device_type; + m_class_type = class_type; } Pad(u32 port_status, u32 device_capability, u32 device_type) @@ -348,6 +350,8 @@ struct pad_config final : cfg::node cfg::_int<0, 100> l_stick_lerp_factor{ this, "Left Stick Lerp Factor", 100 }; cfg::_int<0, 100> r_stick_lerp_factor{ this, "Right Stick Lerp Factor", 100 }; + cfg::_int<0, 5> device_class_type{ this, "Device Class Type", 0 }; + bool load() { if (fs::file cfg_file{ cfg_name, fs::read }) diff --git a/rpcs3/ds4_pad_handler.cpp b/rpcs3/ds4_pad_handler.cpp index 9fd08d07f8..7559f12403 100644 --- a/rpcs3/ds4_pad_handler.cpp +++ b/rpcs3/ds4_pad_handler.cpp @@ -1,4 +1,4 @@ -#include "ds4_pad_handler.h" +#include "ds4_pad_handler.h" #include @@ -805,7 +805,8 @@ bool ds4_pad_handler::bindPadToDevice(std::shared_ptr pad, const std::strin ( CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, - CELL_PAD_DEV_TYPE_STANDARD + CELL_PAD_DEV_TYPE_STANDARD, + p_profile->device_class_type ); // 'keycode' here is just 0 as we have to manually calculate this diff --git a/rpcs3/evdev_joystick_handler.cpp b/rpcs3/evdev_joystick_handler.cpp index ca43111564..b4b8279ac4 100644 --- a/rpcs3/evdev_joystick_handler.cpp +++ b/rpcs3/evdev_joystick_handler.cpp @@ -1,4 +1,4 @@ -// This makes debugging on windows less painful +// This makes debugging on windows less painful //#define HAVE_LIBEVDEV #ifdef HAVE_LIBEVDEV @@ -940,7 +940,8 @@ bool evdev_joystick_handler::bindPadToDevice(std::shared_ptr pad, const std ( CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, - CELL_PAD_DEV_TYPE_STANDARD + CELL_PAD_DEV_TYPE_STANDARD, + p_profile->device_class_type ); pad->m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, find_key(p_profile->triangle), CELL_PAD_CTRL_TRIANGLE); diff --git a/rpcs3/keyboard_pad_handler.cpp b/rpcs3/keyboard_pad_handler.cpp index 99df8b8d54..dcc98acc3c 100644 --- a/rpcs3/keyboard_pad_handler.cpp +++ b/rpcs3/keyboard_pad_handler.cpp @@ -545,7 +545,8 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std:: ( CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, - CELL_PAD_DEV_TYPE_STANDARD + CELL_PAD_DEV_TYPE_STANDARD, + p_profile->device_class_type ); pad->m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, find_key(p_profile->left), CELL_PAD_CTRL_LEFT); diff --git a/rpcs3/mm_joystick_handler.cpp b/rpcs3/mm_joystick_handler.cpp index 81ae930046..483ffbf3f6 100644 --- a/rpcs3/mm_joystick_handler.cpp +++ b/rpcs3/mm_joystick_handler.cpp @@ -1,4 +1,4 @@ -#ifdef _WIN32 +#ifdef _WIN32 #include "mm_joystick_handler.h" mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm) @@ -148,7 +148,8 @@ bool mm_joystick_handler::bindPadToDevice(std::shared_ptr pad, const std::s ( CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, - CELL_PAD_DEV_TYPE_STANDARD + CELL_PAD_DEV_TYPE_STANDARD, + p_profile->device_class_type ); joy_device->trigger_left = find_key(p_profile->l2); diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index 43a73c1e22..a0603d8bf5 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -169,6 +169,13 @@ pad_settings_dialog::pad_settings_dialog(QWidget *parent) // Refresh Button connect(ui->b_refresh, &QPushButton::clicked, this, &pad_settings_dialog::RefreshInputTypes); + ui->chooseClass->addItem(tr("Standard (Pad)")); + ui->chooseClass->addItem(tr("Guitar")); + ui->chooseClass->addItem(tr("Drum")); + ui->chooseClass->addItem(tr("DJ")); + ui->chooseClass->addItem(tr("Dance Mat")); + ui->chooseClass->addItem(tr("Navigation")); + // Initialize configurable buttons InitButtons(); @@ -467,6 +474,8 @@ void pad_settings_dialog::ReloadButtons() m_min_force = m_handler->vibration_min; m_max_force = m_handler->vibration_max; + ui->chooseClass->setCurrentIndex(m_handler_cfg.device_class_type); + // Enable Mouse Deadzones std::vector mouse_dz_range_x = m_handler_cfg.mouse_deadzone_x.to_list(); ui->mouse_dz_x->setRange(std::stoi(mouse_dz_range_x.front()), std::stoi(mouse_dz_range_x.back())); @@ -551,6 +560,7 @@ void pad_settings_dialog::ReactivateButtons() ui->chooseProfile->setFocusPolicy(Qt::WheelFocus); ui->chooseHandler->setFocusPolicy(Qt::WheelFocus); ui->chooseDevice->setFocusPolicy(Qt::WheelFocus); + ui->chooseClass->setFocusPolicy(Qt::WheelFocus); } void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int dz, int w, int x, int y) @@ -726,6 +736,8 @@ void pad_settings_dialog::UpdateLabel(bool is_reset) m_padButtons->button(entry.first)->setText(entry.second.text); } + + ui->chooseClass->setCurrentIndex(m_handler_cfg.device_class_type); } void pad_settings_dialog::SwitchButtons(bool is_enabled) @@ -778,6 +790,7 @@ void pad_settings_dialog::OnPadButtonClicked(int id) ui->chooseProfile->setFocusPolicy(Qt::ClickFocus); ui->chooseHandler->setFocusPolicy(Qt::ClickFocus); ui->chooseDevice->setFocusPolicy(Qt::ClickFocus); + ui->chooseClass->setFocusPolicy(Qt::ClickFocus); m_last_pos = QCursor::pos(); @@ -892,6 +905,7 @@ void pad_settings_dialog::ChangeInputType() // Handle empty device list bool config_enabled = force_enable || (m_handler->m_type != pad_handler::null && ui->chooseDevice->count() > 0); ui->chooseDevice->setEnabled(config_enabled); + ui->chooseClass->setEnabled(config_enabled); if (config_enabled) { @@ -1062,6 +1076,8 @@ void pad_settings_dialog::SaveProfile() m_handler_cfg.r_stick_lerp_factor.set(ui->right_stick_lerp->value() * 100); } + m_handler_cfg.device_class_type.set(ui->chooseClass->currentIndex()); + m_handler_cfg.save(); } diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.ui b/rpcs3/rpcs3qt/pad_settings_dialog.ui index 9307cee2bc..39ba89223a 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.ui +++ b/rpcs3/rpcs3qt/pad_settings_dialog.ui @@ -1458,6 +1458,25 @@ + + + + 10 + + + + + Device Class: + + + + + + + + + + diff --git a/rpcs3/xinput_pad_handler.cpp b/rpcs3/xinput_pad_handler.cpp index 4b25c2e6d9..03704933b4 100644 --- a/rpcs3/xinput_pad_handler.cpp +++ b/rpcs3/xinput_pad_handler.cpp @@ -1,4 +1,4 @@ - + #ifdef _WIN32 #include "xinput_pad_handler.h" @@ -485,7 +485,8 @@ bool xinput_pad_handler::bindPadToDevice(std::shared_ptr pad, const std::st ( CELL_PAD_STATUS_DISCONNECTED, CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_HP_ANALOG_STICK | CELL_PAD_CAPABILITY_ACTUATOR | CELL_PAD_CAPABILITY_SENSOR_MODE, - CELL_PAD_DEV_TYPE_STANDARD + CELL_PAD_DEV_TYPE_STANDARD, + p_profile->device_class_type ); pad->m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, FindKeyCode(button_list, p_profile->up), CELL_PAD_CTRL_UP);