mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Compare commits
4 Commits
1547b813bc
...
546bf3db7d
Author | SHA1 | Date | |
---|---|---|---|
|
546bf3db7d | ||
|
2c92e5b5b3 | ||
|
fe96bf4108 | ||
|
5dede61af7 |
@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "SDL2",
|
|
||||||
"buildsystem": "autotools",
|
|
||||||
"config-opts": ["--disable-static"],
|
|
||||||
"sources": [
|
|
||||||
{
|
|
||||||
"type": "dir",
|
|
||||||
"path": "../../Externals/SDL/SDL"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"cleanup": [ "/bin/sdl2-config",
|
|
||||||
"/include",
|
|
||||||
"/lib/libSDL2.la",
|
|
||||||
"/lib/libSDL2main.a",
|
|
||||||
"/lib/libSDL2main.la",
|
|
||||||
"/lib/libSDL2_test.a",
|
|
||||||
"/lib/libSDL2_test.la",
|
|
||||||
"/lib/cmake",
|
|
||||||
"/share/aclocal",
|
|
||||||
"/lib/pkgconfig"]
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
app-id: org.DolphinEmu.dolphin-emu
|
app-id: org.DolphinEmu.dolphin-emu
|
||||||
runtime: org.kde.Platform
|
runtime: org.kde.Platform
|
||||||
runtime-version: '6.7'
|
runtime-version: '6.8'
|
||||||
sdk: org.kde.Sdk
|
sdk: org.kde.Sdk
|
||||||
command: dolphin-emu-wrapper
|
command: dolphin-emu-wrapper
|
||||||
rename-desktop-file: dolphin-emu.desktop
|
rename-desktop-file: dolphin-emu.desktop
|
||||||
@ -47,9 +47,6 @@ modules:
|
|||||||
url: https://github.com/Unrud/xdg-screensaver-shim/archive/0.0.2.tar.gz
|
url: https://github.com/Unrud/xdg-screensaver-shim/archive/0.0.2.tar.gz
|
||||||
sha256: 0ed2a69fe6ee6cbffd2fe16f85116db737f17fb1e79bfb812d893cf15c728399
|
sha256: 0ed2a69fe6ee6cbffd2fe16f85116db737f17fb1e79bfb812d893cf15c728399
|
||||||
|
|
||||||
# build the vendored SDL2 from Externals until the runtime gets 2.30.6
|
|
||||||
- SDL2/SDL2.json
|
|
||||||
|
|
||||||
- name: dolphin-emu
|
- name: dolphin-emu
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
config-opts:
|
config-opts:
|
||||||
|
@ -4,9 +4,12 @@
|
|||||||
#include "Core/HW/WiimoteReal/IOWin.h"
|
#include "Core/HW/WiimoteReal/IOWin.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
@ -424,6 +427,23 @@ WinWriteMethod GetInitialWriteMethod(bool IsUsingToshibaStack)
|
|||||||
WWM_WRITE_FILE_ACTUAL_REPORT_SIZE);
|
WWM_WRITE_FILE_ACTUAL_REPORT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> TryGetDeviceName(HANDLE handle)
|
||||||
|
{
|
||||||
|
// Buffers larger than 4093 bytes may cause HidD_GetProductString to fail according to
|
||||||
|
// https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/hidsdi/nf-hidsdi-hidd_getproductstring
|
||||||
|
// USB devices have a maximum string length of 127 (with null terminator) but the maximum length
|
||||||
|
// for Bluetooth or SPI devices isn't listed, so use the biggest valid buffer to be safe.
|
||||||
|
static constexpr auto PRODUCT_STRING_BUFFER_SIZE = 4093;
|
||||||
|
std::array<WCHAR, PRODUCT_STRING_BUFFER_SIZE> product_string_buffer;
|
||||||
|
|
||||||
|
const bool read_successful = pHidD_GetProductString(
|
||||||
|
handle, static_cast<PVOID>(product_string_buffer.data()), PRODUCT_STRING_BUFFER_SIZE);
|
||||||
|
if (!read_successful)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
return WStringToUTF8(product_string_buffer.data());
|
||||||
|
}
|
||||||
|
|
||||||
int WriteToHandle(HANDLE& dev_handle, WinWriteMethod& method, const u8* buf, size_t size)
|
int WriteToHandle(HANDLE& dev_handle, WinWriteMethod& method, const u8* buf, size_t size)
|
||||||
{
|
{
|
||||||
OVERLAPPED hid_overlap_write = OVERLAPPED();
|
OVERLAPPED hid_overlap_write = OVERLAPPED();
|
||||||
@ -454,6 +474,13 @@ int ReadFromHandle(HANDLE& dev_handle, u8* buf)
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValidVendorIDAndProductID(const u16 vendor_id, const u16 product_id)
|
||||||
|
{
|
||||||
|
if (vendor_id != 0x057e)
|
||||||
|
return false;
|
||||||
|
return product_id == 0x0306 || product_id == 0x0330;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& method)
|
bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& method)
|
||||||
{
|
{
|
||||||
using namespace WiimoteCommon;
|
using namespace WiimoteCommon;
|
||||||
@ -466,6 +493,29 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
|
|||||||
|
|
||||||
Common::ScopeGuard handle_guard{[&dev_handle] { CloseHandle(dev_handle); }};
|
Common::ScopeGuard handle_guard{[&dev_handle] { CloseHandle(dev_handle); }};
|
||||||
|
|
||||||
|
const std::optional<std::string> device_name_opt = TryGetDeviceName(dev_handle);
|
||||||
|
const std::string name = device_name_opt ? *device_name_opt : "NO_NAME";
|
||||||
|
const bool name_is_valid = device_name_opt && IsValidDeviceName(name);
|
||||||
|
|
||||||
|
HIDD_ATTRIBUTES attributes;
|
||||||
|
const bool read_successful = pHidD_GetAttributes(dev_handle, &attributes);
|
||||||
|
const u16 vendor_id = read_successful ? attributes.VendorID : 0;
|
||||||
|
const u16 product_id = read_successful ? attributes.ProductID : 0;
|
||||||
|
const bool is_valid_vendor_and_product = IsValidVendorIDAndProductID(vendor_id, product_id);
|
||||||
|
|
||||||
|
DEBUG_LOG_FMT(WIIMOTE, "IsWiimote() vendor_id: {:04x} product_id: {:04x} name: {}", vendor_id,
|
||||||
|
product_id, name);
|
||||||
|
|
||||||
|
if (!name_is_valid && !is_valid_vendor_and_product)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// The rest of this function is unnecessary but harmless for official Wii Remotes, but the
|
||||||
|
// DolphinBar doesn't properly sync until it responds correctly to a status request (which
|
||||||
|
// sometimes takes more than one attempt). We could return early if the name, vendor_id, and
|
||||||
|
// product_id all match those of an official Wii Remote, but it's possible some third party remote
|
||||||
|
// appears identical to an official one but also requires the following behavior. To be safe, go
|
||||||
|
// ahead and do it regardless.
|
||||||
|
|
||||||
u8 buf[MAX_PAYLOAD];
|
u8 buf[MAX_PAYLOAD];
|
||||||
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
|
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
|
||||||
int invalid_report_count = 0;
|
int invalid_report_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user