mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
WiimoteReal/IOWin: Major cleanups and improvements.
This commit is contained in:
parent
3978e1eb2c
commit
e0c40025a9
File diff suppressed because it is too large
Load Diff
@ -6,26 +6,22 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/HW/WiimoteCommon/WiimoteHid.h"
|
||||
#include "Common/SocketContext.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "Core/USBUtils.h"
|
||||
|
||||
namespace WiimoteReal
|
||||
{
|
||||
// Different methods to send data Wiimote on Windows depending on OS and Bluetooth Stack
|
||||
enum WinWriteMethod
|
||||
{
|
||||
WWM_WRITE_FILE_LARGEST_REPORT_SIZE,
|
||||
WWM_WRITE_FILE_ACTUAL_REPORT_SIZE,
|
||||
WWM_SET_OUTPUT_REPORT
|
||||
};
|
||||
class WiimoteScannerWindows;
|
||||
|
||||
class WiimoteWindows final : public Wiimote
|
||||
{
|
||||
friend WiimoteScannerWindows;
|
||||
|
||||
public:
|
||||
WiimoteWindows(const std::basic_string<TCHAR>& path, WinWriteMethod initial_write_method);
|
||||
WiimoteWindows(std::wstring hid_iface);
|
||||
~WiimoteWindows() override;
|
||||
std::string GetId() const override { return WStringToUTF8(m_devicepath); }
|
||||
std::string GetId() const override;
|
||||
|
||||
protected:
|
||||
bool ConnectInternal() override;
|
||||
@ -36,11 +32,19 @@ protected:
|
||||
int IOWrite(u8 const* buf, size_t len) override;
|
||||
|
||||
private:
|
||||
std::basic_string<TCHAR> m_devicepath; // Unique Wiimote reference
|
||||
HANDLE m_dev_handle; // HID handle
|
||||
OVERLAPPED m_hid_overlap_read; // Overlap handles
|
||||
OVERLAPPED m_hid_overlap_write;
|
||||
WinWriteMethod m_write_method; // Type of Write Method to use
|
||||
// These return 0 on error. -1 on no data.
|
||||
int OverlappedRead(u8* data, DWORD size);
|
||||
int OverlappedWrite(const u8* data, DWORD size);
|
||||
|
||||
const std::wstring m_hid_iface;
|
||||
|
||||
HANDLE m_dev_handle{INVALID_HANDLE_VALUE};
|
||||
HANDLE m_wakeup_event{INVALID_HANDLE_VALUE};
|
||||
|
||||
OVERLAPPED m_hid_overlap_read{};
|
||||
OVERLAPPED m_hid_overlap_write{};
|
||||
|
||||
std::atomic_bool m_is_connected{};
|
||||
};
|
||||
|
||||
class WiimoteScannerWindows final : public WiimoteScannerBackend
|
||||
@ -51,6 +55,12 @@ public:
|
||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||
void Update() override;
|
||||
void RequestStopSearching() override {}
|
||||
|
||||
static void FindAndAuthenticateWiimotes();
|
||||
static void RemoveRememberedWiimotes();
|
||||
|
||||
private:
|
||||
void FindWiimoteHIDDevices(std::vector<Wiimote*>&, Wiimote*&);
|
||||
};
|
||||
} // namespace WiimoteReal
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user