mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
xbox.cpp: more usb (nw)
This commit is contained in:
parent
b34b408d8c
commit
c30f7e5852
@ -245,7 +245,7 @@ struct usb_device_interface
|
|||||||
{
|
{
|
||||||
UINT8 *position;
|
UINT8 *position;
|
||||||
int size;
|
int size;
|
||||||
std::forward_list<usb_device_interface_alternate> alternate_settings;
|
std::forward_list<usb_device_interface_alternate *> alternate_settings;
|
||||||
int selected_alternate;
|
int selected_alternate;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ struct usb_device_configuration
|
|||||||
USBStandardConfigurationDescriptor configuration_descriptor;
|
USBStandardConfigurationDescriptor configuration_descriptor;
|
||||||
UINT8 *position;
|
UINT8 *position;
|
||||||
int size;
|
int size;
|
||||||
std::forward_list<usb_device_interface> interfaces;
|
std::forward_list<usb_device_interface *> interfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ohci_function_device {
|
class ohci_function_device {
|
||||||
@ -263,18 +263,18 @@ public:
|
|||||||
void execute_reset();
|
void execute_reset();
|
||||||
int execute_transfer(int address, int endpoint, int pid, UINT8 *buffer, int size) ;
|
int execute_transfer(int address, int endpoint, int pid, UINT8 *buffer, int size) ;
|
||||||
protected:
|
protected:
|
||||||
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup);
|
virtual int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) { return -1; };
|
||||||
virtual int handle_get_status_request(int endpoint, USBSetupPacket *setup) = 0;
|
virtual int handle_get_status_request(int endpoint, USBSetupPacket *setup) { return 0; };
|
||||||
virtual int handle_clear_feature_request(int endpoint, USBSetupPacket *setup) = 0;
|
virtual int handle_clear_feature_request(int endpoint, USBSetupPacket *setup) { return 0; };
|
||||||
virtual int handle_set_feature_request(int endpoint, USBSetupPacket *setup) = 0;
|
virtual int handle_set_feature_request(int endpoint, USBSetupPacket *setup) { return 0; };
|
||||||
virtual int handle_set_descriptor_request(int endpoint, USBSetupPacket *setup) = 0;
|
virtual int handle_set_descriptor_request(int endpoint, USBSetupPacket *setup) { return 0; };
|
||||||
virtual int handle_synch_frame_request(int endpoint, USBSetupPacket *setup) = 0;
|
virtual int handle_synch_frame_request(int endpoint, USBSetupPacket *setup) { return 0; };
|
||||||
private:
|
|
||||||
void add_device_descriptor(USBStandardDeviceDescriptor &descriptor);
|
void add_device_descriptor(const USBStandardDeviceDescriptor &descriptor);
|
||||||
void add_configuration_descriptor(USBStandardConfigurationDescriptor &descriptor);
|
void add_configuration_descriptor(const USBStandardConfigurationDescriptor &descriptor);
|
||||||
void add_interface_descriptor(USBStandardInterfaceDescriptor &descriptor);
|
void add_interface_descriptor(const USBStandardInterfaceDescriptor &descriptor);
|
||||||
void add_endpoint_descriptor(USBStandardEndpointDescriptor &descriptor);
|
void add_endpoint_descriptor(const USBStandardEndpointDescriptor &descriptor);
|
||||||
void add_string_descriptor(UINT8 *descriptor);
|
void add_string_descriptor(const UINT8 *descriptor);
|
||||||
void select_configuration(int index);
|
void select_configuration(int index);
|
||||||
void select_alternate(int interfacei, int index);
|
void select_alternate(int interfacei, int index);
|
||||||
int find_alternate(int interfacei);
|
int find_alternate(int interfacei);
|
||||||
@ -298,13 +298,27 @@ private:
|
|||||||
UINT8 *descriptors;
|
UINT8 *descriptors;
|
||||||
int descriptors_pos;
|
int descriptors_pos;
|
||||||
USBStandardDeviceDescriptor device_descriptor;
|
USBStandardDeviceDescriptor device_descriptor;
|
||||||
std::forward_list<usb_device_configuration> configurations;
|
std::forward_list<usb_device_configuration *> configurations;
|
||||||
std::forward_list<usb_device_string> device_strings;
|
std::forward_list<usb_device_string *> device_strings;
|
||||||
usb_device_configuration *latest_configuration;
|
usb_device_configuration *latest_configuration;
|
||||||
usb_device_interface_alternate *latest_alternate;
|
usb_device_interface_alternate *latest_alternate;
|
||||||
usb_device_configuration *selected_configuration;
|
usb_device_configuration *selected_configuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ohci_game_controller_device : public ohci_function_device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ohci_game_controller_device(running_machine &machine);// :
|
||||||
|
//ohci_function_device(machine) {}
|
||||||
|
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
|
||||||
|
private:
|
||||||
|
static const USBStandardDeviceDescriptor devdesc;
|
||||||
|
static const USBStandardConfigurationDescriptor condesc;
|
||||||
|
static const USBStandardInterfaceDescriptor intdesc;
|
||||||
|
static const USBStandardEndpointDescriptor enddesc82;
|
||||||
|
static const USBStandardEndpointDescriptor enddesc02;
|
||||||
|
};
|
||||||
|
|
||||||
class xbox_base_state : public driver_device
|
class xbox_base_state : public driver_device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -833,46 +833,6 @@ void xbox_base_state::usb_ohci_plug(int port, ohci_function_device *function)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static USBStandardDeviceDescriptor devdesc = {18,1,0x110,0x00,0x00,0x00,64,0x45e,0x202,0x100,0,0,0,1};
|
|
||||||
static USBStandardConfigurationDescriptor condesc = {9,2,0x20,1,1,0,0x80,50};
|
|
||||||
static USBStandardInterfaceDescriptor intdesc = {9,4,0,0,2,0x58,0x42,0,0};
|
|
||||||
static USBStandardEndpointDescriptor enddesc82 = {7,5,0x82,3,0x20,4};
|
|
||||||
static USBStandardEndpointDescriptor enddesc02 = {7,5,0x02,3,0x20,4};
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
//ic10
|
|
||||||
static USBStandardDeviceDescriptor devdesc = { 0x12,0x01,0x0100,0x60,0x00,0x00,0x40,0x0CA3,0x0002,0x0108,0x01,0x02,0x00,0x01 };
|
|
||||||
static USBStandardConfigurationDescriptor condesc = { 0x09,0x02,0x0058,0x01,0x01,0x00,0x80,0x96 };
|
|
||||||
static USBStandardInterfaceDescriptor intdesc = { 0x09,0x04,0x00,0x00,0x0A,0xFF,0x00,0x00,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc01 = { 0x07,0x05,0x01,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc02 = { 0x07,0x05,0x02,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc03 = { 0x07,0x05,0x03,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc04 = { 0x07,0x05,0x04,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc05 = { 0x07,0x05,0x05,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc81 = { 0x07,0x05,0x81,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc82 = { 0x07,0x05,0x82,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc83 = { 0x07,0x05,0x83,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc84 = { 0x07,0x05,0x84,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc85 = { 0x07,0x05,0x85,0x02,0x0040,0x00 };
|
|
||||||
static UINT8 strdesc0[] = { 0x04,0x03,0x00,0x00 };
|
|
||||||
static UINT8 strdesc1[] = { 0x0A,0x03,0x53,0x00,0x45,0x00,0x47,0x00,0x41,0x00 };
|
|
||||||
static UINT8 strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0x00,0x53,0x00,0x45,0x00,0x42,0x03,0xFF,0x0B };
|
|
||||||
|
|
||||||
//pc20
|
|
||||||
static USBStandardDeviceDescriptor devdesc = { 0x12,0x01,0x0100,0x60,0x01,0x00,0x40,0x0CA3,0x0003,0x0110,0x01,0x02,0x00,0x01 };
|
|
||||||
static USBStandardConfigurationDescriptor condesc = { 0x09,0x02,0x003C,0x01,0x01,0x00,0x80,0x96 };
|
|
||||||
static USBStandardInterfaceDescriptor intdesc = { 0x09,0x04,0x00,0x00,0x06,0xFF,0x00,0x00,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc01 = { 0x07,0x05,0x01,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc02 = { 0x07,0x05,0x02,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc03 = { 0x07,0x05,0x03,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc81 = { 0x07,0x05,0x81,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc82 = { 0x07,0x05,0x82,0x02,0x0040,0x00 };
|
|
||||||
static USBStandardEndpointDescriptor enddesc83 = { 0x07,0x05,0x83,0x02,0x0040,0x00 };
|
|
||||||
static UINT8 strdesc0[] = { 0x04,0x03,0x00,0x00 };
|
|
||||||
static UINT8 strdesc1[] = { 0x0A,0x03,0x53,0x00,0x45,0x00,0x47,0x00,0x41,0x00 };
|
|
||||||
static UINT8 strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0x00,0x53,0x00,0x45,0x00,0x42,0x00,0x44,0x00 };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ohci_function_device::ohci_function_device(running_machine &machine)
|
ohci_function_device::ohci_function_device(running_machine &machine)
|
||||||
{
|
{
|
||||||
state = DefaultState;
|
state = DefaultState;
|
||||||
@ -891,16 +851,12 @@ ohci_function_device::ohci_function_device(running_machine &machine)
|
|||||||
endpoints[0].type = ControlEndpoint;
|
endpoints[0].type = ControlEndpoint;
|
||||||
settingaddress = false;
|
settingaddress = false;
|
||||||
configurationvalue = 0;
|
configurationvalue = 0;
|
||||||
|
selected_configuration = nullptr;
|
||||||
latest_configuration = nullptr;
|
latest_configuration = nullptr;
|
||||||
latest_alternate = nullptr;
|
latest_alternate = nullptr;
|
||||||
add_device_descriptor(devdesc);
|
|
||||||
add_configuration_descriptor(condesc);
|
|
||||||
add_interface_descriptor(intdesc);
|
|
||||||
add_endpoint_descriptor(enddesc82);
|
|
||||||
add_endpoint_descriptor(enddesc02);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::add_device_descriptor(USBStandardDeviceDescriptor &descriptor)
|
void ohci_function_device::add_device_descriptor(const USBStandardDeviceDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
UINT8 *p = descriptors + descriptors_pos;
|
UINT8 *p = descriptors + descriptors_pos;
|
||||||
|
|
||||||
@ -926,7 +882,7 @@ void ohci_function_device::add_device_descriptor(USBStandardDeviceDescriptor &de
|
|||||||
memcpy(&device_descriptor, &descriptor, sizeof(USBStandardDeviceDescriptor));
|
memcpy(&device_descriptor, &descriptor, sizeof(USBStandardDeviceDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::add_configuration_descriptor(USBStandardConfigurationDescriptor &descriptor)
|
void ohci_function_device::add_configuration_descriptor(const USBStandardConfigurationDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
usb_device_configuration *c = new usb_device_configuration;
|
usb_device_configuration *c = new usb_device_configuration;
|
||||||
UINT8 *p = descriptors + descriptors_pos;
|
UINT8 *p = descriptors + descriptors_pos;
|
||||||
@ -944,12 +900,12 @@ void ohci_function_device::add_configuration_descriptor(USBStandardConfiguration
|
|||||||
c->size = descriptor.bLength;
|
c->size = descriptor.bLength;
|
||||||
descriptors_pos += descriptor.bLength;
|
descriptors_pos += descriptor.bLength;
|
||||||
memcpy(&c->configuration_descriptor, &descriptor, sizeof(USBStandardConfigurationDescriptor));
|
memcpy(&c->configuration_descriptor, &descriptor, sizeof(USBStandardConfigurationDescriptor));
|
||||||
configurations.push_front(*c);
|
configurations.push_front(c);
|
||||||
latest_configuration = c;
|
latest_configuration = c;
|
||||||
latest_alternate = nullptr;
|
latest_alternate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::add_interface_descriptor(USBStandardInterfaceDescriptor &descriptor)
|
void ohci_function_device::add_interface_descriptor(const USBStandardInterfaceDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
usb_device_interface *ii;
|
usb_device_interface *ii;
|
||||||
usb_device_interface_alternate *aa;
|
usb_device_interface_alternate *aa;
|
||||||
@ -970,15 +926,15 @@ void ohci_function_device::add_interface_descriptor(USBStandardInterfaceDescript
|
|||||||
latest_configuration->size += descriptor.bLength;
|
latest_configuration->size += descriptor.bLength;
|
||||||
for (auto i = latest_configuration->interfaces.begin(); i != latest_configuration->interfaces.end(); ++i)
|
for (auto i = latest_configuration->interfaces.begin(); i != latest_configuration->interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
if (i->alternate_settings.front().interface_descriptor.bInterfaceNumber == descriptor.bInterfaceNumber)
|
if ((*i)->alternate_settings.front()->interface_descriptor.bInterfaceNumber == descriptor.bInterfaceNumber)
|
||||||
{
|
{
|
||||||
i->size += descriptor.bLength;
|
(*i)->size += descriptor.bLength;
|
||||||
latest_configuration->interfaces.front().size += descriptor.bLength;
|
latest_configuration->interfaces.front()->size += descriptor.bLength;
|
||||||
aa = new usb_device_interface_alternate;
|
aa = new usb_device_interface_alternate;
|
||||||
memcpy(&aa->interface_descriptor, &descriptor, sizeof(USBStandardInterfaceDescriptor));
|
memcpy(&aa->interface_descriptor, &descriptor, sizeof(USBStandardInterfaceDescriptor));
|
||||||
aa->position = p;
|
aa->position = p;
|
||||||
aa->size = descriptor.bLength;
|
aa->size = descriptor.bLength;
|
||||||
i->alternate_settings.push_front(*aa);
|
(*i)->alternate_settings.push_front(aa);
|
||||||
latest_alternate = aa;
|
latest_alternate = aa;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -991,12 +947,12 @@ void ohci_function_device::add_interface_descriptor(USBStandardInterfaceDescript
|
|||||||
ii->position = p;
|
ii->position = p;
|
||||||
ii->size = descriptor.bLength;
|
ii->size = descriptor.bLength;
|
||||||
ii->selected_alternate = -1;
|
ii->selected_alternate = -1;
|
||||||
ii->alternate_settings.push_front(*aa);
|
ii->alternate_settings.push_front(aa);
|
||||||
latest_alternate = aa;
|
latest_alternate = aa;
|
||||||
latest_configuration->interfaces.push_front(*ii);
|
latest_configuration->interfaces.push_front(ii);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::add_endpoint_descriptor(USBStandardEndpointDescriptor &descriptor)
|
void ohci_function_device::add_endpoint_descriptor(const USBStandardEndpointDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
UINT8 *p = descriptors + descriptors_pos;
|
UINT8 *p = descriptors + descriptors_pos;
|
||||||
|
|
||||||
@ -1012,11 +968,11 @@ void ohci_function_device::add_endpoint_descriptor(USBStandardEndpointDescriptor
|
|||||||
descriptors_pos += descriptor.bLength;
|
descriptors_pos += descriptor.bLength;
|
||||||
latest_alternate->endpoint_descriptors.push_front(descriptor);
|
latest_alternate->endpoint_descriptors.push_front(descriptor);
|
||||||
latest_alternate->size += descriptor.bLength;
|
latest_alternate->size += descriptor.bLength;
|
||||||
latest_configuration->interfaces.front().size += descriptor.bLength;
|
latest_configuration->interfaces.front()->size += descriptor.bLength;
|
||||||
latest_configuration->size += descriptor.bLength;
|
latest_configuration->size += descriptor.bLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::add_string_descriptor(UINT8 *descriptor)
|
void ohci_function_device::add_string_descriptor(const UINT8 *descriptor)
|
||||||
{
|
{
|
||||||
usb_device_string *ss;
|
usb_device_string *ss;
|
||||||
int len = descriptor[0];
|
int len = descriptor[0];
|
||||||
@ -1028,7 +984,7 @@ void ohci_function_device::add_string_descriptor(UINT8 *descriptor)
|
|||||||
descriptors_pos += len;
|
descriptors_pos += len;
|
||||||
ss->size = len;
|
ss->size = len;
|
||||||
ss->position = p;
|
ss->position = p;
|
||||||
device_strings.push_front(*ss);
|
device_strings.push_front(ss);
|
||||||
//latest_configuration->size += len;
|
//latest_configuration->size += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,52 +993,61 @@ void ohci_function_device::select_configuration(int index)
|
|||||||
configurationvalue = index;
|
configurationvalue = index;
|
||||||
for (auto c = configurations.begin(); c != configurations.end(); ++c)
|
for (auto c = configurations.begin(); c != configurations.end(); ++c)
|
||||||
{
|
{
|
||||||
if (c->configuration_descriptor.bConfigurationValue == index)
|
if ((*c)->configuration_descriptor.bConfigurationValue == index)
|
||||||
{
|
{
|
||||||
selected_configuration = &(*c);
|
selected_configuration = *c;
|
||||||
for (auto i = c->interfaces.begin(); i != c->interfaces.end(); ++i)
|
// by default, activate alternate setting 0 in each interface
|
||||||
|
for (auto i = (*c)->interfaces.begin(); i != (*c)->interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
i->selected_alternate = 0;
|
(*i)->selected_alternate = 0;
|
||||||
for (auto a = i->alternate_settings.begin(); a != i->alternate_settings.end(); ++a)
|
for (auto a = (*i)->alternate_settings.begin(); a != (*i)->alternate_settings.end(); ++a)
|
||||||
{
|
{
|
||||||
if (a->interface_descriptor.bAlternateSetting == 0)
|
if ((*a)->interface_descriptor.bAlternateSetting == 0)
|
||||||
{
|
{
|
||||||
for (auto e = a->endpoint_descriptors.begin(); e != a->endpoint_descriptors.end(); ++e)
|
// activate the endpoints in interface i alternate setting 0
|
||||||
|
for (auto e = (*a)->endpoint_descriptors.begin(); e != (*a)->endpoint_descriptors.end(); ++e)
|
||||||
{
|
{
|
||||||
endpoints[e->bEndpointAddress].type = e->bmAttributes & 3;
|
endpoints[e->bEndpointAddress].type = e->bmAttributes & 3;
|
||||||
endpoints[e->bEndpointAddress].remain = 0;
|
endpoints[e->bEndpointAddress].remain = 0;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ohci_function_device::select_alternate(int interfacei, int index)
|
void ohci_function_device::select_alternate(int interfacei, int index)
|
||||||
{
|
{
|
||||||
|
// among all the interfaces in the currently selected configuration, consider interface interfacei
|
||||||
for (auto i = selected_configuration->interfaces.begin(); i != selected_configuration->interfaces.end(); ++i)
|
for (auto i = selected_configuration->interfaces.begin(); i != selected_configuration->interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
for (auto a = i->alternate_settings.begin(); a != i->alternate_settings.end(); ++a)
|
// deactivate the endpoints in the currently selected alternate setting for interface interfacei
|
||||||
|
for (auto a = (*i)->alternate_settings.begin(); a != (*i)->alternate_settings.end(); ++a)
|
||||||
{
|
{
|
||||||
if ((a->interface_descriptor.bInterfaceNumber == interfacei) && (a->interface_descriptor.bAlternateSetting == i->selected_alternate))
|
if (((*a)->interface_descriptor.bInterfaceNumber == interfacei) && ((*a)->interface_descriptor.bAlternateSetting == (*i)->selected_alternate))
|
||||||
{
|
{
|
||||||
for (auto e = a->endpoint_descriptors.begin(); e != a->endpoint_descriptors.end(); ++e)
|
for (auto e = (*a)->endpoint_descriptors.begin(); e != (*a)->endpoint_descriptors.end(); ++e)
|
||||||
{
|
{
|
||||||
endpoints[e->bEndpointAddress].type = -1;
|
endpoints[e->bEndpointAddress].type = -1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto a = i->alternate_settings.begin(); a != i->alternate_settings.end(); ++a)
|
// activate the endpoints in the newly selected alternate setting
|
||||||
|
for (auto a = (*i)->alternate_settings.begin(); a != (*i)->alternate_settings.end(); ++a)
|
||||||
{
|
{
|
||||||
if ((a->interface_descriptor.bInterfaceNumber == interfacei) && (a->interface_descriptor.bAlternateSetting == index))
|
if (((*a)->interface_descriptor.bInterfaceNumber == interfacei) && ((*a)->interface_descriptor.bAlternateSetting == index))
|
||||||
{
|
{
|
||||||
i->selected_alternate = index;
|
(*i)->selected_alternate = index;
|
||||||
for (auto e = a->endpoint_descriptors.begin(); e != a->endpoint_descriptors.end(); ++e)
|
for (auto e = (*a)->endpoint_descriptors.begin(); e != (*a)->endpoint_descriptors.end(); ++e)
|
||||||
{
|
{
|
||||||
endpoints[e->bEndpointAddress].type = e->bmAttributes & 3;
|
endpoints[e->bEndpointAddress].type = e->bmAttributes & 3;
|
||||||
endpoints[e->bEndpointAddress].remain = 0;
|
endpoints[e->bEndpointAddress].remain = 0;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1090,13 +1055,14 @@ void ohci_function_device::select_alternate(int interfacei, int index)
|
|||||||
|
|
||||||
int ohci_function_device::find_alternate(int interfacei)
|
int ohci_function_device::find_alternate(int interfacei)
|
||||||
{
|
{
|
||||||
|
// find the active alternate setting for interface inteerfacei
|
||||||
for (auto i = selected_configuration->interfaces.begin(); i != selected_configuration->interfaces.end(); ++i)
|
for (auto i = selected_configuration->interfaces.begin(); i != selected_configuration->interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
for (auto a = i->alternate_settings.begin(); a != i->alternate_settings.end(); ++a)
|
for (auto a = (*i)->alternate_settings.begin(); a != (*i)->alternate_settings.end(); ++a)
|
||||||
{
|
{
|
||||||
if (a->interface_descriptor.bInterfaceNumber == interfacei)
|
if ((*a)->interface_descriptor.bInterfaceNumber == interfacei)
|
||||||
{
|
{
|
||||||
return i->selected_alternate;
|
return (*i)->selected_alternate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1113,10 +1079,10 @@ UINT8 *ohci_function_device::position_configuration_descriptor(int index, int &s
|
|||||||
{
|
{
|
||||||
for (auto c = configurations.begin(); c != configurations.end(); ++c)
|
for (auto c = configurations.begin(); c != configurations.end(); ++c)
|
||||||
{
|
{
|
||||||
if (c->configuration_descriptor.bConfigurationValue == index)
|
if ((*c)->configuration_descriptor.bConfigurationValue == (index + 1))
|
||||||
{
|
{
|
||||||
size = c->size;
|
size = (*c)->size;
|
||||||
return c->position;
|
return (*c)->position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size = 0;
|
size = 0;
|
||||||
@ -1131,8 +1097,8 @@ UINT8 *ohci_function_device::position_string_descriptor(int index, int &size)
|
|||||||
{
|
{
|
||||||
if (index == i)
|
if (index == i)
|
||||||
{
|
{
|
||||||
size = s->size;
|
size = (*s)->size;
|
||||||
return s->position;
|
return (*s)->position;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -1291,11 +1257,63 @@ int ohci_function_device::execute_transfer(int address, int endpoint, int pid, U
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ohci_function_device::handle_nonstandard_request(int endpoint, USBSetupPacket *setup)
|
const USBStandardDeviceDescriptor ohci_game_controller_device::devdesc = { 18,1,0x110,0x00,0x00,0x00,64,0x45e,0x202,0x100,0,0,0,1 };
|
||||||
|
const USBStandardConfigurationDescriptor ohci_game_controller_device::condesc = { 9,2,0x20,1,1,0,0x80,50 };
|
||||||
|
const USBStandardInterfaceDescriptor ohci_game_controller_device::intdesc = { 9,4,0,0,2,0x58,0x42,0,0 };
|
||||||
|
const USBStandardEndpointDescriptor ohci_game_controller_device::enddesc82 = { 7,5,0x82,3,0x20,4 };
|
||||||
|
const USBStandardEndpointDescriptor ohci_game_controller_device::enddesc02 = { 7,5,0x02,3,0x20,4 };
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//ic10
|
||||||
|
static USBStandardDeviceDescriptor ohci_hlean2131qc_device::devdesc = { 0x12,0x01,0x0100,0x60,0x00,0x00,0x40,0x0CA3,0x0002,0x0108,0x01,0x02,0x00,0x01 };
|
||||||
|
static USBStandardConfigurationDescriptor ohci_hlean2131qc_device::condesc = { 0x09,0x02,0x0058,0x01,0x01,0x00,0x80,0x96 };
|
||||||
|
static USBStandardInterfaceDescriptor ohci_hlean2131qc_device::intdesc = { 0x09,0x04,0x00,0x00,0x0A,0xFF,0x00,0x00,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc01 = { 0x07,0x05,0x01,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc02 = { 0x07,0x05,0x02,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc03 = { 0x07,0x05,0x03,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc04 = { 0x07,0x05,0x04,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc05 = { 0x07,0x05,0x05,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc81 = { 0x07,0x05,0x81,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc82 = { 0x07,0x05,0x82,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc83 = { 0x07,0x05,0x83,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc84 = { 0x07,0x05,0x84,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc85 = { 0x07,0x05,0x85,0x02,0x0040,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131qc_device::strdesc0[] = { 0x04,0x03,0x00,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131qc_device::strdesc1[] = { 0x0A,0x03,0x53,0x00,0x45,0x00,0x47,0x00,0x41,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131qc_device::strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0x00,0x53,0x00,0x45,0x00,0x42,0x03,0xFF,0x0B };
|
||||||
|
|
||||||
|
//pc20
|
||||||
|
static USBStandardDeviceDescriptor ohci_hlean2131sc_device::devdesc = { 0x12,0x01,0x0100,0x60,0x01,0x00,0x40,0x0CA3,0x0003,0x0110,0x01,0x02,0x00,0x01 };
|
||||||
|
static USBStandardConfigurationDescriptor ohci_hlean2131sc_device::condesc = { 0x09,0x02,0x003C,0x01,0x01,0x00,0x80,0x96 };
|
||||||
|
static USBStandardInterfaceDescriptor ohci_hlean2131sc_device::intdesc = { 0x09,0x04,0x00,0x00,0x06,0xFF,0x00,0x00,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc01 = { 0x07,0x05,0x01,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc02 = { 0x07,0x05,0x02,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc03 = { 0x07,0x05,0x03,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc81 = { 0x07,0x05,0x81,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc82 = { 0x07,0x05,0x82,0x02,0x0040,0x00 };
|
||||||
|
static USBStandardEndpointDescriptor ohci_hlean2131sc_device::enddesc83 = { 0x07,0x05,0x83,0x02,0x0040,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131sc_device::strdesc0[] = { 0x04,0x03,0x00,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131sc_device::strdesc1[] = { 0x0A,0x03,0x53,0x00,0x45,0x00,0x47,0x00,0x41,0x00 };
|
||||||
|
static UINT8 ohci_hlean2131sc_device::strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0x00,0x53,0x00,0x45,0x00,0x42,0x00,0x44,0x00 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ohci_game_controller_device::ohci_game_controller_device(running_machine &machine) :
|
||||||
|
ohci_function_device(machine)
|
||||||
|
{
|
||||||
|
add_device_descriptor(devdesc);
|
||||||
|
add_configuration_descriptor(condesc);
|
||||||
|
add_interface_descriptor(intdesc);
|
||||||
|
add_endpoint_descriptor(enddesc82);
|
||||||
|
add_endpoint_descriptor(enddesc02);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ohci_game_controller_device::handle_nonstandard_request(int endpoint, USBSetupPacket *setup)
|
||||||
{
|
{
|
||||||
// >=8 ==42 !=0 !=0 1,3 2<20 <=20
|
// >=8 ==42 !=0 !=0 1,3 2<20 <=20
|
||||||
static UINT8 mytestdata[16] = { 0x10,0x42 ,0x32,0x43,1 ,0x65,0x18,0x20,0x98,0xa9,0xba,0xcb,0xdc,0xed,0xfe };
|
static UINT8 mytestdata[16] = { 0x10,0x42 ,0x32,0x43,1 ,0x65,0x18,0x20,0x98,0xa9,0xba,0xcb,0xdc,0xed,0xfe };
|
||||||
|
|
||||||
|
if (endpoint != 0)
|
||||||
|
return -1;
|
||||||
if ((endpoints[endpoint].controltype == VendorType) && (endpoints[endpoint].controlrecipient == InterfaceRecipient))
|
if ((endpoints[endpoint].controltype == VendorType) && (endpoints[endpoint].controlrecipient == InterfaceRecipient))
|
||||||
{
|
{
|
||||||
if (setup->bRequest == GET_DESCRIPTOR)
|
if (setup->bRequest == GET_DESCRIPTOR)
|
||||||
@ -1964,7 +1982,7 @@ ADDRESS_MAP_END
|
|||||||
void xbox_base_state::machine_start()
|
void xbox_base_state::machine_start()
|
||||||
{
|
{
|
||||||
#ifdef USB_ENABLED
|
#ifdef USB_ENABLED
|
||||||
ohci_function_device *usb_device;
|
ohci_game_controller_device *usb_device;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nvidia_nv2a = std::make_unique<nv2a_renderer>(machine());
|
nvidia_nv2a = std::make_unique<nv2a_renderer>(machine());
|
||||||
@ -2005,7 +2023,7 @@ void xbox_base_state::machine_start()
|
|||||||
ohcist.space = &m_maincpu->space();
|
ohcist.space = &m_maincpu->space();
|
||||||
ohcist.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xbox_base_state::usb_ohci_timer), this), (void *)"USB OHCI Timer");
|
ohcist.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xbox_base_state::usb_ohci_timer), this), (void *)"USB OHCI Timer");
|
||||||
ohcist.timer->enable(false);
|
ohcist.timer->enable(false);
|
||||||
usb_device = new ohci_function_device(machine());
|
usb_device = new ohci_game_controller_device(machine());
|
||||||
usb_ohci_plug(1, usb_device); // test connect
|
usb_ohci_plug(1, usb_device); // test connect
|
||||||
#endif
|
#endif
|
||||||
memset(&superiost, 0, sizeof(superiost));
|
memset(&superiost, 0, sizeof(superiost));
|
||||||
|
Loading…
Reference in New Issue
Block a user