mirror of https://github.com/PCSX2/pcsx2.git
USB: initial merge relatively complete, linking issues left
This commit is contained in:
parent
eb4089657e
commit
d33eff635b
|
@ -78,16 +78,6 @@ Config::Config(): Log(0)
|
||||||
memset(&WheelType, 0, sizeof(WheelType));
|
memset(&WheelType, 0, sizeof(WheelType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __Log(const char *fmt, ...) {
|
|
||||||
va_list list;
|
|
||||||
|
|
||||||
if (!conf.Log ||!usbLog) return;
|
|
||||||
|
|
||||||
va_start(list, fmt);
|
|
||||||
vfprintf(usbLog, fmt, list);
|
|
||||||
va_end(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Simpler to reset and reattach after USBclose/USBopen
|
//Simpler to reset and reattach after USBclose/USBopen
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,9 +35,9 @@ std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
||||||
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, TSTDSTRING& value)
|
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, TSTDSTRING& value)
|
||||||
{
|
{
|
||||||
CIniKey *key;
|
CIniKey *key;
|
||||||
auto sect = ciniFile.GetSection(section);
|
auto sect = ciniFile.GetSection(str_to_wstr(section));
|
||||||
if (sect && (key = sect->GetKey(param))) {
|
if (sect && (key = sect->GetKey(str_to_wstr(param)))) {
|
||||||
value = key->GetValue();
|
value = wstr_to_str(key->GetValue());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,8 +46,8 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t& value)
|
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t& value)
|
||||||
{
|
{
|
||||||
CIniKey *key;
|
CIniKey *key;
|
||||||
auto sect = ciniFile.GetSection(section);
|
auto sect = ciniFile.GetSection(str_to_wstr(section));
|
||||||
if (sect && (key = sect->GetKey(param))) {
|
if (sect && (key = sect->GetKey(str_to_wstr(param)))) {
|
||||||
try {
|
try {
|
||||||
value = std::stoi(key->GetValue());
|
value = std::stoi(key->GetValue());
|
||||||
return true;
|
return true;
|
||||||
|
@ -61,19 +61,19 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
|
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const TSTDSTRING& value)
|
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const TSTDSTRING& value)
|
||||||
{
|
{
|
||||||
ciniFile.SetKeyValue(section, param, value);
|
ciniFile.SetKeyValue(str_to_wstr(section), str_to_wstr(param), str_to_wstr(value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t value)
|
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t value)
|
||||||
{
|
{
|
||||||
ciniFile.SetKeyValue(section, param, TSTDTOSTRING(value));
|
ciniFile.SetKeyValue(str_to_wstr(section), str_to_wstr(param), str_to_wstr(TSTDTOSTRING(value)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveConfig() {
|
void SaveConfig() {
|
||||||
|
|
||||||
SaveSetting(_T("MAIN"), _T("log"), conf.Log);
|
SaveSetting("MAIN", "log", conf.Log);
|
||||||
|
|
||||||
SaveSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
|
SaveSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
|
||||||
SaveSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
|
SaveSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
|
||||||
|
@ -86,15 +86,15 @@ void SaveConfig() {
|
||||||
SaveSetting(nullptr, k.first.first, k.first.second, N_DEVICE_API, k.second);
|
SaveSetting(nullptr, k.first.first, k.first.second, N_DEVICE_API, k.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = ciniFile.Save(IniPath);
|
ciniFile.Save(str_to_wstr(IniPath));
|
||||||
OSDebugOut(_T("ciniFile.Save: %d [%s]\n"), ret, IniPath.c_str());
|
OSDebugOut(_T("ciniFile.Save: %d [%s]\n"), ret, IniPath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig() {
|
void LoadConfig() {
|
||||||
std::cerr << "USB load config\n" << std::endl;
|
std::cerr << "USB load config\n" << std::endl;
|
||||||
ciniFile.Load(IniPath);
|
ciniFile.Load(str_to_wstr(IniPath));
|
||||||
|
|
||||||
LoadSetting(_T("MAIN"), _T("log"), conf.Log);
|
LoadSetting("MAIN", "log", conf.Log);
|
||||||
|
|
||||||
LoadSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
|
LoadSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
|
||||||
LoadSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
|
LoadSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
|
||||||
|
@ -133,7 +133,7 @@ void LoadConfig() {
|
||||||
|
|
||||||
void ClearSection(const TCHAR* section)
|
void ClearSection(const TCHAR* section)
|
||||||
{
|
{
|
||||||
auto s = ciniFile.GetSection(section);
|
auto s = ciniFile.GetSection(str_to_wstr(section));
|
||||||
if (s) {
|
if (s) {
|
||||||
s->RemoveAllKeys();
|
s->RemoveAllKeys();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
|
#include "../platcompat.h"
|
||||||
#include "vl.h"
|
#include "vl.h"
|
||||||
#include "iov.h"
|
#include "iov.h"
|
||||||
//#include "trace.h"
|
//#include "trace.h"
|
||||||
|
@ -39,7 +40,7 @@ void usb_pick_speed(USBPort *port)
|
||||||
USBDevice *udev = port->dev;
|
USBDevice *udev = port->dev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(speeds); i++) {
|
for (i = 0; i < (int)ARRAY_SIZE(speeds); i++) {
|
||||||
if ((udev->speedmask & (1 << speeds[i])) &&
|
if ((udev->speedmask & (1 << speeds[i])) &&
|
||||||
(port->speedmask & (1 << speeds[i]))) {
|
(port->speedmask & (1 << speeds[i]))) {
|
||||||
udev->speed = speeds[i];
|
udev->speed = speeds[i];
|
||||||
|
@ -138,7 +139,7 @@ static void do_token_setup(USBDevice *s, USBPacket *p)
|
||||||
s->setup_index = 0;
|
s->setup_index = 0;
|
||||||
p->actual_length = 0;
|
p->actual_length = 0;
|
||||||
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||||
if (s->setup_len > sizeof(s->data_buf)) {
|
if (s->setup_len > (int32_t)sizeof(s->data_buf)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||||
s->setup_len, sizeof(s->data_buf));
|
s->setup_len, sizeof(s->data_buf));
|
||||||
|
@ -200,7 +201,7 @@ static void do_token_in(USBDevice *s, USBPacket *p)
|
||||||
case SETUP_STATE_DATA:
|
case SETUP_STATE_DATA:
|
||||||
if (s->setup_buf[0] & USB_DIR_IN) {
|
if (s->setup_buf[0] & USB_DIR_IN) {
|
||||||
int len = s->setup_len - s->setup_index;
|
int len = s->setup_len - s->setup_index;
|
||||||
if (len > p->iov.size) {
|
if ((size_t)len > p->iov.size) {
|
||||||
len = p->iov.size;
|
len = p->iov.size;
|
||||||
}
|
}
|
||||||
usb_packet_copy(p, s->data_buf + s->setup_index, len);
|
usb_packet_copy(p, s->data_buf + s->setup_index, len);
|
||||||
|
@ -236,7 +237,7 @@ static void do_token_out(USBDevice *s, USBPacket *p)
|
||||||
case SETUP_STATE_DATA:
|
case SETUP_STATE_DATA:
|
||||||
if (!(s->setup_buf[0] & USB_DIR_IN)) {
|
if (!(s->setup_buf[0] & USB_DIR_IN)) {
|
||||||
int len = s->setup_len - s->setup_index;
|
int len = s->setup_len - s->setup_index;
|
||||||
if (len > p->iov.size) {
|
if ((size_t)len > p->iov.size) {
|
||||||
len = p->iov.size;
|
len = p->iov.size;
|
||||||
}
|
}
|
||||||
usb_packet_copy(p, s->data_buf + s->setup_index, len);
|
usb_packet_copy(p, s->data_buf + s->setup_index, len);
|
||||||
|
@ -271,7 +272,7 @@ static void do_parameter(USBDevice *s, USBPacket *p)
|
||||||
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
||||||
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
|
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
|
||||||
|
|
||||||
if (s->setup_len > sizeof(s->data_buf)) {
|
if (s->setup_len > (int32_t)sizeof(s->data_buf)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||||
s->setup_len, sizeof(s->data_buf));
|
s->setup_len, sizeof(s->data_buf));
|
||||||
|
@ -450,7 +451,7 @@ void usb_packet_complete_one(USBDevice *dev, USBPacket *p)
|
||||||
assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK);
|
assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK);
|
||||||
|
|
||||||
if (p->status != USB_RET_SUCCESS ||
|
if (p->status != USB_RET_SUCCESS ||
|
||||||
(p->short_not_ok && (p->actual_length < p->iov.size))) {
|
(p->short_not_ok && ((size_t)p->actual_length < p->iov.size))) {
|
||||||
ep->halted = true;
|
ep->halted = true;
|
||||||
}
|
}
|
||||||
usb_packet_set_state(p, USB_PACKET_COMPLETE);
|
usb_packet_set_state(p, USB_PACKET_COMPLETE);
|
||||||
|
@ -527,14 +528,9 @@ static const char *usb_packet_state_name(USBPacketState state)
|
||||||
|
|
||||||
void usb_packet_check_state(USBPacket *p, USBPacketState expected)
|
void usb_packet_check_state(USBPacket *p, USBPacketState expected)
|
||||||
{
|
{
|
||||||
USBDevice *dev;
|
|
||||||
USBBus *bus;
|
|
||||||
|
|
||||||
if (p->state == expected) {
|
if (p->state == expected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev = p->ep->dev;
|
|
||||||
bus = dev->bus; //usb_bus_from_device(dev);
|
|
||||||
//trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p,
|
//trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p,
|
||||||
// usb_packet_state_name(p->state),
|
// usb_packet_state_name(p->state),
|
||||||
// usb_packet_state_name(expected));
|
// usb_packet_state_name(expected));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "vl.h"
|
#include "vl.h"
|
||||||
#include "desc.h"
|
#include "desc.h"
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
//#include "trace.h"
|
//#include "trace.h"
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
@ -128,7 +128,6 @@ int usb_desc_iface_group(const USBDescIfaceAssoc& iad, int flags,
|
||||||
uint8_t *dest, size_t len)
|
uint8_t *dest, size_t len)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
/* handle interface association descriptor */
|
/* handle interface association descriptor */
|
||||||
uint8_t bLength = 0x08;
|
uint8_t bLength = 0x08;
|
||||||
|
@ -209,7 +208,7 @@ int usb_desc_endpoint(const USBDescEndpoint& ep, int flags,
|
||||||
uint8_t superlen = (flags & USB_DESC_FLAG_SUPER) ? 0x06 : 0;
|
uint8_t superlen = (flags & USB_DESC_FLAG_SUPER) ? 0x06 : 0;
|
||||||
USBDescriptor *d = (USBDescriptor *)dest;
|
USBDescriptor *d = (USBDescriptor *)dest;
|
||||||
|
|
||||||
if (len < bLength + extralen + superlen) {
|
if (len < (size_t)(bLength + extralen + superlen)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ int usb_desc_other(const USBDescOther& desc, uint8_t *dest, size_t len)
|
||||||
{
|
{
|
||||||
int bLength = desc.length ? desc.length : desc.data[0];
|
int bLength = desc.length ? desc.length : desc.data[0];
|
||||||
|
|
||||||
if (len < bLength) {
|
if (len < (size_t)bLength) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +388,6 @@ int usb_desc_parse_config (const uint8_t *data, int len, USBDescDevice& dev)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
USBDescIface *iface = nullptr;
|
USBDescIface *iface = nullptr;
|
||||||
USBDescIfaceAssoc *ifaceAssoc = nullptr;
|
|
||||||
USBDescConfig *config = nullptr;
|
USBDescConfig *config = nullptr;
|
||||||
USBDescriptor *d;
|
USBDescriptor *d;
|
||||||
|
|
||||||
|
@ -668,7 +666,7 @@ int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len)
|
||||||
dest[0] = bLength;
|
dest[0] = bLength;
|
||||||
dest[1] = USB_DT_STRING;
|
dest[1] = USB_DT_STRING;
|
||||||
i = 0; pos = 2;
|
i = 0; pos = 2;
|
||||||
while (pos+1 < bLength && pos+1 < len) {
|
while (pos+1 < bLength && (size_t)(pos+1) < len) {
|
||||||
dest[pos++] = str[i++];
|
dest[pos++] = str[i++];
|
||||||
dest[pos++] = 0;
|
dest[pos++] = 0;
|
||||||
}
|
}
|
||||||
|
@ -744,7 +742,7 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
if (ret > len) {
|
if ((size_t)ret > len) {
|
||||||
ret = len;
|
ret = len;
|
||||||
}
|
}
|
||||||
memcpy(dest, buf, ret);
|
memcpy(dest, buf, ret);
|
||||||
|
@ -757,11 +755,9 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,
|
||||||
int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
|
int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
|
||||||
int request, int value, int index, int length, uint8_t *data)
|
int request, int value, int index, int length, uint8_t *data)
|
||||||
{
|
{
|
||||||
bool msos = (dev->flags & (1 << USB_DEV_FLAG_MSOS_DESC_IN_USE));
|
assert(usb_device_get_usb_desc(dev) != NULL);
|
||||||
const USBDesc *desc = usb_device_get_usb_desc(dev);
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
assert(desc != NULL);
|
|
||||||
switch(request) {
|
switch(request) {
|
||||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||||
dev->addr = value;
|
dev->addr = value;
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
#define GLIB_H
|
#define GLIB_H
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "gmem-size.h"
|
|
||||||
|
#ifdef __M_X86_64
|
||||||
|
#define G_MAXSIZE G_MAXUINT64
|
||||||
|
#else
|
||||||
|
#define G_MAXSIZE G_MAXUINT32
|
||||||
|
#endif
|
||||||
|
|
||||||
#define G_MAXUINT64 0xffffffffffffffffUL
|
#define G_MAXUINT64 0xffffffffffffffffUL
|
||||||
#define G_MAXUINT32 ((uint32_t)0xffffffff)
|
#define G_MAXUINT32 ((uint32_t)0xffffffff)
|
||||||
|
@ -28,4 +33,4 @@ void* my_g_realloc_n (void* mem,
|
||||||
#define my_g_new(struct_type, n_structs) my_G_NEW (struct_type, n_structs, malloc)
|
#define my_g_new(struct_type, n_structs) my_G_NEW (struct_type, n_structs, malloc)
|
||||||
#define my_g_renew(struct_type, mem, n_structs) my_G_RENEW (struct_type, mem, n_structs, realloc)
|
#define my_g_renew(struct_type, mem, n_structs) my_G_RENEW (struct_type, mem, n_structs, realloc)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
#include "input-keymap.h"
|
#include "input-keymap.h"
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
|
|
||||||
#define HID_USAGE_ERROR_ROLLOVER 0x01
|
#define HID_USAGE_ERROR_ROLLOVER 0x01
|
||||||
#define HID_USAGE_POSTFAIL 0x02
|
#define HID_USAGE_POSTFAIL 0x02
|
||||||
|
@ -283,6 +283,7 @@ static void hid_keyboard_process_keycode(HIDState *hs)
|
||||||
}
|
}
|
||||||
/* fall through to process Ctrl_L */
|
/* fall through to process Ctrl_L */
|
||||||
//case 0xe1 ... 0xe7:
|
//case 0xe1 ... 0xe7:
|
||||||
|
[[fallthrough]];
|
||||||
case 0xe1:
|
case 0xe1:
|
||||||
case 0xe2:
|
case 0xe2:
|
||||||
case 0xe3:
|
case 0xe3:
|
||||||
|
@ -341,7 +342,7 @@ static void hid_keyboard_process_keycode(HIDState *hs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
if (hs->kbd.keys < sizeof(hs->kbd.key)) {
|
if (hs->kbd.keys < (int32_t)sizeof(hs->kbd.key)) {
|
||||||
hs->kbd.key[hs->kbd.keys++] = hid_code;
|
hs->kbd.key[hs->kbd.keys++] = hid_code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,12 +379,10 @@ size_t iov_discard_back(struct iovec *iov, unsigned int *iov_cnt,
|
||||||
|
|
||||||
void qemu_iovec_discard_back(QEMUIOVector *qiov, size_t bytes)
|
void qemu_iovec_discard_back(QEMUIOVector *qiov, size_t bytes)
|
||||||
{
|
{
|
||||||
size_t total;
|
|
||||||
unsigned int niov = qiov->niov;
|
unsigned int niov = qiov->niov;
|
||||||
|
|
||||||
assert(qiov->size >= bytes);
|
assert(qiov->size >= bytes);
|
||||||
total = iov_discard_back(qiov->iov, &niov, bytes);
|
assert(iov_discard_back(qiov->iov, &niov, bytes) == bytes);
|
||||||
assert(total == bytes);
|
|
||||||
|
|
||||||
qiov->niov = niov;
|
qiov->niov = niov;
|
||||||
qiov->size -= bytes;
|
qiov->size -= bytes;
|
||||||
|
|
|
@ -537,5 +537,9 @@ typedef KeyIndexA KeyIndex;
|
||||||
typedef SecIndexA SecIndex;
|
typedef SecIndexA SecIndex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
std::wstring str_to_wstr(const std::string& arg);
|
||||||
|
std::string wstr_to_str(const std::wstring& arg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DPRINTF OSDebugOut
|
#define DPRINTF OSDebugOut
|
||||||
|
@ -152,8 +152,6 @@ size_t RingBuffer::peek_read() const
|
||||||
|
|
||||||
void RingBuffer::write(size_t bytes)
|
void RingBuffer::write(size_t bytes)
|
||||||
{
|
{
|
||||||
size_t before = m_end;
|
|
||||||
|
|
||||||
//assert( bytes <= m_capacity - size() );
|
//assert( bytes <= m_capacity - size() );
|
||||||
|
|
||||||
// push m_begin forward if m_end overlaps it
|
// push m_begin forward if m_end overlaps it
|
||||||
|
@ -175,7 +173,6 @@ void RingBuffer::read(size_t bytes)
|
||||||
{
|
{
|
||||||
assert( bytes <= size() );
|
assert( bytes <= size() );
|
||||||
|
|
||||||
size_t before = m_begin;
|
|
||||||
m_overrun = false;
|
m_overrun = false;
|
||||||
if ((m_begin < m_end && m_begin + bytes > m_end) ||
|
if ((m_begin < m_end && m_begin + bytes > m_end) ||
|
||||||
m_begin + bytes > m_end + m_capacity)
|
m_begin + bytes > m_end + m_capacity)
|
||||||
|
|
|
@ -74,12 +74,14 @@ public:
|
||||||
{
|
{
|
||||||
return std::chrono::duration_cast<ms>(hrc::now()-mLastWrite).count();
|
return std::chrono::duration_cast<ms>(hrc::now()-mLastWrite).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_overrun;
|
size_t m_capacity;
|
||||||
size_t m_begin, m_end, m_capacity;
|
|
||||||
char *m_data;
|
char *m_data;
|
||||||
|
size_t m_begin;
|
||||||
|
bool m_overrun;
|
||||||
|
size_t m_end;
|
||||||
hrc::time_point mLastWrite = hrc::time_point(ns(0));
|
hrc::time_point mLastWrite = hrc::time_point(ns(0));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -421,9 +421,7 @@ static void eyetoy_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
EYETOYState *s = (EYETOYState *)dev;
|
EYETOYState *s = (EYETOYState *)dev;
|
||||||
static const int max_ep_size = 896;
|
static const int max_ep_size = 896;
|
||||||
uint8_t data[max_ep_size];
|
uint8_t data[max_ep_size];
|
||||||
int ret = 0;
|
|
||||||
uint8_t devep = p->ep->nr;
|
uint8_t devep = p->ep->nr;
|
||||||
size_t len = p->iov.size;
|
|
||||||
|
|
||||||
switch(p->pid) {
|
switch(p->pid) {
|
||||||
case USB_TOKEN_IN:
|
case USB_TOKEN_IN:
|
||||||
|
@ -578,8 +576,6 @@ int EyeToyWebCamDevice::Configure(int port, const std::string& api, void *data)
|
||||||
|
|
||||||
int EyeToyWebCamDevice::Freeze(int mode, USBDevice *dev, void *data)
|
int EyeToyWebCamDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
{
|
{
|
||||||
EYETOYState *s = (EYETOYState *)dev;
|
|
||||||
|
|
||||||
/*switch (mode)
|
/*switch (mode)
|
||||||
{
|
{
|
||||||
case FREEZE_LOAD:
|
case FREEZE_LOAD:
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "hidproxy.h"
|
#include "hidproxy.h"
|
||||||
#include "../qemu-usb/desc.h"
|
#include "../qemu-usb/desc.h"
|
||||||
#include "usb-hid.h"
|
#include "usb-hid.h"
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
|
|
||||||
#define CONTAINER_OF(p, type, field) ((type*) ((char*)p - ((ptrdiff_t)&((type*)0)->field)))
|
#define CONTAINER_OF(p, type, field) ((type*) ((char*)p - ((ptrdiff_t)&((type*)0)->field)))
|
||||||
|
|
||||||
|
@ -720,4 +720,4 @@ int HIDMouseDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
return HIDKbdDevice::Freeze(mode, dev, data);
|
return HIDKbdDevice::Freeze(mode, dev, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
|
@ -658,7 +658,6 @@ static int usb_audio_ep_control(HeadsetState *s, uint8_t attrib,
|
||||||
int length, uint8_t *data)
|
int length, uint8_t *data)
|
||||||
{
|
{
|
||||||
uint8_t cs = cscn >> 8;
|
uint8_t cs = cscn >> 8;
|
||||||
uint8_t cn = cscn - 1; /* -1 for the non-present master control */
|
|
||||||
uint32_t aid = ATTRIB_ID(cs, attrib, ep);
|
uint32_t aid = ATTRIB_ID(cs, attrib, ep);
|
||||||
int ret = USB_RET_STALL;
|
int ret = USB_RET_STALL;
|
||||||
|
|
||||||
|
@ -902,7 +901,6 @@ static void headset_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fail:
|
|
||||||
p->status = USB_RET_STALL;
|
p->status = USB_RET_STALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1068,4 +1066,4 @@ int HeadsetDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,6 @@ USBDevice* LogitechMicDevice::CreateDevice(int port)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SINGSTARMICMINIState *s = (SINGSTARMICMINIState *)dev;
|
SINGSTARMICMINIState *s = (SINGSTARMICMINIState *)dev;
|
||||||
const USBDescDevice *full = s->desc.full;
|
|
||||||
s->desc = {};
|
s->desc = {};
|
||||||
s->desc_dev = {};
|
s->desc_dev = {};
|
||||||
|
|
||||||
|
@ -256,4 +255,4 @@ fail:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -694,8 +694,8 @@ static void singstar_mic_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
case USB_TOKEN_OUT:
|
case USB_TOKEN_OUT:
|
||||||
printf("token out ep: %d\n", devep);
|
printf("token out ep: %d\n", devep);
|
||||||
OSDebugOut(TEXT("token out ep: %d len: %d\n"), devep, p->actual_length);
|
OSDebugOut(TEXT("token out ep: %d len: %d\n"), devep, p->actual_length);
|
||||||
|
[[fallthrough]];
|
||||||
default:
|
default:
|
||||||
fail:
|
|
||||||
p->status = USB_RET_STALL;
|
p->status = USB_RET_STALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -861,4 +861,4 @@ int SingstarDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,7 +780,6 @@ static void usb_msd_handle_control(USBDevice *dev, USBPacket *p, int request, in
|
||||||
p->actual_length = 1;
|
p->actual_length = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fail:
|
|
||||||
p->status = USB_RET_STALL;
|
p->status = USB_RET_STALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -801,8 +800,6 @@ static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p)
|
||||||
static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
|
static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
{
|
{
|
||||||
MSDState *s = (MSDState *)dev;
|
MSDState *s = (MSDState *)dev;
|
||||||
int ret = 0;
|
|
||||||
size_t file_ret = 0;
|
|
||||||
struct usb_msd_cbw cbw;
|
struct usb_msd_cbw cbw;
|
||||||
uint8_t devep = p->ep->nr;
|
uint8_t devep = p->ep->nr;
|
||||||
|
|
||||||
|
@ -877,7 +874,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->actual_length < p->iov.size) {
|
if ((size_t)p->actual_length < p->iov.size) {
|
||||||
DPRINTF("Deferring packet %p [wait data-out]\n", p);
|
DPRINTF("Deferring packet %p [wait data-out]\n", p);
|
||||||
s->packet = p;
|
s->packet = p;
|
||||||
p->status = USB_RET_ASYNC;
|
p->status = USB_RET_ASYNC;
|
||||||
|
@ -955,7 +952,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->actual_length < p->iov.size) {
|
if ((size_t)p->actual_length < p->iov.size) {
|
||||||
DPRINTF("Deferring packet %p [wait data-in]\n", p);
|
DPRINTF("Deferring packet %p [wait data-in]\n", p);
|
||||||
s->packet = p;
|
s->packet = p;
|
||||||
p->status = USB_RET_ASYNC;
|
p->status = USB_RET_ASYNC;
|
||||||
|
@ -1049,7 +1046,6 @@ const char* MsdDevice::TypeName()
|
||||||
|
|
||||||
int MsdDevice::Freeze(int mode, USBDevice *dev, void *data)
|
int MsdDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
{
|
{
|
||||||
uint32_t fat32_serial = 0;
|
|
||||||
MSDState *s = (MSDState *)dev;
|
MSDState *s = (MSDState *)dev;
|
||||||
MSDState::freeze *tmp;
|
MSDState::freeze *tmp;
|
||||||
|
|
||||||
|
@ -1085,4 +1081,4 @@ int MsdDevice::Freeze(int mode, USBDevice *dev, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DPRINTF
|
#undef DPRINTF
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "usb-pad.h"
|
#include "usb-pad.h"
|
||||||
#include "lg/lg_ff.h"
|
#include "lg/lg_ff.h"
|
||||||
#include "osdebugout.h"
|
#include "../osdebugout.h"
|
||||||
|
|
||||||
namespace usb_pad {
|
namespace usb_pad {
|
||||||
|
|
||||||
|
@ -266,4 +266,4 @@ void Pad::ParseFFData(const ff_data *ffdata, bool isDFP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
|
@ -164,7 +164,7 @@ static void pad_handle_data(USBDevice *dev, USBPacket *p)
|
||||||
if (devep == 1 && s->pad) {
|
if (devep == 1 && s->pad) {
|
||||||
ret = s->pad->TokenIn(data, p->iov.size);
|
ret = s->pad->TokenIn(data, p->iov.size);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
usb_packet_copy (p, data, MIN(ret, sizeof(data)));
|
usb_packet_copy (p, data, MIN(ret, (int)sizeof(data)));
|
||||||
else
|
else
|
||||||
p->status = ret;
|
p->status = ret;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "FW.h"
|
#include "FW.h"
|
||||||
#include "SPU2/spu2.h"
|
#include "SPU2/spu2.h"
|
||||||
#include "DEV9/DEV9.h"
|
#include "DEV9/DEV9.h"
|
||||||
|
#include "USB/USB.h"
|
||||||
|
|
||||||
#include "ps2/pgif.h"
|
#include "ps2/pgif.h"
|
||||||
#include "Mdec.h"
|
#include "Mdec.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "CDVD/CdRom.h"
|
#include "CDVD/CdRom.h"
|
||||||
#include "SPU2/spu2.h"
|
#include "SPU2/spu2.h"
|
||||||
#include "DEV9/DEV9.h"
|
#include "DEV9/DEV9.h"
|
||||||
|
#include "USB/USB.h"
|
||||||
|
|
||||||
#include "ps2/pgif.h"
|
#include "ps2/pgif.h"
|
||||||
#include "Mdec.h"
|
#include "Mdec.h"
|
||||||
|
|
Loading…
Reference in New Issue