diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-01 09:42:58 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-01 09:42:58 +0100 |
commit | d5285d9c7f8a9a9be90eda6802a4adf8eb495f90 (patch) | |
tree | b88659227b7c53da689fc44eeaf54c19d279ae0a /ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp | |
parent | 730ad505abee026791b3d4b5b3e4551559f8216a (diff) |
remove libevdev tracker
Issue: #75
Diffstat (limited to 'ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp')
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp | 118 |
1 files changed, 0 insertions, 118 deletions
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 <algorithm> - -#include <QDir> -#include <QDebug> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <unistd.h> -#include <string> - -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; -} |