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"

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <guiddef.h>
#include "PrecompiledHeader.h"
#include "videodev.h"
#include "cam-windows.h"
#include "usb-eyetoy-webcam.h"
@ -22,104 +22,6 @@
#include "../Win32/Config.h"
#include "../Win32/resource.h"
#ifndef DIBSIZE
#define WIDTHBYTES(BTIS) ((DWORD)(((BTIS) + 31) & (~31)) / 8)
#define DIBWIDTHBYTES(BI) (DWORD)(BI).biBitCount) * (DWORD)WIDTHBYTES((DWORD)(BI).biWidth
#define _DIBSIZE(BI) (DIBWIDTHBYTES(BI) * (DWORD)(BI).biHeight)
#define DIBSIZE(BI) ((BI).biHeight < 0 ? (-1) * (_DIBSIZE(BI)) : _DIBSIZE(BI))
#endif
constexpr GUID make_guid(const char* const spec)
{
#define nybble_from_hex(c) ((c >= '0' && c <= '9') ? (c - '0') : ((c >= 'a' && c <= 'f') ? (c - 'a' + 10) : ((c >= 'A' && c <= 'F') ? (c - 'A' + 10) : 0)))
#define byte_from_hex(c1, c2) ((nybble_from_hex(c1) << 4) | nybble_from_hex(c2))
return {
// Data1
(((((((((((((
static_cast<unsigned __int32>(nybble_from_hex(spec[0]))
<< 4) |
nybble_from_hex(spec[1]))
<< 4) |
nybble_from_hex(spec[2]))
<< 4) |
nybble_from_hex(spec[3]))
<< 4) |
nybble_from_hex(spec[4]))
<< 4) |
nybble_from_hex(spec[5]))
<< 4) |
nybble_from_hex(spec[6]))
<< 4) |
nybble_from_hex(spec[7]),
// Data2
static_cast<unsigned short>(
(((((
static_cast<unsigned>(nybble_from_hex(spec[9]))
<< 4) |
nybble_from_hex(spec[10]))
<< 4) |
nybble_from_hex(spec[11]))
<< 4) |
nybble_from_hex(spec[12])),
// Data 3
static_cast<unsigned short>(
(((((
static_cast<unsigned>(nybble_from_hex(spec[14]))
<< 4) |
nybble_from_hex(spec[15]))
<< 4) |
nybble_from_hex(spec[16]))
<< 4) |
nybble_from_hex(spec[17])),
// Data 4
{
static_cast<unsigned char>(byte_from_hex(spec[19], spec[20])),
static_cast<unsigned char>(byte_from_hex(spec[21], spec[22])),
static_cast<unsigned char>(byte_from_hex(spec[24], spec[25])),
static_cast<unsigned char>(byte_from_hex(spec[26], spec[27])),
static_cast<unsigned char>(byte_from_hex(spec[28], spec[29])),
static_cast<unsigned char>(byte_from_hex(spec[30], spec[31])),
static_cast<unsigned char>(byte_from_hex(spec[32], spec[33])),
static_cast<unsigned char>(byte_from_hex(spec[34], spec[35]))}};
}
#if defined(_MSC_VER)
#define CPPX_MSVC_UUID_FOR(name, spec) \
class __declspec(uuid(spec)) name
#else
#define CPPX_GNUC_UUID_FOR(name, spec) \
template <> \
inline auto __mingw_uuidof<name>() \
->GUID const& \
{ \
static constexpr GUID the_uuid = make_guid(spec); \
\
return the_uuid; \
} \
\
template <> \
inline auto __mingw_uuidof<name*>() \
->GUID const& \
{ \
return __mingw_uuidof<name>(); \
} \
\
static_assert(true, "")
#endif
#if !defined(CPPX_UUID_FOR)
#if defined(_MSC_VER)
#define CPPX_UUID_FOR CPPX_MSVC_UUID_FOR
#elif defined(__GNUC__)
#define CPPX_UUID_FOR CPPX_GNUC_UUID_FOR
#endif
#endif
CPPX_UUID_FOR(ISampleGrabber, "6b652fff-11fe-4fce-92ad-0266b5d7c78f");
CPPX_UUID_FOR(ISampleGrabberCB, "0579154a-2b53-4994-b0d0-e773148eff85");
//CPPX_UUID_FOR(SampleGrabber, "c1f400a0-3f08-11d3-9f0b-006008039e37");
namespace usb_eyetoy
{
namespace windows_api
@ -134,8 +36,8 @@ namespace usb_eyetoy
if (hr != S_OK)
return S_OK;
if (parent)
std::invoke(&DirectShow::dshow_callback, parent, buffer, sample->GetActualDataLength(), BITS_PER_PIXEL);
if (callback)
callback(buffer, sample->GetActualDataLength(), BITS_PER_PIXEL);
return S_OK;
}
@ -152,7 +54,6 @@ namespace usb_eyetoy
std::vector<std::wstring> getDevList()
{
std::vector<std::wstring> devList;
devList.push_back(L"None");
ICreateDevEnum* pCreateDevEnum = 0;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pCreateDevEnum));
@ -163,9 +64,8 @@ namespace usb_eyetoy
}
IEnumMoniker* pEnum = 0;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, 0);
if (hr == S_FALSE || FAILED(hr))
{
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, NULL);
if (FAILED(hr))
{
fprintf(stderr, "You have no video capture hardware");
return devList;
@ -248,9 +148,8 @@ namespace usb_eyetoy
}
IEnumMoniker* pEnum = 0;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, 0);
if (hr == S_FALSE || FAILED(hr))
{
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, NULL);
if (FAILED(hr))
{
fprintf(stderr, "You have no video capture hardware");
return -1;
@ -402,9 +301,7 @@ namespace usb_eyetoy
}
// if the stream is started, start capturing immediatly
LONGLONG start, stop;
start = 0;
stop = MAXLONGLONG;
LONGLONG start = 0, stop = MAXLONGLONG;
hr = pGraphBuilder->ControlStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, sourcefilter, &start, &stop, 1, 2);
if (FAILED(hr))
{
@ -444,8 +341,6 @@ namespace usb_eyetoy
void DirectShow::Stop()
{
if (!sourcefilter)
return;
HRESULT hr = sourcefilter->Stop();
if (FAILED(hr))
throw hr;
@ -458,21 +353,26 @@ namespace usb_eyetoy
if (FAILED(hr))
throw hr;
}
void DirectShow::store_mpeg_frame(const std::vector<unsigned char>& data)
buffer_t mpeg_buffer{};
std::mutex mpeg_mutex;
void store_mpeg_frame(unsigned char* data, unsigned int len)
{
std::lock_guard<std::mutex> lk(mpeg_mutex);
mpeg_buffer = data;
mpeg_mutex.lock();
memcpy(mpeg_buffer.start, data, len);
mpeg_buffer.length = len;
mpeg_mutex.unlock();
}
void DirectShow::dshow_callback(unsigned char* data, int len, int bitsperpixel)
void dshow_callback(unsigned char* data, int len, int bitsperpixel)
{
if (bitsperpixel == 24)
{
std::vector<unsigned char> mpegData(320 * 240 * 2);
int mpegLen = jo_write_mpeg(mpegData.data(), data, 320, 240, JO_RGB24, JO_FLIP_X, JO_FLIP_Y);
//OSDebugOut(_T("MPEG: alloced: %d, got: %d\n"), mpegData.size(), mpegLen);
mpegData.resize(mpegLen);
store_mpeg_frame(mpegData);
unsigned char* mpegData = (unsigned char*)calloc(1, 320 * 240 * 2);
int mpegLen = jo_write_mpeg(mpegData, data, 320, 240, JO_RGB24, JO_FLIP_X, JO_FLIP_Y);
store_mpeg_frame(mpegData, mpegLen);
free(mpegData);
}
else
{
@ -480,28 +380,29 @@ namespace usb_eyetoy
}
}
void DirectShow::create_dummy_frame()
void create_dummy_frame()
{
const int width = 320;
const int height = 240;
const int bytesPerPixel = 3;
std::vector<unsigned char> rgbData(width * height * bytesPerPixel, 0);
unsigned char* rgbData = (unsigned char*)calloc(1, width * height * bytesPerPixel);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned char* ptr = &rgbData[(y * width + x) * bytesPerPixel];
int c = (255 * y) / height;
ptr[0] = 255 - c;
ptr[1] = c;
ptr[2] = 255 - c;
unsigned char* ptr = rgbData + (y * width + x) * bytesPerPixel;
ptr[0] = 255 - y;
ptr[1] = y;
ptr[2] = 255 - y;
}
}
std::vector<unsigned char> mpegData(width * height * bytesPerPixel, 255);
int mpegLen = jo_write_mpeg(mpegData.data(), rgbData.data(), width, height, JO_RGB24, JO_NONE, JO_NONE);
mpegData.resize(mpegLen);
store_mpeg_frame(mpegData);
unsigned char* mpegData = (unsigned char*)calloc(1, width * height * bytesPerPixel);
int mpegLen = jo_write_mpeg(mpegData, rgbData, width, height, JO_RGB24, JO_NONE, JO_NONE);
free(rgbData);
store_mpeg_frame(mpegData, mpegLen);
free(mpegData);
}
DirectShow::DirectShow(int port)
@ -515,15 +416,13 @@ namespace usb_eyetoy
nullrenderer = NULL;
pSourceConfig = NULL;
samplegrabber = NULL;
callbackhandler = new CallbackHandler(this);
callbackhandler = new CallbackHandler();
CoInitialize(NULL);
}
int DirectShow::Open()
{
mpeg_buffer.resize(320 * 240 * 2);
std::fill(mpeg_buffer.begin(), mpeg_buffer.end(), 0);
mpeg_buffer.start = calloc(1, 320 * 240 * 2);
create_dummy_frame();
std::wstring selectedDevice;
@ -538,6 +437,7 @@ namespace usb_eyetoy
pControl->Run();
this->Stop();
this->SetCallback(dshow_callback);
this->Start();
return 0;
@ -545,9 +445,8 @@ namespace usb_eyetoy
int DirectShow::Close()
{
if (!sourcefilter)
return 0;
if (sourcefilter != NULL)
{
this->Stop();
pControl->Stop();
@ -556,24 +455,28 @@ namespace usb_eyetoy
samplegrabberfilter->Release();
samplegrabber->Release();
nullrenderer->Release();
sourcefilter = nullptr;
}
pGraphBuilder->Release();
pGraph->Release();
pControl->Release();
std::lock_guard<std::mutex> lck(mpeg_mutex);
mpeg_buffer.resize(0);
if (mpeg_buffer.start != NULL)
{
free(mpeg_buffer.start);
mpeg_buffer.start = NULL;
}
return 0;
};
int DirectShow::GetImage(uint8_t* buf, int len)
{
std::lock_guard<std::mutex> lck(mpeg_mutex);
int len2 = mpeg_buffer.size();
if (len < mpeg_buffer.size())
mpeg_mutex.lock();
int len2 = mpeg_buffer.length;
if (len < mpeg_buffer.length)
len2 = len;
memcpy(buf, mpeg_buffer.data(), len2);
memcpy(buf, mpeg_buffer.start, len2);
mpeg_mutex.unlock();
return len2;
};

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"