summaryrefslogtreecommitdiff
path: root/Source/Core/Common/WindowsDevice.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2025-07-19 14:02:43 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2025-07-19 21:24:51 +0200
commit68713e08b4b5009e76147e0109ffef3472477cfe (patch)
tree91dd2424176e3785cf6faeb935228c5d1cd8e892 /Source/Core/Common/WindowsDevice.cpp
parent5cc0a5a3be68c77a7119fab15178f4fd2ab54c54 (diff)
Common: Move GetDeviceProperty() into its own header
Otherwise we include Windows headers in the entire codebase through CommonFuncs.h
Diffstat (limited to 'Source/Core/Common/WindowsDevice.cpp')
-rw-r--r--Source/Core/Common/WindowsDevice.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/Core/Common/WindowsDevice.cpp b/Source/Core/Common/WindowsDevice.cpp
new file mode 100644
index 0000000000..8ecc346187
--- /dev/null
+++ b/Source/Core/Common/WindowsDevice.cpp
@@ -0,0 +1,38 @@
+// Copyright 2025 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifdef _WIN32
+
+#include "Common/WindowsDevice.h"
+
+#include <string>
+
+#include "Common/CommonFuncs.h"
+
+namespace Common
+{
+std::wstring GetDeviceProperty(const HDEVINFO& device_info, const PSP_DEVINFO_DATA device_data,
+ const DEVPROPKEY* requested_property)
+{
+ DWORD required_size = 0;
+ DEVPROPTYPE device_property_type;
+ BOOL result;
+
+ result = SetupDiGetDeviceProperty(device_info, device_data, requested_property,
+ &device_property_type, nullptr, 0, &required_size, 0);
+ if (!result && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return std::wstring();
+
+ std::vector<TCHAR> unicode_buffer(required_size / sizeof(TCHAR));
+
+ result = SetupDiGetDeviceProperty(
+ device_info, device_data, requested_property, &device_property_type,
+ reinterpret_cast<PBYTE>(unicode_buffer.data()), required_size, nullptr, 0);
+ if (!result)
+ return std::wstring();
+
+ return std::wstring(unicode_buffer.data());
+}
+} // namespace Common
+
+#endif