diff options
| author | a1xd <[email protected]> | 2020-07-31 20:19:24 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-07-31 20:19:24 -0400 |
| commit | 66a4043a9ecb1990878bea230f213708c7fdd3da (patch) | |
| tree | e0bcad437a3170f391fc74fe723be6abaf41cd89 | |
| parent | add read (diff) | |
| download | rawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.tar.xz rawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.zip | |
move write function into common io header
| -rw-r--r-- | common/rawaccel-io.hpp | 29 | ||||
| -rw-r--r-- | console/console.cpp | 9 | ||||
| -rw-r--r-- | console/console.vcxproj | 2 | ||||
| -rw-r--r-- | console/console_write.cpp | 32 | ||||
| -rw-r--r-- | console/console_write.hpp | 14 | ||||
| -rw-r--r-- | rawaccel.sln | 3 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 1 | ||||
| -rw-r--r-- | wrapper/wrapper.hpp | 14 | ||||
| -rw-r--r-- | wrapper/wrapper.vcxproj | 1 | ||||
| -rw-r--r-- | wrapper/wrapper_writer.cpp | 4 | ||||
| -rw-r--r-- | wrapper/wrapper_writer.hpp | 2 |
11 files changed, 45 insertions, 66 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"); + } + } + } diff --git a/console/console.cpp b/console/console.cpp index 549cb68..00dc481 100644 --- a/console/console.cpp +++ b/console/console.cpp @@ -1,14 +1,13 @@ #include <iostream> -#define NOMINMAX -#include <Windows.h> - #include <rawaccel-userspace.hpp> -#include "console_write.hpp" +#include <rawaccel-io.hpp> + +namespace ra = rawaccel; int main(int argc, char** argv) { try { - write(ra::parse(argc, argv)); + ra::write(ra::parse(argc, argv)); } catch (std::domain_error e) { std::cerr << e.what() << '\n'; diff --git a/console/console.vcxproj b/console/console.vcxproj index 05780cd..d0ad292 100644 --- a/console/console.vcxproj +++ b/console/console.vcxproj @@ -90,8 +90,6 @@ </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 deleted file mode 100644 index 3240ea5..0000000 --- a/console/console_write.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#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 deleted file mode 100644 index 31eb575..0000000 --- a/console/console_write.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#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 diff --git a/rawaccel.sln b/rawaccel.sln index 2235818..0db5ecb 100644 --- a/rawaccel.sln +++ b/rawaccel.sln @@ -23,10 +23,9 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution common-install\common-install.vcxitems*{058d66c6-d88b-4fdb-b0e4-0a6fe7483b95}*SharedItemsImports = 9 common\common.vcxitems*{24b4226f-1461-408f-a1a4-1371c97153ea}*SharedItemsImports = 9 - common\common.vcxitems*{60d6c942-ac20-4c05-a2be-54b5c966534d}*SharedItemsImports = 4 + common\common.vcxitems*{28a3656f-a1de-405c-b547-191c32ec555f}*SharedItemsImports = 4 common-install\common-install.vcxitems*{896950d1-520a-420a-b6b1-73014b92a68c}*SharedItemsImports = 4 common-install\common-install.vcxitems*{a4097ff6-a6f0-44e8-b8d0-538d0fb75936}*SharedItemsImports = 4 - common\common.vcxitems*{ab7b3759-b85f-4067-8935-fb4539b41869}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index ceee1a1..bd0574f 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -1,6 +1,7 @@ #pragma once #include "wrapper.hpp" + using namespace rawaccel; using namespace System; diff --git a/wrapper/wrapper.hpp b/wrapper/wrapper.hpp index 870aca7..e8f100d 100644 --- a/wrapper/wrapper.hpp +++ b/wrapper/wrapper.hpp @@ -1,16 +1,14 @@ #pragma once -#include "wrapper_writer.hpp" -#include "..\common\rawaccel.hpp"; -#include "..\common\accel-error.hpp"; #include <iostream> -using namespace rawaccel; -using namespace System; +#include <rawaccel.hpp> +#include <accel-error.hpp> -public value struct ArgsWrapper { - int a; -}; +#include "wrapper_writer.hpp" + +using namespace rawaccel; +using namespace System; public ref class ManagedAccel { diff --git a/wrapper/wrapper.vcxproj b/wrapper/wrapper.vcxproj index 28acbe7..bffbf8b 100644 --- a/wrapper/wrapper.vcxproj +++ b/wrapper/wrapper.vcxproj @@ -59,6 +59,7 @@ <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="Shared"> + <Import Project="..\common\common.vcxitems" Label="Shared" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> diff --git a/wrapper/wrapper_writer.cpp b/wrapper/wrapper_writer.cpp index 0a74105..da7c9bf 100644 --- a/wrapper/wrapper_writer.cpp +++ b/wrapper/wrapper_writer.cpp @@ -1,9 +1,9 @@ #pragma once -#include "..\console\console_write.cpp" +#include <rawaccel-io.hpp> #include "wrapper_writer.hpp" void writer::writeToDriver(rawaccel::mouse_modifier* modifier) { - write(*modifier); + rawaccel::write(*modifier); } diff --git a/wrapper/wrapper_writer.hpp b/wrapper/wrapper_writer.hpp index 591f62f..dcbef10 100644 --- a/wrapper/wrapper_writer.hpp +++ b/wrapper/wrapper_writer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "..\common\rawaccel.hpp" +#include <rawaccel.hpp> struct writer { void writeToDriver(rawaccel::mouse_modifier* modifier); |