Compare commits

...

4 Commits

Author SHA1 Message Date
Dentomologist
546bf3db7d
Merge 5dede61af7 into 2c92e5b5b3 2024-11-12 13:28:59 -06:00
OatmealDome
2c92e5b5b3
Merge pull request #13160 from cpba/flatpak-6.8-runtime
Flatpak: Upgrade kde runtime to 6.8
2024-11-12 00:30:46 -05:00
Carles Pastor
fe96bf4108 Flatpak: Upgrade kde runtime to 6.8
this version bundles SDL2-2.30.6, the temporary measure of building the
vendored version from exports is no longer necessary.
2024-11-10 12:06:06 +01:00
Dentomologist
5dede61af7 WiimoteWindows: Rework IsWiimote check to avoid Log spam
Only send requests for a status report if the device either has a valid
device name or a valid vendor_id/product_id combination.

This prevents Log spam of "Error on Writefile: Incorrect Function" or
"The parameter is incorrect" from other types of devices.
2023-09-07 14:38:18 -07:00
3 changed files with 51 additions and 26 deletions

View File

@ -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"]
}

View File

@ -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:

View File

@ -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;