From d5285d9c7f8a9a9be90eda6802a4adf8eb495f90 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 1 Nov 2014 09:42:58 +0100 Subject: remove libevdev tracker Issue: #75 --- .../ftnoir_tracker_libevdev.cpp | 118 --------------------- 1 file changed, 118 deletions(-) delete mode 100644 ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp (limited to 'ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp') diff --git a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp b/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp deleted file mode 100644 index 4ad3c624..00000000 --- a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "ftnoir_tracker_libevdev.h" -#include "opentrack/plugin-api.hpp" - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -static const int ot_libevdev_joystick_axes[6] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; - -FTNoIR_Tracker::FTNoIR_Tracker() : node(nullptr), success(false), should_quit(false) -{ -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - if (success) - { - should_quit = true; - wait(); - } - if (node) - libevdev_free(node); - if (fd != -1) - close(fd); -} - -void FTNoIR_Tracker::start_tracker(QFrame*) -{ - QString node_name = s.device_name; - std::string str = (QString("/dev/input/by-id/") + node_name).toStdString(); - const char* filename = str.c_str(); - - fd = open(filename, O_NONBLOCK, O_RDWR); - if (fd == -1) - { - qDebug() << "error opening" << filename; - return; - } - - int ret = libevdev_new_from_fd(fd, &node); - if (ret) - { - qDebug() << "libevdev open error" << ret; - return; - } - - for (int i = 0; i < 6; i++) - { - // no error checking here, errors result in SIGFPE - a_min[i] = libevdev_get_abs_minimum(node, ot_libevdev_joystick_axes[i]); - a_max[i] = libevdev_get_abs_maximum(node, ot_libevdev_joystick_axes[i]); - - if (a_min[i] == a_max[i]) - a_max[i]++; - - qDebug() << "axis limits" << i << a_min[i] << "->" << a_max[i]; - } - - success = true; - - QThread::start(); -} - -void FTNoIR_Tracker::run() -{ - while (!should_quit) - { - msleep(1); - - while (1) - { - struct input_event ev; - int status = libevdev_next_event(node, LIBEVDEV_READ_FLAG_NORMAL, &ev); - if (status != LIBEVDEV_READ_STATUS_SUCCESS) - break; - if (ev.type == EV_ABS) - { - const int code = ev.code; - for (int i = 0; i < 6; i++) - { - if (ot_libevdev_joystick_axes[i] == code) - { - QMutexLocker l(&mtx); - values[i] = ev.value; - break; - } - } - } - } - } -} - -void FTNoIR_Tracker::data(double *data) -{ - if (node) - { - QMutexLocker l(&mtx); - for (int i = 0; i < 6; i++) - { - int val = values[i]; - double v = (val - a_min[i])*(i >= Yaw ? 180. : 100.) / a_max[i] - a_min[i]; - data[i] = v; - } - } -} - -extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() -{ - return new FTNoIR_Tracker; -} -- cgit v1.2.3