mirror of https://github.com/PCSX2/pcsx2.git
USB: continuing merge, platformcompat fixes
This commit is contained in:
parent
de314d253e
commit
50969601bf
|
@ -364,7 +364,6 @@ set(pcsx2USBHeaders
|
|||
USB/proxybase.h
|
||||
USB/deviceproxy.h
|
||||
USB/configuration.h
|
||||
USB/platcompat.h
|
||||
USB/osdebugout.h
|
||||
USB/helpers.h
|
||||
USB/readerwriterqueue/readerwriterqueue.h
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "IopCommon.h"
|
||||
#include "SPU2/spu2.h"
|
||||
#include "DEV9/DEV9.h"
|
||||
#include "USB/USB.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -149,12 +150,9 @@ void psxRcntInit()
|
|||
psxCounters[6].CycleT = psxCounters[6].rate;
|
||||
psxCounters[6].mode = 0x8;
|
||||
|
||||
if (USBasync != NULL)
|
||||
{
|
||||
psxCounters[7].rate = PSXCLK / 1000;
|
||||
psxCounters[7].CycleT = psxCounters[7].rate;
|
||||
psxCounters[7].mode = 0x8;
|
||||
}
|
||||
psxCounters[7].rate = PSXCLK / 1000;
|
||||
psxCounters[7].CycleT = psxCounters[7].rate;
|
||||
psxCounters[7].mode = 0x8;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
psxCounters[i].sCycleT = psxRegs.cycle;
|
||||
|
@ -516,22 +514,19 @@ void psxRcntUpdate()
|
|||
c -= difference;
|
||||
psxNextCounter = c;
|
||||
DEV9async(1);
|
||||
if(USBasync)
|
||||
{
|
||||
const s32 difference = psxRegs.cycle - psxCounters[7].sCycleT;
|
||||
s32 c = psxCounters[7].CycleT;
|
||||
const s32 diffusb = psxRegs.cycle - psxCounters[7].sCycleT;
|
||||
s32 cusb = psxCounters[7].CycleT;
|
||||
|
||||
if (difference >= psxCounters[7].CycleT)
|
||||
{
|
||||
USBasync(difference);
|
||||
psxCounters[7].sCycleT = psxRegs.cycle;
|
||||
psxCounters[7].CycleT = psxCounters[7].rate;
|
||||
}
|
||||
else
|
||||
c -= difference;
|
||||
if (c < psxNextCounter)
|
||||
psxNextCounter = c;
|
||||
}
|
||||
if (diffusb >= psxCounters[7].CycleT)
|
||||
{
|
||||
USBasync(diffusb);
|
||||
psxCounters[7].sCycleT = psxRegs.cycle;
|
||||
psxCounters[7].CycleT = psxCounters[7].rate;
|
||||
}
|
||||
else
|
||||
cusb -= diffusb;
|
||||
if (cusb < psxNextCounter)
|
||||
psxNextCounter = cusb;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
_rcntSet(i);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "IopCommon.h"
|
||||
#include "DEV9/DEV9.h"
|
||||
#include "USB/USB.h"
|
||||
|
||||
using namespace R3000A;
|
||||
|
||||
|
@ -33,8 +34,6 @@ void dev9Irq(int cycles)
|
|||
|
||||
void usbInterrupt()
|
||||
{
|
||||
if (usbHandler != NULL && (usbHandler() != 1)) return;
|
||||
|
||||
iopIntcIrq(22);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "Elfheader.h"
|
||||
#include "CDVD/CDVD.h"
|
||||
#include "USB/USB.h"
|
||||
#include "Patch.h"
|
||||
#include "GameDatabase.h"
|
||||
|
||||
|
@ -109,8 +110,7 @@ void cpuReset()
|
|||
ElfEntry = -1;
|
||||
|
||||
// Probably not the right place, but it has to be done when the ram is actually initialized
|
||||
if(USBsetRAM != 0)
|
||||
USBsetRAM(iopMem->Main);
|
||||
USBsetRAM(iopMem->Main);
|
||||
|
||||
// FIXME: LastELF should be reset on media changes as well as on CPU resets, in
|
||||
// the very unlikely case that a user swaps to another media source that "looks"
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
#include <cerrno>
|
||||
#include <cassert>
|
||||
|
||||
#include "version.h" //CMake generated
|
||||
#include "USB.h"
|
||||
#include "platcompat.h"
|
||||
#include "osdebugout.h"
|
||||
#include "qemu-usb/USBinternal.h"
|
||||
#include "qemu-usb/desc.h"
|
||||
|
@ -33,8 +31,6 @@
|
|||
|
||||
#define PSXCLK 36864000 /* 36.864 Mhz */
|
||||
|
||||
static char libraryName[256];
|
||||
|
||||
OHCIState *qemu_ohci = NULL;
|
||||
USBDevice *usb_device[2] = { NULL };
|
||||
bool configChanged = false;
|
||||
|
@ -195,14 +191,8 @@ s32 USBinit() {
|
|||
|
||||
if (conf.Log && !usbLog)
|
||||
{
|
||||
usbLog =
|
||||
#if _UNICODE
|
||||
_wfopen(LogDir.c_str(), L"wb");// L"wb,ccs=UNICODE");
|
||||
#else
|
||||
fopen(LogDir.c_str(), "w");
|
||||
#endif
|
||||
usbLog = wfopen(LogDir.c_str(), "wb");// L"wb,ccs=UNICODE");
|
||||
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
||||
USB_LOG("usbqemu wheel mod plugin version %d.%d.%d\n", VER_REV, VER_BLD, VER_FIX);
|
||||
USB_LOG("USBinit\n");
|
||||
}
|
||||
|
||||
|
@ -239,7 +229,6 @@ s32 USBopen(void *pDsp) {
|
|||
{
|
||||
usbLog = fopen("logs/usbLog.txt", "a");
|
||||
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
||||
USB_LOG("usbqemu wheel mod plugin version %d.%d.%d\n", VER_REV, VER_BLD, VER_FIX);
|
||||
}
|
||||
|
||||
USB_LOG("USBopen\n");
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string>
|
||||
#include <limits.h>
|
||||
|
||||
#include "platcompat.h"
|
||||
#include "SaveState.h"
|
||||
#include "osdebugout.h"
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
|
@ -12,7 +12,7 @@ TSTDSTRING IniPath = TSTDSTRING(TEXT("./inis/")) + iniFile; // default path, jus
|
|||
TSTDSTRING LogDir;
|
||||
CIniFile ciniFile;
|
||||
|
||||
EXPORT_C_(void) USBsetSettingsDir( const char* dir )
|
||||
void USBsetSettingsDir( const char* dir )
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
OSDebugOut(L"USBsetSettingsDir: %S\n", dir);
|
||||
|
@ -29,7 +29,7 @@ EXPORT_C_(void) USBsetSettingsDir( const char* dir )
|
|||
#endif
|
||||
}
|
||||
|
||||
EXPORT_C_(void) USBsetLogDir( const char* dir )
|
||||
void USBsetLogDir( const char* dir )
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
OSDebugOut(L"USBsetLogDir: %S\n", dir);
|
||||
|
|
|
@ -1,12 +1,54 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
#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 <string>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include "platcompat.h"
|
||||
#include "osdebugout.h"
|
||||
|
||||
#define RESULT_CANCELED 0
|
||||
|
@ -71,6 +113,9 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
|||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const std::string& value);
|
||||
#endif
|
||||
|
||||
void USBsetSettingsDir( const char* dir );
|
||||
void USBsetLogDir( const char* dir );
|
||||
|
||||
template<typename Type>
|
||||
bool LoadSetting(const char* dev_type, int port, const std::string& key, const TCHAR* name, Type& var)
|
||||
{
|
||||
|
@ -163,4 +208,8 @@ bool SaveSetting(const TCHAR* section, const TCHAR* key, const Type var)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
template <class T, std::size_t N>
|
||||
constexpr std::size_t countof(const T (&)[N]) noexcept
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
void __Log(const char* fmt, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "platcompat.h"
|
||||
|
||||
#include <vector>
|
||||
void _OSDebugOut(const TCHAR *psz_fmt, ...);
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
#ifndef PLATCOMPAT_H
|
||||
#define PLATCOMPAT_H
|
||||
|
||||
// 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
|
||||
#ifdef UNICODE
|
||||
#define SFMTs "S"
|
||||
#else
|
||||
#define SFMTs "s"
|
||||
#endif
|
||||
|
||||
#define __builtin_constant_p(p) false
|
||||
|
||||
#if _UNICODE
|
||||
void SysMessageW(const wchar_t *fmt, ...);
|
||||
#define SysMessage SysMessageW
|
||||
#else
|
||||
void SysMessageA(const char *fmt, ...);
|
||||
#define SysMessage SysMessageA
|
||||
#endif
|
||||
|
||||
#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 _T(x) x
|
||||
#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
|
||||
#endif
|
|
@ -1,4 +1,3 @@
|
|||
#include "platcompat.h"
|
||||
#include "USBinternal.h"
|
||||
#include "vl.h"
|
||||
|
||||
|
@ -128,4 +127,4 @@ void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps)
|
|||
if (klass->free_streams) {
|
||||
klass->free_streams(dev, eps, nr_eps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "platcompat.h"
|
||||
#include "osdebugout.h"
|
||||
#include "vl.h"
|
||||
#include "iov.h"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include "platcompat.h"
|
||||
|
||||
#include "vl.h"
|
||||
#include "desc.h"
|
||||
#include "glib.h"
|
||||
|
@ -848,4 +846,4 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
|
|||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
#ifndef QEMU_HW_USB_DESC_H
|
||||
#define QEMU_HW_USB_DESC_H
|
||||
#pragma once
|
||||
|
||||
#include "platcompat.h"
|
||||
#include <wchar.h>
|
||||
#include <vector>
|
||||
|
||||
#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 */
|
||||
PACK(typedef struct USBDescriptor {
|
||||
uint8_t bLength;
|
||||
|
@ -244,4 +250,3 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
|
|||
|
||||
int usb_desc_set_config(USBDevice *dev, int value);
|
||||
int usb_desc_set_interface(USBDevice *dev, int index, int value);
|
||||
#endif /* QEMU_HW_USB_DESC_H */
|
|
@ -16,7 +16,6 @@
|
|||
* GNU GPL, version 2 or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "platcompat.h"
|
||||
#include "vl.h"
|
||||
//#include "qemu-common.h"
|
||||
#include "iov.h"
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#ifndef IOV_H
|
||||
#define IOV_H
|
||||
#include "platcompat.h" /* ssize_t */
|
||||
|
||||
#if !defined(_BITS_UIO_H) && !defined(__iovec_defined) /* /usr/include/bits/uio.h */
|
||||
struct iovec {
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "vl.h"
|
||||
#include "queue.h"
|
||||
#include "USBinternal.h"
|
||||
#include "platcompat.h"
|
||||
#include "../osdebugout.h"
|
||||
|
||||
#define DMA_DIRECTION_TO_DEVICE 0
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "platcompat.h"
|
||||
#include "osdebugout.h"
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
@ -270,4 +269,4 @@ void Uninitialize()
|
|||
eatenWnd = nullptr;
|
||||
}
|
||||
|
||||
}} //namespace
|
||||
}} //namespace
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include "osdebugout.h"
|
||||
#include "platcompat.h"
|
||||
|
||||
#if 0
|
||||
#define DPRINTF OSDebugOut
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "../configuration.h"
|
||||
#include "qemu-usb/hid.h"
|
||||
#include "../qemu-usb/hid.h"
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
@ -73,4 +73,4 @@ public:
|
|||
static int Freeze(int mode, USBDevice *dev, void *data);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue