Skip to content

Commit

Permalink
Buzz 7 players
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin9doi committed Dec 29, 2020
1 parent 9e6b650 commit 046e3a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 5 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_usbd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ usb_handler_thread::usb_handler_thread()

if (!found_buzz)
{
sys_usbd.error("Adding emulated Buzz! buzzer");
usb_devices.push_back(std::make_shared<usb_device_buzz>());
sys_usbd.notice("Adding emulated Buzz! buzzer");
usb_devices.push_back(std::make_shared<usb_device_buzz>(0, 3));
// The current buzz emulation piggybacks on the pad input.
// Since there can only be 7 pads connected on a PS3 the 8th player is currently not supported
usb_devices.push_back(std::make_shared<usb_device_buzz>(4, 6));
}

for (u32 index = 0; index < MAX_SYS_USBD_TRANSFERS; index++)
Expand Down
12 changes: 8 additions & 4 deletions rpcs3/Emu/Io/Buzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

LOG_CHANNEL(buzz_log);

usb_device_buzz::usb_device_buzz()
usb_device_buzz::usb_device_buzz(int first_controller, int last_controller)
{
this->first_controller = first_controller;
this->last_controller = last_controller;

device = UsbDescriptorNode(USB_DESCRIPTOR_DEVICE, UsbDeviceDescriptor{0x0200, 0x00, 0x00, 0x00, 0x08, 0x054c, 0x0002, 0x05a1, 0x03, 0x01, 0x00, 0x01});
auto& config0 = device.add_node(UsbDescriptorNode(USB_DESCRIPTOR_CONFIG, UsbDeviceConfiguration{0x0022, 0x01, 0x01, 0x00, 0x80, 0x32}));
config0.add_node(UsbDescriptorNode(USB_DESCRIPTOR_INTERFACE, UsbDeviceInterface{0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00}));
Expand Down Expand Up @@ -44,7 +47,7 @@ void usb_device_buzz::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, Us
transfer->fake = true;
transfer->expected_count = 5;
transfer->expected_result = HC_CC_NOERR;
// Interrupt transfers are slow(6ms, TODO accurate measurement)
// Interrupt transfers are slow (6ms, TODO accurate measurement)
transfer->expected_time = get_timestamp() + 6000;

memset(buf, 0, buf_size);
Expand All @@ -59,9 +62,10 @@ void usb_device_buzz::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, Us
const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();

for (int index = 0; index < 4; index++)
for (int index = 0; index <= (last_controller - first_controller); index++)
{
auto pad = pads[index];
const auto pad = pads[first_controller + index];

if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
continue;

Expand Down
5 changes: 4 additions & 1 deletion rpcs3/Emu/Io/Buzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

class usb_device_buzz : public usb_device_emulated
{
int first_controller;
int last_controller;

public:
usb_device_buzz();
usb_device_buzz(int first_controller, int last_controller);
~usb_device_buzz();

void control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, u32 buf_size, u8* buf, UsbTransfer* transfer) override;
Expand Down

0 comments on commit 046e3a1

Please sign in to comment.