From fff0261be5765c44d8fbcf3dffd7ed319cd39a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 4 Mar 2026 11:24:32 +0100 Subject: [PATCH] Minor code cleanups --- Common/UI/UIScreen.cpp | 2 +- Windows/Hid/HidInputDevice.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index df12c1cba0..9cd40c855c 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -12,7 +12,7 @@ #include "Common/UI/Root.h" #include "Common/Render/DrawBuffer.h" -static const bool ClickDebug = false; +static constexpr bool ClickDebug = false; UIScreen::UIScreen() : Screen() { lastOrientation_ = GetDeviceOrientation(); diff --git a/Windows/Hid/HidInputDevice.cpp b/Windows/Hid/HidInputDevice.cpp index e8ac828b49..3673bbe072 100644 --- a/Windows/Hid/HidInputDevice.cpp +++ b/Windows/Hid/HidInputDevice.cpp @@ -70,11 +70,7 @@ static const HIDControllerInfo g_psInfos[] = { // {PSSubType::DS5, DUALSENSE_EDGE_WIRELESS}, }; -static const HIDControllerInfo *GetGamepadInfo(HANDLE handle) { - HIDD_ATTRIBUTES attr{sizeof(HIDD_ATTRIBUTES)}; - if (!HidD_GetAttributes(handle, &attr)) { - return nullptr; - } +static const HIDControllerInfo *GetGamepadInfo(const HIDD_ATTRIBUTES &attr) { for (const auto &info : g_psInfos) { if (attr.VendorID == info.vendorId && attr.ProductID == info.productId) { return &info; @@ -106,7 +102,11 @@ static HANDLE OpenFirstHIDController(HIDControllerType *subType, int *reportSize 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) { - const HIDControllerInfo *info = GetGamepadInfo(handle); + HIDD_ATTRIBUTES attr{sizeof(HIDD_ATTRIBUTES)}; + if (!HidD_GetAttributes(handle, &attr)) { + return nullptr; + } + const HIDControllerInfo *info = GetGamepadInfo(attr); *outInfo = info; if (info) { *subType = info->type;