USB: windows mostly complete, linker issues left

This commit is contained in:
GovanifY 2020-11-04 00:39:36 +01:00 committed by refractionpcsx2
parent bc022789fc
commit 395b372ef7
54 changed files with 587 additions and 551 deletions

View File

@ -19,6 +19,7 @@
#include <cerrno>
#include <cassert>
#include "PrecompiledHeader.h"
#include "Utilities/pxStreams.h"
#include "USB.h"
#include "osdebugout.h"
@ -189,7 +190,11 @@ s32 USBinit()
if (conf.Log && !usbLog)
{
#ifdef _WIN32
usbLog = wfopen(LogDir.c_str(), L"wb"); // L"wb,ccs=UNICODE");
#else
usbLog = wfopen(LogDir.c_str(), "wb"); // L"wb,ccs=UNICODE");
#endif
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
USB_LOG("USBinit\n");
}

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "AppCoreThread.h"
#include "../USB.h"
#include "resource.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "osdebugout.h"
#include "deviceproxy.h"
#include "configuration.h"
@ -30,13 +31,21 @@ CIniFile ciniFile;
void USBsetSettingsDir(const char* dir)
{
#ifdef _WIN32
IniPath = str_to_wstr(dir);
#else
IniPath = dir;
#endif
IniPath.append(iniFile);
}
void USBsetLogDir(const char* dir)
{
#ifdef _WIN32
LogDir = str_to_wstr(dir);
#else
LogDir = dir;
#endif
}
std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
@ -50,18 +59,37 @@ std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, TSTDSTRING& value)
{
CIniKey* key;
#ifdef _WIN32
auto sect = ciniFile.GetSection(section);
if (sect && (key = sect->GetKey(param)))
{
value = key->GetValue();
return true;
}
#else
auto sect = ciniFile.GetSection(str_to_wstr(section));
if (sect && (key = sect->GetKey(str_to_wstr(param))))
{
value = wstr_to_str(key->GetValue());
return true;
}
#endif
return false;
}
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t& value)
{
CIniKey* key;
#ifdef _WIN32
auto sect = ciniFile.GetSection(section);
if (sect && (key = sect->GetKey(param)))
{
try
{
value = std::stoi(key->GetValue());
return true;
}
#else
auto sect = ciniFile.GetSection(str_to_wstr(section));
if (sect && (key = sect->GetKey(str_to_wstr(param))))
{
@ -70,6 +98,7 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
value = std::stoi(key->GetValue());
return true;
}
#endif
catch (std::exception& err)
{
OSDebugOut(TEXT("%" SFMTs "\n"), err.what());
@ -80,20 +109,32 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const TSTDSTRING& value)
{
#ifdef _WIN32
ciniFile.SetKeyValue(section, param, value);
#else
ciniFile.SetKeyValue(str_to_wstr(section), str_to_wstr(param), str_to_wstr(value));
#endif
return true;
}
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t value)
{
#ifdef _WIN32
ciniFile.SetKeyValue(section, param, TSTDTOSTRING(value));
#else
ciniFile.SetKeyValue(str_to_wstr(section), str_to_wstr(param), str_to_wstr(TSTDTOSTRING(value)));
#endif
return true;
}
void SaveConfig()
{
#ifdef _WIN32
SaveSetting(L"MAIN", L"log", conf.Log);
#else
SaveSetting("MAIN", "log", conf.Log);
#endif
SaveSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
SaveSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
@ -106,17 +147,27 @@ void SaveConfig()
SaveSetting(nullptr, k.first.first, k.first.second, N_DEVICE_API, k.second);
}
ciniFile.Save(str_to_wstr(IniPath));
#ifdef _WIN32
bool ret = ciniFile.Save(IniPath);
OSDebugOut(_T("ciniFile.Save: %d [%s]\n"), ret, IniPath.c_str());
#else
bool ret = ciniFile.Save(str_to_wstr(IniPath));
OSDebugOut(_T("ciniFile.Save: %d [%s]\n"), ret, IniPath.c_str());
#endif
}
void LoadConfig()
{
std::cerr << "USB load config\n"
<< std::endl;
ciniFile.Load(str_to_wstr(IniPath));
#ifdef _WIN32
ciniFile.Load(IniPath);
LoadSetting(L"MAIN", L"log", conf.Log);
#else
ciniFile.Load(str_to_wstr(IniPath));
LoadSetting("MAIN", "log", conf.Log);
#endif
LoadSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]);
LoadSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]);
@ -155,7 +206,11 @@ void LoadConfig()
void ClearSection(const TCHAR* section)
{
#ifdef _WIN32
auto s = ciniFile.GetSection(section);
#else
auto s = ciniFile.GetSection(str_to_wstr(section));
#endif
if (s)
{
s->RemoveAllKeys();
@ -173,5 +228,9 @@ void RemoveSection(const char* dev_type, int port, const std::string& key)
section << tkey << _T(" ") << port;
TSTDSTRING str = section.str();
#ifdef _WIN32
ciniFile.RemoveSection(section.str());
#else
ciniFile.RemoveSection(str_to_wstr(section.str()));
#endif
}

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "deviceproxy.h"
#include "usb-pad/usb-pad.h"
#include "usb-msd/usb-msd.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "deviceproxy.h"
#include "usb-pad/padproxy.h"
#include "usb-mic/audiodeviceproxy.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "osdebugout.h"
std::wostream& operator<<(std::wostream& os, const std::string& s)

View File

@ -57,9 +57,10 @@
#define TSTDTOSTRING std::to_wstring
#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
//typedef SSIZE_T ssize_t;
#endif
//FIXME narrow string fmt
#define SFMTs "S"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "USBinternal.h"
#include "vl.h"

View File

@ -23,6 +23,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "PrecompiledHeader.h"
#include "../osdebugout.h"
#include "../platcompat.h"
#include "vl.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "vl.h"
#include "desc.h"
#include "glib.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "glib.h"
#include <cstdlib>
#include <cstring>

View File

@ -22,6 +22,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "PrecompiledHeader.h"
#include "hid.h"
#include "input-keymap.h"
#include "../osdebugout.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "input-keymap.h"
//TODO how much does std::map kill perf if any?

View File

@ -18,6 +18,7 @@
* To re-generate, run:
* keymap-gen --lang=stdc++ --varname=qemu_input_map_win32_to_qcode code-map keymaps.csv win32 qcode
*/
#include "PrecompiledHeader.h"
#include "input-keymap-win32-to-qcode.h"
const std::array<QKeyCode, 252> qemu_input_map_win32_to_qcode = {
Q_KEY_CODE_UNMAPPED, /* win32:0 (unnamed) -> linux:None (unnamed) -> qcode:None (unnamed) */

View File

@ -16,6 +16,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "PrecompiledHeader.h"
#include "vl.h"
//#include "qemu-common.h"
#include "iov.h"

View File

@ -11,6 +11,8 @@
* the COPYING file in the top-level directory.
*/
#include "../platcompat.h"
#ifndef IOV_H
#define IOV_H

View File

@ -28,6 +28,7 @@
//typedef CPUReadMemoryFunc
#include "PrecompiledHeader.h"
#include "vl.h"
#include "queue.h"
#include "USBinternal.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "vl.h"
/* compute with 96 bit intermediate result: (a*b)/c */

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include <windows.h>
#include <setupapi.h>
#include "hidapi.h"

View File

@ -18,6 +18,8 @@
#include <pshpack4.h>
#define NTSTATUS int
typedef USHORT USAGE, *PUSAGE;
#define HID_USAGE_PAGE_GENERIC ((USAGE)0x01)

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "inifile.h"
#include <algorithm>
#include <iostream>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "rawinput.h"
#include <cstdio>
#include <vector>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "ringbuffer.h"
#include <cstring>
#include <cassert>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "shared.h"
#include <stdexcept>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "videodeviceproxy.h"
#include "cam-windows.h"

File diff suppressed because it is too large Load Diff

View File

@ -28,14 +28,14 @@ extern GUID CLSID_NullRenderer;
}
#pragma region qedit.h
struct //__declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
ISampleGrabberCB : IUnknown
{
virtual HRESULT __stdcall SampleCB(double SampleTime, struct IMediaSample* pSample) = 0;
virtual HRESULT __stdcall BufferCB(double SampleTime, unsigned char* pBuffer, long BufferLen) = 0;
};
struct //__declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
struct __declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
ISampleGrabber : IUnknown
{
virtual HRESULT __stdcall SetOneShot(long OneShot) = 0;
@ -47,8 +47,8 @@ struct //__declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
virtual HRESULT __stdcall SetCallback(struct ISampleGrabberCB* pCallback, long WhichMethodToCallback) = 0;
};
//struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
// SampleGrabber;
struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
SampleGrabber;
#pragma endregion
@ -72,6 +72,12 @@ namespace usb_eyetoy
typedef void (*DShowVideoCaptureCallback)(unsigned char* data, int len, int bitsperpixel);
typedef struct
{
void* start = NULL;
size_t length = 0;
} buffer_t;
static const char* APINAME = "DirectShow";
class DirectShow : public VideoDevice
@ -94,12 +100,10 @@ namespace usb_eyetoy
void Port(int port) { mPort = port; }
protected:
void SetCallback(DShowVideoCaptureCallback cb) { callbackhandler->SetCallback(cb); }
void Start();
void Stop();
int InitializeDevice(std::wstring selectedDevice);
void store_mpeg_frame(const std::vector<unsigned char>& data);
void create_dummy_frame();
void dshow_callback(unsigned char* data, int len, int bitsperpixel);
private:
int mPort;
@ -114,16 +118,10 @@ namespace usb_eyetoy
ISampleGrabber* samplegrabber;
IBaseFilter* nullrenderer;
std::vector<unsigned char> mpeg_buffer{};
std::mutex mpeg_mutex;
class CallbackHandler : public ISampleGrabberCB
{
public:
CallbackHandler(DirectShow* parent_)
: parent(parent_)
{
}
CallbackHandler() { callback = 0; }
~CallbackHandler() {}
void SetCallback(DShowVideoCaptureCallback cb) { callback = cb; }
@ -135,7 +133,7 @@ namespace usb_eyetoy
virtual ULONG __stdcall Release() { return 2; }
private:
DirectShow* parent;
DShowVideoCaptureCallback callback;
} * callbackhandler;
};

View File

@ -27,6 +27,7 @@
* http://www.cs.cornell.edu/dali/api/mpegvideo-c.html
* */
#include "PrecompiledHeader.h"
#include <stdio.h>
#include <math.h>
#include <memory.h>

View File

@ -26,6 +26,8 @@
// Important:
// #define JPGD_USE_SSE2 to 0 to completely disable SSE2 usage.
//
#include "PrecompiledHeader.h"
#include "jpgd.h"
#include <string.h>
#include <algorithm>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "videodeviceproxy.h"
#include "../osdebugout.h"
#include "usb-eyetoy-webcam.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "hidproxy.h"
#include "raw/rawinput.h"
#include "noop.h"

View File

@ -13,10 +13,11 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "rawinput.h"
#include "../../Win32/Config.h"
#include "qemu-usb/input-keymap.h"
#include "qemu-usb/input-keymap-win32-to-qcode.h"
#include "../../qemu-usb/input-keymap.h"
#include "../../qemu-usb/input-keymap-win32-to-qcode.h"
namespace usb_hid
{

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "shared/rawinput.h"
#include "../../shared/rawinput.h"
#include "../hidproxy.h"
#include "../usb-hid.h"

View File

@ -22,6 +22,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "PrecompiledHeader.h"
#include "../deviceproxy.h"
#include "hidproxy.h"
#include "../qemu-usb/desc.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "audiodeviceproxy.h"
#include "audiodev-noop.h"
#include "audiodev-wasapi.h"

View File

@ -15,6 +15,7 @@
// Used OBS as example
#include "PrecompiledHeader.h"
#include <assert.h>
#include <propsys.h>
#include <typeinfo>

View File

@ -17,7 +17,7 @@
#include "audiodeviceproxy.h"
#include "../libsamplerate/samplerate.h"
#include "shared/ringbuffer.h"
#include "../shared/ringbuffer.h"
#include <mmdeviceapi.h>
#include <audioclient.h>

View File

@ -24,6 +24,7 @@
// Most stuff is based on Qemu 1.7 USB soundcard passthrough code.
#include "PrecompiledHeader.h"
#include "../qemu-usb/vl.h"
#include "../qemu-usb/desc.h"
#include <assert.h>
@ -666,6 +667,7 @@ namespace usb_mic
int length, uint8_t* data)
{
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);
int ret = USB_RET_STALL;

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "usb-mic-singstar.h"
#include "audio.h"
#include "../qemu-usb/desc.h"

View File

@ -24,6 +24,7 @@
// Most stuff is based on Qemu 1.7 USB soundcard passthrough code.
#include "PrecompiledHeader.h"
#include "../qemu-usb/vl.h"
#include "../qemu-usb/desc.h"
#include "usb-mic-singstar.h"

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include <commdlg.h>
#include "usb-msd.h"
#include "../Win32/Config.h"
#include "../Win32/resource.h"

View File

@ -7,6 +7,7 @@
* This code is licenced under the LGPL.
*/
#include "PrecompiledHeader.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "padproxy.h"
#include "raw/usb-pad-raw.h"
#include "dx/usb-pad-dx.h"

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#pragma warning(push)
// floats to int
#pragma warning(disable : 4244)

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include <math.h>
#include "dx.h"

View File

@ -29,7 +29,7 @@
#include "../usb-pad.h"
#include "../../configuration.h"
#include "../../osdebugout.h"
#include "usb-pad/lg/lg_ff.h"
#include "../../usb-pad/lg/lg_ff.h"
#define DINPUT_AXES_COUNT 32

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "usb-pad-dx.h"
#include "dx.h"
#include <cmath>

View File

@ -3,6 +3,7 @@
License: GPLv3
*/
#include "PrecompiledHeader.h"
#include "lg_ff.h"
typedef struct

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#define _WIN32_WINNT 0x0502
#include <stdio.h>
#include <windows.h>

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "../../USB.h"
#include "../../Win32/Config.h"
#include "usb-pad-raw.h"

View File

@ -20,8 +20,8 @@
#include <atomic>
#include "../padproxy.h"
#include "../usb-pad.h"
#include "shared/rawinput.h"
#include "readerwriterqueue/readerwriterqueue.h"
#include "../../shared/rawinput.h"
#include "../../readerwriterqueue/readerwriterqueue.h"
namespace usb_pad
{

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "usb-pad.h"
#include "lg/lg_ff.h"
#include "../osdebugout.h"

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "padproxy.h"
#include "usb-pad.h"
#include "../qemu-usb/desc.h"

View File

@ -1,3 +1,19 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "padproxy.h"
#include "usb-pad.h"
#include "../qemu-usb/desc.h"