Also create serial for gamepad as well
This commit is contained in:
parent
04d1817570
commit
a4d869f4e4
|
@ -269,7 +269,7 @@ int Hub::UsbHub_Initfn(XboxDeviceState* dev)
|
|||
USBPortOps* ops;
|
||||
int i;
|
||||
|
||||
m_UsbDev->USB_CreateSerial(dev, "314159");
|
||||
m_UsbDev->USB_CreateSerial(dev, std::string("314159"));
|
||||
m_UsbDev->USBDesc_SetString(dev, STR_MANUFACTURER, std::string("Cxbx-Reloaded"));
|
||||
m_UsbDev->USBDesc_SetString(dev, STR_PRODUCT, std::string("Cxbx-Reloaded USB Hub"));
|
||||
m_UsbDev->USBDesc_Init(dev);
|
||||
|
|
|
@ -725,19 +725,18 @@ void USBDevice::USB_EpReset(XboxDeviceState* dev)
|
|||
* the pci address in most cases). Third the physical port path.
|
||||
* Results in serial numbers like this: "314159-0000:00:1d.7-3".
|
||||
*/
|
||||
void USBDevice::USB_CreateSerial(XboxDeviceState* dev, const char* str)
|
||||
void USBDevice::USB_CreateSerial(XboxDeviceState* dev, std::string&& str)
|
||||
{
|
||||
const USBDesc* desc = USBDesc_GetUsbDeviceDesc(dev);
|
||||
int index = desc->id.iSerialNumber;
|
||||
USBDescString* s;
|
||||
std::string serial;
|
||||
std::string str2;
|
||||
|
||||
assert(index != 0 && str != nullptr);
|
||||
serial = str + '-';
|
||||
serial += m_PciPath;
|
||||
serial += ('-' + dev->Port->Path);
|
||||
assert(index != 0 && str.empty() == false);
|
||||
str += '-';
|
||||
str += m_PciPath;
|
||||
str += ('-' + dev->Port->Path);
|
||||
|
||||
USBDesc_SetString(dev, index, serial);
|
||||
USBDesc_SetString(dev, index, std::move(str));
|
||||
}
|
||||
|
||||
const USBDesc* USBDevice::USBDesc_GetUsbDeviceDesc(XboxDeviceState* dev)
|
||||
|
@ -1253,7 +1252,7 @@ int USBDevice::USB_ReadStringDesc(XboxDeviceState* dev, int index, uint8_t* dest
|
|||
return pos;
|
||||
}
|
||||
|
||||
void USBDevice::USBDesc_SetString(XboxDeviceState* dev, int index, std::string& const str)
|
||||
void USBDevice::USBDesc_SetString(XboxDeviceState* dev, int index, std::string&& str)
|
||||
{
|
||||
USBDescString* s;
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ class USBDevice : public PCIDevice {
|
|||
// reset all endpoints of this peripheral
|
||||
void USB_EpReset(XboxDeviceState* dev);
|
||||
// create a serial number for the device
|
||||
void USB_CreateSerial(XboxDeviceState* dev, const char* str);
|
||||
void USB_CreateSerial(XboxDeviceState* dev, std::string&& str);
|
||||
// start descriptors initialization
|
||||
void USBDesc_Init(XboxDeviceState* dev);
|
||||
// get device descriptor
|
||||
|
@ -190,7 +190,7 @@ class USBDevice : public PCIDevice {
|
|||
// return the binary rapresentation of string descriptors
|
||||
int USB_ReadStringDesc(XboxDeviceState* dev, int index, uint8_t* dest, size_t len);
|
||||
// set a string in the string descriptor with the supplied index
|
||||
void USBDesc_SetString(XboxDeviceState* dev, int index, std::string& const str);
|
||||
void USBDesc_SetString(XboxDeviceState* dev, int index, std::string&& str);
|
||||
// get a string in the string descriptor with the supplied index
|
||||
const char* USBDesc_GetString(XboxDeviceState* dev, int index);
|
||||
};
|
||||
|
|
|
@ -152,6 +152,9 @@ USBDesc::USBDesc()
|
|||
id.idVendor = 0x045E;
|
||||
id.idProduct = 0x0202;
|
||||
id.bcdDevice = 0x0100;
|
||||
id.iManufacturer = STR_MANUFACTURER;
|
||||
id.iProduct = STR_PRODUCT;
|
||||
id.iSerialNumber = STR_SERIALNUMBER;
|
||||
full = &desc_device_xbox_gamepad;
|
||||
}
|
||||
|
||||
|
@ -262,6 +265,9 @@ void XidGamepad::UsbXidReleasePort(XboxDeviceState* dev)
|
|||
|
||||
int XidGamepad::UsbXid_Initfn(XboxDeviceState* dev)
|
||||
{
|
||||
m_UsbDev->USB_CreateSerial(dev, std::string("1"));
|
||||
m_UsbDev->USBDesc_SetString(dev, STR_MANUFACTURER, std::string("Cxbx-Reloaded"));
|
||||
m_UsbDev->USBDesc_SetString(dev, STR_PRODUCT, std::string("Microsoft Gamepad"));
|
||||
m_UsbDev->USBDesc_Init(dev);
|
||||
m_XidState->intr = m_UsbDev->USB_GetEP(dev, USB_TOKEN_IN, 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue