summaryrefslogtreecommitdiffhomepage
path: root/proto-libevdev/ftnoir_protocol_libevdev.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-13 07:46:21 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-13 07:46:21 +0100
commit9f06603e2d752f574b145bc3c4b5e453d7d306d0 (patch)
tree90d8415c98908a7249561682ed6e3a19a6e2b30f /proto-libevdev/ftnoir_protocol_libevdev.cpp
parent8451b16e88b25405d9877243b253a369fd953243 (diff)
proto/libevdev: buffer flush, WIP
Diffstat (limited to 'proto-libevdev/ftnoir_protocol_libevdev.cpp')
-rw-r--r--proto-libevdev/ftnoir_protocol_libevdev.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/proto-libevdev/ftnoir_protocol_libevdev.cpp b/proto-libevdev/ftnoir_protocol_libevdev.cpp
index 8b8e294e..40ce1b80 100644
--- a/proto-libevdev/ftnoir_protocol_libevdev.cpp
+++ b/proto-libevdev/ftnoir_protocol_libevdev.cpp
@@ -1,10 +1,18 @@
#include "ftnoir_protocol_libevdev.h"
#include "api/plugin-api.hpp"
-#include <cstdio>
-#include <algorithm>
+#include <stdio.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include "compat/util.hpp"
+
+#include <algorithm>
#define CHECK_LIBEVDEV(expr) if ((error = (expr)) != 0) goto error;
@@ -87,11 +95,23 @@ void evdev::pose(const double* headpose) {
for (int i = 0; i < 6; i++)
{
int value = headpose[i] * mid_input / max_value[i] + mid_input;
- int normalized = std::max(std::min(max_input, value), min_input);
+ int normalized = clamp(value, min_input, max_input);
(void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized);
}
(void) libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
}
+module_status evdev::initialize()
+{
+ if (access("/dev/uinput", R_OK | W_OK))
+ {
+ char buf[128] {};
+ (void) strerror_r(errno, buf, sizeof(buf));
+ return error(tr("Can't open /dev/uinput: %1").arg(buf));
+ }
+
+ return status_ok();
+}
+
OPENTRACK_DECLARE_PROTOCOL(evdev, LibevdevControls, evdevDll)