summaryrefslogtreecommitdiff
path: root/console/console_write.cpp
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-29 15:39:39 -0700
committerJacob Palecki <[email protected]>2020-07-29 15:39:39 -0700
commit0a8effcccac92ffd591f94c276fb797dd31f51ab (patch)
tree8e2185a334e5c7dbfc0e219b164ef9c89e209f42 /console/console_write.cpp
parentAdded skeleton for input fields (diff)
downloadrawaccel-0a8effcccac92ffd591f94c276fb797dd31f51ab.tar.xz
rawaccel-0a8effcccac92ffd591f94c276fb797dd31f51ab.zip
Compiles but may file
Diffstat (limited to 'console/console_write.cpp')
-rw-r--r--console/console_write.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/console/console_write.cpp b/console/console_write.cpp
new file mode 100644
index 0000000..3240ea5
--- /dev/null
+++ b/console/console_write.cpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "console_write.hpp"
+
+void write(ra::mouse_modifier vars) {
+ 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_WRITE,
+ &vars,
+ sizeof(ra::mouse_modifier),
+ 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");
+ }
+}