mirror of https://github.com/PCSX2/pcsx2.git
USB: cleaning up a bunch of warnings, platcompat fixes
This commit is contained in:
parent
50969601bf
commit
eb4089657e
|
@ -365,6 +365,7 @@ set(pcsx2USBHeaders
|
||||||
USB/deviceproxy.h
|
USB/deviceproxy.h
|
||||||
USB/configuration.h
|
USB/configuration.h
|
||||||
USB/osdebugout.h
|
USB/osdebugout.h
|
||||||
|
USB/platcompat.h
|
||||||
USB/helpers.h
|
USB/helpers.h
|
||||||
USB/readerwriterqueue/readerwriterqueue.h
|
USB/readerwriterqueue/readerwriterqueue.h
|
||||||
USB/readerwriterqueue/atomicops.h
|
USB/readerwriterqueue/atomicops.h
|
||||||
|
|
|
@ -339,7 +339,7 @@ s32 USBfreeze(int mode, freezeData *data) {
|
||||||
//TODO FREEZE_SIZE mismatch causes loading to fail in PCSX2 beforehand
|
//TODO FREEZE_SIZE mismatch causes loading to fail in PCSX2 beforehand
|
||||||
if (mode == FREEZE_LOAD)
|
if (mode == FREEZE_LOAD)
|
||||||
{
|
{
|
||||||
if(data->size < sizeof(USBfreezeData))
|
if((long unsigned int)data->size < sizeof(USBfreezeData))
|
||||||
{
|
{
|
||||||
SysMessage(TEXT("ERROR: Unable to load freeze data! Got %d bytes, expected >= %d.\n"), data->size, sizeof(USBfreezeData));
|
SysMessage(TEXT("ERROR: Unable to load freeze data! Got %d bytes, expected >= %d.\n"), data->size, sizeof(USBfreezeData));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -358,7 +358,7 @@ s32 USBfreeze(int mode, freezeData *data) {
|
||||||
//clocks = usbd.cycles;
|
//clocks = usbd.cycles;
|
||||||
//remaining = usbd.remaining;
|
//remaining = usbd.remaining;
|
||||||
|
|
||||||
for(int i=0; i< qemu_ohci->num_ports; i++)
|
for(uint32_t i=0; i< qemu_ohci->num_ports; i++)
|
||||||
{
|
{
|
||||||
usbd.t.rhport[i].port.opaque = qemu_ohci;
|
usbd.t.rhport[i].port.opaque = qemu_ohci;
|
||||||
usbd.t.rhport[i].port.ops = qemu_ohci->rhport[i].port.ops;
|
usbd.t.rhport[i].port.ops = qemu_ohci->rhport[i].port.ops;
|
||||||
|
@ -368,7 +368,7 @@ s32 USBfreeze(int mode, freezeData *data) {
|
||||||
|
|
||||||
s8 *ptr = data->data + sizeof(USBfreezeData);
|
s8 *ptr = data->data + sizeof(USBfreezeData);
|
||||||
// Load the state of the attached devices
|
// Load the state of the attached devices
|
||||||
if (data->size != sizeof(USBfreezeData) + usbd.device[0].size + usbd.device[1].size + 8192)
|
if ((long unsigned int)data->size != sizeof(USBfreezeData) + usbd.device[0].size + usbd.device[1].size + 8192)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
RegisterDevice& regInst = RegisterDevice::instance();
|
RegisterDevice& regInst = RegisterDevice::instance();
|
||||||
|
@ -398,7 +398,7 @@ s32 USBfreeze(int mode, freezeData *data) {
|
||||||
|
|
||||||
if (proxy && usb_device[i]) /* usb device creation may have failed for some reason */
|
if (proxy && usb_device[i]) /* usb device creation may have failed for some reason */
|
||||||
{
|
{
|
||||||
if (proxy->Freeze(FREEZE_SIZE, usb_device[i], nullptr) != usbd.device[i].size)
|
if (proxy->Freeze(FREEZE_SIZE, usb_device[i], nullptr) != (s32)usbd.device[i].size)
|
||||||
{
|
{
|
||||||
SysMessage(TEXT("Port %d: device's freeze size doesn't match.\n"), 1+(1-i));
|
SysMessage(TEXT("Port %d: device's freeze size doesn't match.\n"), 1+(1-i));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -509,13 +509,13 @@ s32 USBfreeze(int mode, freezeData *data) {
|
||||||
usbd.usb_packet.dev_index = i;
|
usbd.usb_packet.dev_index = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(usbd.freezeID, USBfreezeID, strlen(USBfreezeID));
|
strncpy(usbd.freezeID, USBfreezeID, strlen(usbd.freezeID));
|
||||||
usbd.t = *qemu_ohci;
|
usbd.t = *qemu_ohci;
|
||||||
usbd.usb_packet.ep = qemu_ohci->usb_packet.ep ? *qemu_ohci->usb_packet.ep : USBEndpoint{0};
|
usbd.usb_packet.ep = qemu_ohci->usb_packet.ep ? *qemu_ohci->usb_packet.ep : USBEndpoint{0};
|
||||||
usbd.t.usb_packet.iov = { };
|
usbd.t.usb_packet.iov = { };
|
||||||
usbd.t.usb_packet.ep = nullptr;
|
usbd.t.usb_packet.ep = nullptr;
|
||||||
|
|
||||||
for(int i=0; i< qemu_ohci->num_ports; i++)
|
for(uint32_t i=0; i< qemu_ohci->num_ports; i++)
|
||||||
{
|
{
|
||||||
usbd.t.rhport[i].port.opaque = nullptr;
|
usbd.t.rhport[i].port.opaque = nullptr;
|
||||||
usbd.t.rhport[i].port.ops = nullptr;
|
usbd.t.rhport[i].port.ops = nullptr;
|
||||||
|
@ -580,7 +580,7 @@ void USBasync(u32 cycles)
|
||||||
clocks += remaining;
|
clocks += remaining;
|
||||||
if(qemu_ohci->eof_timer>0)
|
if(qemu_ohci->eof_timer>0)
|
||||||
{
|
{
|
||||||
while(remaining>=qemu_ohci->eof_timer)
|
while((uint64_t)remaining>=qemu_ohci->eof_timer)
|
||||||
{
|
{
|
||||||
remaining-=qemu_ohci->eof_timer;
|
remaining-=qemu_ohci->eof_timer;
|
||||||
qemu_ohci->eof_timer=0;
|
qemu_ohci->eof_timer=0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "deviceproxy.h"
|
#include "deviceproxy.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "shared/inifile.h"
|
#include "shared/inifile.h"
|
||||||
|
#include "platcompat.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -14,33 +15,13 @@ CIniFile ciniFile;
|
||||||
|
|
||||||
void USBsetSettingsDir( const char* dir )
|
void USBsetSettingsDir( const char* dir )
|
||||||
{
|
{
|
||||||
#ifdef _UNICODE
|
|
||||||
OSDebugOut(L"USBsetSettingsDir: %S\n", dir);
|
|
||||||
wchar_t dst[4096] = {0};
|
|
||||||
size_t num = 0;
|
|
||||||
mbstowcs_s(&num, dst, dir, countof(dst));
|
|
||||||
IniPath = dst;
|
|
||||||
IniPath.append(iniFile);
|
|
||||||
OSDebugOut(L"USBsetSettingsDir: %s\n", IniPath.c_str());
|
|
||||||
|
|
||||||
#else
|
|
||||||
IniPath = dir;
|
IniPath = dir;
|
||||||
IniPath.append(iniFile);
|
IniPath.append(iniFile);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void USBsetLogDir( const char* dir )
|
void USBsetLogDir( const char* dir )
|
||||||
{
|
{
|
||||||
#ifdef _UNICODE
|
|
||||||
OSDebugOut(L"USBsetLogDir: %S\n", dir);
|
|
||||||
wchar_t dst[4096] = {0};
|
|
||||||
size_t num = 0;
|
|
||||||
mbstowcs_s(&num, dst, dir, countof(dst));
|
|
||||||
LogDir = dst;
|
|
||||||
LogDir.append(_T("USBqemu-wheel.log"));
|
|
||||||
#else
|
|
||||||
LogDir = dir;
|
LogDir = dir;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
||||||
|
@ -90,33 +71,6 @@ bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _UNICODE
|
|
||||||
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, std::string& value)
|
|
||||||
{
|
|
||||||
char tmpA[4096] = { 0 };
|
|
||||||
size_t num = 0;
|
|
||||||
std::wstring str;
|
|
||||||
|
|
||||||
CIniKey *key;
|
|
||||||
auto sect = ciniFile.GetSection(section);
|
|
||||||
if (sect && (key = sect->GetKey(param))) {
|
|
||||||
str = key->GetValue();
|
|
||||||
wcstombs_s(&num, tmpA, str.c_str(), sizeof(tmpA)); //TODO error-check
|
|
||||||
value = tmpA;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const std::string& value)
|
|
||||||
{
|
|
||||||
std::wstring wstr;
|
|
||||||
wstr.assign(value.begin(), value.end());
|
|
||||||
ciniFile.SetKeyValue(section, param, wstr);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void SaveConfig() {
|
void SaveConfig() {
|
||||||
|
|
||||||
SaveSetting(_T("MAIN"), _T("log"), conf.Log);
|
SaveSetting(_T("MAIN"), _T("log"), conf.Log);
|
||||||
|
|
|
@ -1,55 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifndef NOMINMAX
|
|
||||||
#define NOMINMAX
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#define wfopen _wfopen
|
|
||||||
#define fseeko64 _fseeki64
|
|
||||||
#define ftello64 _ftelli64
|
|
||||||
#define TSTDSTRING std::wstring
|
|
||||||
#define TSTDSTRINGSTREAM std::wstringstream
|
|
||||||
#define TSTDTOSTRING std::to_wstring
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
typedef SSIZE_T ssize_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//FIXME narrow string fmt
|
|
||||||
#ifdef UNICODE
|
|
||||||
#define SFMTs "S"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __builtin_constant_p(p) false
|
|
||||||
|
|
||||||
#else //_WIN32
|
|
||||||
|
|
||||||
#define MAX_PATH PATH_MAX
|
|
||||||
#define __inline inline
|
|
||||||
|
|
||||||
//#ifndef TEXT
|
|
||||||
//#define TEXT(x) L##x
|
|
||||||
//#endif
|
|
||||||
//FIXME narrow string fmt
|
|
||||||
#define SFMTs "s"
|
|
||||||
#define TEXT(val) val
|
|
||||||
#define TCHAR char
|
|
||||||
#define wfopen fopen
|
|
||||||
#define TSTDSTRING std::string
|
|
||||||
#define TSTDSTRINGSTREAM std::stringstream
|
|
||||||
#define TSTDTOSTRING std::to_string
|
|
||||||
|
|
||||||
void SysMessage(const char *fmt, ...);
|
|
||||||
|
|
||||||
#endif //_WIN32
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "osdebugout.h"
|
#include "osdebugout.h"
|
||||||
|
#include "platcompat.h"
|
||||||
|
|
||||||
#define RESULT_CANCELED 0
|
#define RESULT_CANCELED 0
|
||||||
#define RESULT_OK 1
|
#define RESULT_OK 1
|
||||||
|
@ -207,9 +163,3 @@ bool SaveSetting(const TCHAR* section, const TCHAR* key, const Type var)
|
||||||
OSDebugOutStream_noprfx(var);
|
OSDebugOutStream_noprfx(var);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
constexpr std::size_t countof(const T (&)[N]) noexcept
|
|
||||||
{
|
|
||||||
return N;
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Annoying defines
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// make sure __POSIX__ is defined for all systems where we assume POSIX
|
||||||
|
// compliance
|
||||||
|
#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) || defined(__CYGWIN__) || defined(__LINUX__)
|
||||||
|
#if !defined(__POSIX__)
|
||||||
|
#define __POSIX__ 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define CALLBACK __stdcall
|
||||||
|
#else
|
||||||
|
# define CALLBACK __attribute__((stdcall))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EXPORT_C_
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define EXPORT_C_(type) extern "C" type CALLBACK
|
||||||
|
#else
|
||||||
|
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
|
||||||
|
//#define EXPORT_C_(type) extern "C" __attribute__((stdcall,visibility("default"))) type
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef NOMINMAX
|
||||||
|
#define NOMINMAX
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#define wfopen _wfopen
|
||||||
|
#define fseeko64 _fseeki64
|
||||||
|
#define ftello64 _ftelli64
|
||||||
|
#define TSTDSTRING std::wstring
|
||||||
|
#define TSTDSTRINGSTREAM std::wstringstream
|
||||||
|
#define TSTDTOSTRING std::to_wstring
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//FIXME narrow string fmt
|
||||||
|
#define SFMTs "S"
|
||||||
|
|
||||||
|
#define __builtin_constant_p(p) false
|
||||||
|
|
||||||
|
void SysMessageW(const wchar_t *fmt, ...);
|
||||||
|
#define SysMessage SysMessageW
|
||||||
|
|
||||||
|
#ifndef _T
|
||||||
|
#define _T(x) L##x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else //_WIN32
|
||||||
|
|
||||||
|
#define MAX_PATH PATH_MAX
|
||||||
|
#define __inline inline
|
||||||
|
|
||||||
|
//#ifndef TEXT
|
||||||
|
//#define TEXT(x) L##x
|
||||||
|
//#endif
|
||||||
|
//FIXME narrow string fmt
|
||||||
|
#define SFMTs "s"
|
||||||
|
#define TEXT(val) val
|
||||||
|
#define TCHAR char
|
||||||
|
#define wfopen fopen
|
||||||
|
#define TSTDSTRING std::string
|
||||||
|
#define TSTDSTRINGSTREAM std::stringstream
|
||||||
|
#define TSTDTOSTRING std::to_string
|
||||||
|
|
||||||
|
void SysMessage(const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#if __MINGW32__
|
||||||
|
|
||||||
|
#define DBL_EPSILON 2.2204460492503131e-16
|
||||||
|
#define FLT_EPSILON 1.1920928955078125e-7f
|
||||||
|
|
||||||
|
template <size_t size>
|
||||||
|
errno_t mbstowcs_s(
|
||||||
|
size_t *pReturnValue,
|
||||||
|
wchar_t (&wcstr)[size],
|
||||||
|
const char *mbstr,
|
||||||
|
size_t count
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return mbstowcs_s(pReturnValue, wcstr, size, mbstr, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t size>
|
||||||
|
errno_t wcstombs_s(
|
||||||
|
size_t *pReturnValue,
|
||||||
|
char (&mbstr)[size],
|
||||||
|
const wchar_t *wcstr,
|
||||||
|
size_t count
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return wcstombs_s(pReturnValue, mbstr, size, wcstr, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //__MINGW32__
|
||||||
|
|
||||||
|
#ifndef ARRAY_SIZE
|
||||||
|
#define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template <class T, std::size_t N>
|
||||||
|
constexpr std::size_t countof(const T (&)[N]) noexcept
|
||||||
|
{
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
constexpr std::size_t countof(const T N)
|
||||||
|
{
|
||||||
|
return N.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO Idk, used only in desc.h and struct USBDescriptor should be already packed anyway
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
#define PACK(def,name) __pragma( pack(push, 1) ) def name __pragma( pack(pop) )
|
||||||
|
#elif defined(__clang__)
|
||||||
|
#define PACK(def,name) def __attribute__((packed)) name
|
||||||
|
#else
|
||||||
|
#define PACK(def,name) def __attribute__((gcc_struct, packed)) name
|
||||||
|
#endif
|
|
@ -2,14 +2,7 @@
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "../platcompat.h"
|
||||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
|
||||||
#define PACK(def,name) __pragma( pack(push, 1) ) def name __pragma( pack(pop) )
|
|
||||||
#elif defined(__clang__)
|
|
||||||
#define PACK(def,name) def __attribute__((packed)) name
|
|
||||||
#else
|
|
||||||
#define PACK(def,name) def __attribute__((gcc_struct, packed)) name
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* binary representation */
|
/* binary representation */
|
||||||
PACK(typedef struct USBDescriptor {
|
PACK(typedef struct USBDescriptor {
|
||||||
|
|
|
@ -67,6 +67,12 @@ public:
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
int mPort;
|
||||||
|
const char *mDevType;
|
||||||
|
int mDevice;
|
||||||
|
AudioDir mAudioDir;
|
||||||
|
public:
|
||||||
virtual ~AudioDevice() {}
|
virtual ~AudioDevice() {}
|
||||||
//get buffer, converted to 16bit int format
|
//get buffer, converted to 16bit int format
|
||||||
virtual uint32_t GetBuffer(int16_t *buff, uint32_t len) = 0;
|
virtual uint32_t GetBuffer(int16_t *buff, uint32_t len) = 0;
|
||||||
|
@ -87,11 +93,6 @@ public:
|
||||||
|
|
||||||
//Remember to add to your class
|
//Remember to add to your class
|
||||||
//static const wchar_t* GetName();
|
//static const wchar_t* GetName();
|
||||||
protected:
|
|
||||||
int mPort;
|
|
||||||
int mDevice;
|
|
||||||
AudioDir mAudioDir;
|
|
||||||
const char *mDevType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<AudioDeviceInfo> AudioDeviceInfoList;
|
typedef std::vector<AudioDeviceInfo> AudioDeviceInfoList;
|
||||||
|
|
Loading…
Reference in New Issue