summaryrefslogtreecommitdiff
path: root/console
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 /console
parentadd read (diff)
downloadrawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.tar.xz
rawaccel-66a4043a9ecb1990878bea230f213708c7fdd3da.zip
move write function into common io header
Diffstat (limited to 'console')
-rw-r--r--console/console.cpp9
-rw-r--r--console/console.vcxproj2
-rw-r--r--console/console_write.cpp32
-rw-r--r--console/console_write.hpp14
4 files changed, 4 insertions, 53 deletions
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