diff options
| author | Jacob Palecki <[email protected]> | 2020-07-29 15:39:39 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-29 15:39:39 -0700 |
| commit | 0a8effcccac92ffd591f94c276fb797dd31f51ab (patch) | |
| tree | 8e2185a334e5c7dbfc0e219b164ef9c89e209f42 /console | |
| parent | Added skeleton for input fields (diff) | |
| download | rawaccel-0a8effcccac92ffd591f94c276fb797dd31f51ab.tar.xz rawaccel-0a8effcccac92ffd591f94c276fb797dd31f51ab.zip | |
Compiles but may file
Diffstat (limited to 'console')
| -rw-r--r-- | console/console.cpp | 34 | ||||
| -rw-r--r-- | console/console.vcxproj | 2 | ||||
| -rw-r--r-- | console/console_write.cpp | 32 | ||||
| -rw-r--r-- | console/console_write.hpp | 14 |
4 files changed, 49 insertions, 33 deletions
diff --git a/console/console.cpp b/console/console.cpp index 490051c..549cb68 100644 --- a/console/console.cpp +++ b/console/console.cpp @@ -4,39 +4,7 @@ #include <Windows.h> #include <rawaccel-userspace.hpp> - -#define RA_WRITE CTL_CODE(0x8888, 0x888, METHOD_BUFFERED, FILE_ANY_ACCESS) - -namespace ra = rawaccel; - -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"); - } -} +#include "console_write.hpp" int main(int argc, char** argv) { try { diff --git a/console/console.vcxproj b/console/console.vcxproj index d0ad292..05780cd 100644 --- a/console/console.vcxproj +++ b/console/console.vcxproj @@ -90,6 +90,8 @@ </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="console.cpp" /> + <ClCompile Include="console_write.cpp" /> + <ClCompile Include="console_write.hpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> 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"); + } +} diff --git a/console/console_write.hpp b/console/console_write.hpp new file mode 100644 index 0000000..31eb575 --- /dev/null +++ b/console/console_write.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include <iostream> + +#define NOMINMAX +#include <Windows.h> + +#include "..\common\rawaccel.hpp" + +#define RA_WRITE CTL_CODE(0x8888, 0x888, METHOD_BUFFERED, FILE_ANY_ACCESS) + +namespace ra = rawaccel; + +void write(ra::mouse_modifier vars);
\ No newline at end of file |