summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-09-03 18:15:39 -0400
committera1xd <[email protected]>2021-09-23 22:28:44 -0400
commit3dc64cc13a7a2a6da843fdd33e0791f154e8a2dc (patch)
treef3984f39d9b7b726601219ddfc7c5fb866c8ce74 /common
parentrefactor vec2/math (diff)
downloadrawaccel-3dc64cc13a7a2a6da843fdd33e0791f154e8a2dc.tar.xz
rawaccel-3dc64cc13a7a2a6da843fdd33e0791f154e8a2dc.zip
make ioctls constexpr
Diffstat (limited to 'common')
-rw-r--r--common/rawaccel-io-def.h10
-rw-r--r--common/rawaccel-io.hpp11
2 files changed, 8 insertions, 13 deletions
diff --git a/common/rawaccel-io-def.h b/common/rawaccel-io-def.h
index 399e0f2..2f67b8f 100644
--- a/common/rawaccel-io-def.h
+++ b/common/rawaccel-io-def.h
@@ -8,8 +8,8 @@
#include <Windows.h>
#endif
-#define RA_DEV_TYPE 0x8888u
-
-#define RA_READ CTL_CODE(RA_DEV_TYPE, 0x888, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define RA_WRITE CTL_CODE(RA_DEV_TYPE, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define RA_GET_VERSION CTL_CODE(RA_DEV_TYPE, 0x88a, METHOD_BUFFERED, FILE_ANY_ACCESS)
+namespace rawaccel {
+ constexpr ULONG READ = (ULONG)CTL_CODE(0x8888u, 0x888, METHOD_BUFFERED, FILE_ANY_ACCESS);
+ constexpr ULONG WRITE = (ULONG)CTL_CODE(0x8888u, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS);
+ constexpr ULONG GET_VERSION = (ULONG)CTL_CODE(0x8888u, 0x88a, METHOD_BUFFERED, FILE_ANY_ACCESS);
+} \ No newline at end of file
diff --git a/common/rawaccel-io.hpp b/common/rawaccel-io.hpp
index a80e254..57bf707 100644
--- a/common/rawaccel-io.hpp
+++ b/common/rawaccel-io.hpp
@@ -5,9 +5,6 @@
#include "rawaccel-error.hpp"
#include "rawaccel.hpp"
-#pragma warning(push)
-#pragma warning(disable:4245) // int -> DWORD conversion while passing CTL_CODE
-
namespace rawaccel {
inline void io_control(DWORD code, void* in, DWORD in_size, void* out, DWORD out_size)
@@ -42,12 +39,12 @@ namespace rawaccel {
inline void read(io_t& args)
{
- io_control(RA_READ, NULL, 0, &args, sizeof(io_t));
+ io_control(READ, NULL, 0, &args, sizeof(io_t));
}
inline void write(const io_t& args)
{
- io_control(RA_WRITE, const_cast<io_t*>(&args), sizeof(io_t), NULL, 0);
+ io_control(WRITE, const_cast<io_t*>(&args), sizeof(io_t), NULL, 0);
}
inline version_t get_version()
@@ -55,7 +52,7 @@ namespace rawaccel {
version_t v;
try {
- io_control(RA_GET_VERSION, NULL, 0, &v, sizeof(version_t));
+ io_control(GET_VERSION, NULL, 0, &v, sizeof(version_t));
}
catch (const sys_error&) {
// assume request is not implemented (< 1.3)
@@ -81,5 +78,3 @@ namespace rawaccel {
}
}
-
-#pragma warning(pop)