mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Windows: Cache unsupported HID device paths during HID controller polling
This commit is contained in:
@@ -81,7 +81,7 @@ static const HIDControllerInfo *GetGamepadInfo(const HIDD_ATTRIBUTES &attr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static HANDLE OpenFirstHIDController(HIDControllerType *subType, int *reportSize, int *outReportSize, const HIDControllerInfo **outInfo) {
|
||||
static HANDLE OpenFirstHIDController(std::unordered_set<std::wstring> &ignoreHidDevicePaths, HIDControllerType *subType, int *reportSize, int *outReportSize, const HIDControllerInfo **outInfo) {
|
||||
GUID hidGuid;
|
||||
HidD_GetHidGuid(&hidGuid);
|
||||
|
||||
@@ -104,6 +104,11 @@ static HANDLE OpenFirstHIDController(HIDControllerType *subType, int *reportSize
|
||||
continue;
|
||||
}
|
||||
|
||||
std::wstring hidDevicePath = detailData->DevicePath;
|
||||
if (ignoreHidDevicePaths.find(hidDevicePath) != ignoreHidDevicePaths.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HANDLE handle = CreateFile(detailData->DevicePath, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
@@ -120,6 +125,7 @@ static HANDLE OpenFirstHIDController(HIDControllerType *subType, int *reportSize
|
||||
*outInfo = info;
|
||||
if (!info) {
|
||||
CloseHandle(handle);
|
||||
ignoreHidDevicePaths.insert(hidDevicePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -223,7 +229,7 @@ int HidInputDevice::UpdateState() {
|
||||
if (pollCount_ == 0) {
|
||||
pollCount_ = POLL_FREQ;
|
||||
const HIDControllerInfo *info{};
|
||||
HANDLE newController = OpenFirstHIDController(&subType_, &inReportSize_, &outReportSize_, &info);
|
||||
HANDLE newController = OpenFirstHIDController(ignoreHidDevicePaths_, &subType_, &inReportSize_, &outReportSize_, &info);
|
||||
if (newController) {
|
||||
controller_ = newController;
|
||||
if (info) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Input/InputState.h"
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
HIDControllerType subType_{};
|
||||
HANDLE controller_;
|
||||
std::string name_;
|
||||
std::unordered_set<std::wstring> ignoreHidDevicePaths_;
|
||||
int pad_ = 0;
|
||||
int pollCount_ = 0;
|
||||
int inReportSize_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user