diff options
| author | a1xd <[email protected]> | 2021-01-14 12:27:42 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-14 12:27:42 -0500 |
| commit | 9ea8b4b94bba795eb5060b376baa8e5169e80272 (patch) | |
| tree | 493bfaeb2b59b7db452c52e9ec9713e8b8296510 /wrapper/wrapper.cpp | |
| parent | Merge pull request #53 from termhn/patch-1 (diff) | |
| parent | filter raw input based on id (diff) | |
| download | rawaccel-9ea8b4b94bba795eb5060b376baa8e5169e80272.tar.xz rawaccel-9ea8b4b94bba795eb5060b376baa8e5169e80272.zip | |
Merge pull request #59 from aroidzap/apply-for-specific-device-gui
(GUI) Apply RawAccel only for specific device
Diffstat (limited to 'wrapper/wrapper.cpp')
| -rw-r--r-- | wrapper/wrapper.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index fcbf2e8..2c0d5e3 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -1,13 +1,16 @@ #pragma once #include <type_traits> +#include <msclr\marshal_cppstd.h> #include <rawaccel.hpp> #include <rawaccel-version.h> +#include <utility-rawinput.hpp> #include "wrapper_io.hpp" using namespace System; +using namespace System::Collections::Generic; using namespace System::Runtime::InteropServices; using namespace System::Reflection; @@ -51,7 +54,7 @@ public value struct Vec2 }; [JsonObject(ItemRequired = Required::Always)] -[StructLayout(LayoutKind::Sequential)] +[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Unicode)] public ref struct DriverSettings { literal String^ Key = "Driver settings"; @@ -78,6 +81,10 @@ public ref struct DriverSettings [JsonProperty(Required = Required::Default)] double minimumTime; + [JsonProperty("Device ID", Required = Required::Default)] + [MarshalAs(UnmanagedType::ByValTStr, SizeConst = MAX_DEV_ID_LEN)] + String^ deviceID = ""; + bool ShouldSerializeminimumTime() { return minimumTime > 0 && minimumTime != DEFAULT_TIME_MIN; @@ -217,6 +224,24 @@ public: } }; +public ref struct RawInputInterop +{ + static void AddHandlesFromID(String^ deviceID, List<IntPtr>^ rawInputHandles) + { + try + { + std::vector<HANDLE> nativeHandles = rawinput_handles_from_dev_id( + msclr::interop::marshal_as<std::wstring>(deviceID)); + + for (auto nh : nativeHandles) rawInputHandles->Add(IntPtr(nh)); + } + catch (const std::exception& e) + { + throw gcnew System::Exception(gcnew String(e.what())); + } + } +}; + public ref struct DriverInterop { literal double WriteDelayMs = WRITE_DELAY; |