summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-31 20:19:24 -0400
committera1xd <[email protected]>2020-07-31 20:19:24 -0400
commit66a4043a9ecb1990878bea230f213708c7fdd3da (patch)
treee0bcad437a3170f391fc74fe723be6abaf41cd89 /common
parentadd read (diff)
downloadrawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.tar.xz
rawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.zip
move write function into common io header
Diffstat (limited to 'common')
-rw-r--r--common/rawaccel-io.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/rawaccel-io.hpp b/common/rawaccel-io.hpp
index 5d6fad6..7a4c59c 100644
--- a/common/rawaccel-io.hpp
+++ b/common/rawaccel-io.hpp
@@ -43,4 +43,33 @@ namespace rawaccel {
return mod;
}
+ void write(mouse_modifier mod) {
+ HANDLE ra_handle = INVALID_HANDLE_VALUE;
+
+ ra_handle = CreateFileW(L"\\\\.\\rawaccel", 0, 0, 0, OPEN_EXISTING, 0, 0);
+
+ if (ra_handle == INVALID_HANDLE_VALUE) {
+ throw std::system_error(GetLastError(), std::system_category(), "CreateFile failed");
+ }
+
+ DWORD dummy;
+
+ BOOL success = DeviceIoControl(
+ ra_handle,
+ RA_IOCTL,
+ &mod, // input buffer
+ sizeof(mouse_modifier), // input buffer size
+ NULL, // output buffer
+ 0, // output buffer size
+ &dummy, // bytes returned
+ NULL // overlapped structure
+ );
+
+ CloseHandle(ra_handle);
+
+ if (!success) {
+ throw std::system_error(GetLastError(), std::system_category(), "DeviceIoControl failed");
+ }
+ }
+
}