1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

USB: Move uDraw GameTablet config from IO to Pads

This commit is contained in:
Florin9doi 2024-05-18 10:30:37 +03:00 committed by Megamouse
parent 500bf0f3f5
commit a1a38b7b39
15 changed files with 47 additions and 67 deletions

View File

@ -495,12 +495,6 @@ usb_handler_thread::usb_handler_thread()
sys_usbd.notice("Adding emulated Buzz! buzzer (5-7 players)");
usb_devices.push_back(std::make_shared<usb_device_buzz>(4, 6, get_new_location()));
}
if (g_cfg.io.gametablet == gametablet_handler::enabled)
{
sys_usbd.notice("Adding emulated uDraw GameTablet");
usb_devices.push_back(std::make_shared<usb_device_gametablet>(get_new_location()));
}
}
usb_handler_thread::~usb_handler_thread()
@ -868,17 +862,27 @@ void connect_usb_controller(u8 index, input::product_type type)
}
}
if (!already_connected && type == input::product_type::guncon_3)
if (!already_connected)
{
if (!g_cfg_guncon3.load())
if (type == input::product_type::guncon_3)
{
sys_usbd.notice("Could not load GunCon3 config. Using defaults.");
}
if (!g_cfg_guncon3.load())
{
sys_usbd.notice("Could not load GunCon3 config. Using defaults.");
}
sys_usbd.success("Adding emulated GunCon3 (controller %d)", index);
std::shared_ptr<usb_device> dev = std::make_shared<usb_device_guncon3>(index, usbh->get_new_location());
usbh->connect_usb_device(dev, true);
usbh->pad_to_usb.emplace(index, std::pair(type, dev));
sys_usbd.success("Adding emulated GunCon3 (controller %d)", index);
std::shared_ptr<usb_device> dev = std::make_shared<usb_device_guncon3>(index, usbh->get_new_location());
usbh->connect_usb_device(dev, true);
usbh->pad_to_usb.emplace(index, std::pair(type, dev));
}
if (type == input::product_type::udraw_gametablet)
{
sys_usbd.success("Adding emulated uDraw GameTablet (controller %d)", index);
std::shared_ptr<usb_device> dev = std::make_shared<usb_device_gametablet>(index, usbh->get_new_location());
usbh->connect_usb_device(dev, true);
usbh->pad_to_usb.emplace(index, std::pair(type, dev));
}
}
}

View File

@ -62,8 +62,9 @@ enum
Dpad_None = 0x0f
};
usb_device_gametablet::usb_device_gametablet(const std::array<u8, 7>& location)
usb_device_gametablet::usb_device_gametablet(u32 controller_index, const std::array<u8, 7>& location)
: usb_device_emulated(location)
, m_controller_index(controller_index)
{
device = UsbDescriptorNode(USB_DESCRIPTOR_DEVICE,
UsbDeviceDescriptor {
@ -163,7 +164,7 @@ void usb_device_gametablet::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endp
ensure(buf_size >= sizeof(GameTablet_data));
transfer->fake = true;
transfer->expected_count = 27;
transfer->expected_count = sizeof(GameTablet_data);
transfer->expected_result = HC_CC_NOERR;
// Interrupt transfers are slow (6ms, TODO accurate measurement)
transfer->expected_time = get_timestamp() + 6000;
@ -196,9 +197,7 @@ void usb_device_gametablet::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endp
std::lock_guard lock(pad::g_pad_mutex);
const auto gamepad_handler = pad::get_current_handler();
const auto& pads = gamepad_handler->GetPads();
constexpr s32 pad_index = 1; // Player2
const auto& pad = ::at32(pads, pad_index);
const auto& pad = ::at32(pads, m_controller_index);
if (pad->m_port_status & CELL_PAD_STATUS_CONNECTED)
{
for (Button& button : pad->m_buttons)

View File

@ -5,9 +5,12 @@
class usb_device_gametablet : public usb_device_emulated
{
public:
usb_device_gametablet(const std::array<u8, 7>& location);
usb_device_gametablet(u32 controller_index, const std::array<u8, 7>& location);
~usb_device_gametablet();
void control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, u32 buf_size, u8* buf, UsbTransfer* transfer) override;
void interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) override;
private:
u32 m_controller_index;
};

View File

@ -148,6 +148,7 @@ enum
// these are used together with pad->is_fake_pad to capture input events for usbd/gem/move without conflicting with cellPad
CELL_PAD_FAKE_TYPE_FIRST = 0xa000,
CELL_PAD_FAKE_TYPE_GUNCON3 = 0xa000,
CELL_PAD_FAKE_TYPE_GAMETABLET = 0xa003,
CELL_PAD_FAKE_TYPE_LAST,
CELL_PAD_PCLASS_TYPE_MAX // last item

View File

@ -273,7 +273,6 @@ struct cfg_root : cfg::node
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};
cfg::_enum<gametablet_handler> gametablet{this, "GameTablet emulated controller", gametablet_handler::disabled};
cfg::_enum<pad_handler_mode> pad_mode{this, "Pad handler mode", pad_handler_mode::single_threaded, true};
cfg::_bool keep_pads_connected{this, "Keep pads connected", false, true};
cfg::uint<0, 100'000> pad_sleep{this, "Pad handler sleep (microseconds)", 1'000, true};

View File

@ -510,21 +510,6 @@ void fmt_class_string<ghltar_handler>::format(std::string& out, u64 arg)
});
}
template <>
void fmt_class_string<gametablet_handler>::format(std::string& out, u64 arg)
{
format_enum(out, arg, [](auto value)
{
switch (value)
{
case gametablet_handler::disabled: return "Disabled";
case gametablet_handler::enabled: return "Enabled";
}
return unknown;
});
}
template <>
void fmt_class_string<ppu_decoder_type>::format(std::string& out, u64 arg)
{

View File

@ -167,12 +167,6 @@ enum class ghltar_handler
two_controllers,
};
enum class gametablet_handler
{
disabled,
enabled,
};
enum class microphone_handler
{
null,

View File

@ -204,6 +204,17 @@ namespace input
.pclass_profile = 0x0,
.capabilites = 0x0
}
},
{
product_type::udraw_gametablet,
{
.type = product_type::udraw_gametablet,
.class_id = CELL_PAD_FAKE_TYPE_GAMETABLET,
.vendor_id = vendor_id::bda,
.product_id = product_id::udraw_gametablet,
.pclass_profile = 0x0,
.capabilites = 0x0
}
}
};

View File

@ -19,6 +19,7 @@ namespace input
ps_move_navigation,
ride_skateboard,
guncon_3,
udraw_gametablet,
};
enum vendor_id
@ -27,6 +28,7 @@ namespace input
namco = 0x0B9A, // Namco
sony_cea = 0x12BA, // Sony Computer Entertainment America
konami_de = 0x1CCF, // Konami Digital Entertainment
bda = 0x20D6, // Bensussen Deutsch & Associates
};
enum product_id
@ -43,6 +45,7 @@ namespace input
dance_dance_revolution_mat = 0x1010, // Dance Dance Revolution Dance Mat Controller
ride_skateboard = 0x0400, // Tony Hawk RIDE Skateboard Controller
guncon_3 = 0x0800, // GunCon 3 Controller
udraw_gametablet = 0xCB17, // uDraw GameTablet Controller
};
struct product_info

View File

@ -1088,13 +1088,6 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_
case ghltar_handler::two_controllers: return tr("2 controllers", "GHLtar handler");
}
break;
case emu_settings_type::GameTablet:
switch (static_cast<gametablet_handler>(index))
{
case gametablet_handler::disabled: return tr("Disabled", "GameTablet handler");
case gametablet_handler::enabled: return tr("Enabled", "GameTablet handler");
}
break;
case emu_settings_type::InternetStatus:
switch (static_cast<np_internet_status>(index))
{

View File

@ -160,7 +160,6 @@ enum class emu_settings_type
Buzz,
Turntable,
GHLtar,
GameTablet,
MidiDevices,
SDLMappings,
@ -350,7 +349,6 @@ inline static const QMap<emu_settings_type, cfg_location> settings_location =
{ 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" }},
{ emu_settings_type::GameTablet, { "Input/Output", "GameTablet emulated controller" }},
{ emu_settings_type::MidiDevices, { "Input/Output", "Emulated Midi devices" }},
{ emu_settings_type::SDLMappings, { "Input/Output", "Load SDL GameController Mappings" }},

View File

@ -182,6 +182,7 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_setti
ui->chooseClass->addItem(tr("PS Move Navigation"), u32{CELL_PAD_PCLASS_TYPE_NAVIGATION});
ui->chooseClass->addItem(tr("Skateboard"), u32{CELL_PAD_PCLASS_TYPE_SKATEBOARD});
ui->chooseClass->addItem(tr("GunCon 3"), u32{CELL_PAD_FAKE_TYPE_GUNCON3});
ui->chooseClass->addItem(tr("uDraw GameTablet"), u32{CELL_PAD_FAKE_TYPE_GAMETABLET});
connect(ui->chooseClass, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index)
{
@ -1724,6 +1725,11 @@ void pad_settings_dialog::HandleDeviceClassChange(u32 class_id) const
ui->chooseProduct->addItem(tr("GunCon 3", "GunCon 3 Controller"), static_cast<int>(product.type));
break;
}
case input::product_type::udraw_gametablet:
{
ui->chooseProduct->addItem(tr("uDraw GameTablet", "uDraw GameTablet Controller"), static_cast<int>(product.type));
break;
}
}
}
}

View File

@ -1224,9 +1224,6 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_emu_settings->EnhanceComboBox(ui->ghltarBox, emu_settings_type::GHLtar);
SubscribeTooltip(ui->gb_ghltar_emulated, tooltips.settings.ghltar);
m_emu_settings->EnhanceComboBox(ui->gameTabletBox, emu_settings_type::GameTablet);
SubscribeTooltip(ui->gametablet_emulated, tooltips.settings.gametablet);
m_emu_settings->EnhanceCheckBox(ui->backgroundInputBox, emu_settings_type::BackgroundInput);
SubscribeTooltip(ui->backgroundInputBox, tooltips.settings.background_input);

View File

@ -1731,18 +1731,6 @@
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QGroupBox" name="gametablet_emulated">
<property name="title">
<string>GameTablet</string>
</property>
<layout class="QVBoxLayout" name="gametablet_emulated_layout">
<item>
<widget class="QComboBox" name="gameTabletBox"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="2">
<widget class="QGroupBox" name="gb_midi_1">
<property name="title">

View File

@ -231,7 +231,6 @@ public:
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.");
const QString gametablet = tr("uDraw GameTablet emulated controller support. It requires a Mouse Handler enabled.\nDisable to use a physical uDraw GameTablet device.\n• uDraw Studio: Instant Artist requires Pad1=Connected and Pad2=Null.\n• Marvel Super Hero Squad: Comic Combat requires Pad1=Null and Pad2=Connected.");
const QString background_input = tr("Allows pad and keyboard input while the game window is unfocused.");
const QString show_move_cursor = tr("Shows the raw position of the PS Move input.\nThis can be very helpful during calibration screens.");
const QString midi_devices = tr("Select up to 3 emulated MIDI devices and their types.");