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 | |
parent | 730ad505abee026791b3d4b5b3e4551559f8216a (diff) |
remove libevdev tracker
Issue: #75
Diffstat (limited to 'ftnoir_tracker_libevdev')
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_libevdev.ui | 56 | ||||
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.cpp | 118 | ||||
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.h | 59 | ||||
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dialog.cpp | 35 | ||||
-rw-r--r-- | ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dll.cpp | 7 |
5 files changed, 0 insertions, 275 deletions
diff --git a/ftnoir_tracker_libevdev/ftnoir_libevdev.ui b/ftnoir_tracker_libevdev/ftnoir_libevdev.ui deleted file mode 100644 index 6c1ebcae..00000000 --- a/ftnoir_tracker_libevdev/ftnoir_libevdev.ui +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ui_libevdev_tracker_dialog</class> - <widget class="QWidget" name="ui_libevdev_tracker_dialog"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>677</width> - <height>90</height> - </rect> - </property> - <property name="windowTitle"> - <string>libevdev tracker settings</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>../facetracknoir/images/facetracknoir.png</normaloff>../facetracknoir/images/facetracknoir.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QComboBox" name="comboBox"/> - </item> - <item row="1" column="1"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Device</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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; -} diff --git a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.h b/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.h deleted file mode 100644 index 0ae1c8b3..00000000 --- a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once -#include <cmath> -#include "libevdev/libevdev.h" -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -#include "./ui_ftnoir_libevdev.h" -#include <QThread> -#include <QMutex> -#include <QMutexLocker> -using namespace options; - -struct settings { - pbundle b; - value<QString> device_name; - settings() : - b(bundle("libevdev-tracker")), - device_name(b, "device-name", "") - {} -}; - -class FTNoIR_Tracker : public ITracker, private QThread -{ -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker() override; - void start_tracker(QFrame *); - void data(double *data); -private: - void run() override; - struct libevdev* node; - int fd; - settings s; - bool success; - int a_min[6], a_max[6], values[6]; - QMutex mtx; - volatile bool should_quit; -}; - -class TrackerControls: public ITrackerDialog -{ - Q_OBJECT -public: - TrackerControls(); - void register_tracker(ITracker *) {} - void unregister_tracker() {} -private: - Ui::ui_libevdev_tracker_dialog ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_TrackerDll : public Metadata -{ -public: - QString name() { return QString("libevdev joystick input"); } - QIcon icon() { return QIcon(":/images/facetracknoir.png"); } -}; diff --git a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dialog.cpp b/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dialog.cpp deleted file mode 100644 index 02f48639..00000000 --- a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dialog.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "ftnoir_tracker_libevdev.h" -#include "opentrack/plugin-api.hpp" - -#include <QDir> - -TrackerControls::TrackerControls() -{ - ui.setupUi(this); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - ui.comboBox->clear(); - - QDir dir("/dev/input/by-id"); - auto devices = dir.entryList(QStringList { "usb-?*-event-?*"}); - for (QString dev : devices) - ui.comboBox->addItem(dev); - tie_setting(s.device_name, ui.comboBox); -} - -void TrackerControls::doOK() { - s.b->save(); - this->close(); -} - -void TrackerControls::doCancel() { - s.b->reload(); - this->close(); -} - -extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog() -{ - return new TrackerControls; -} diff --git a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dll.cpp b/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dll.cpp deleted file mode 100644 index 26c858b9..00000000 --- a/ftnoir_tracker_libevdev/ftnoir_tracker_libevdev_dll.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "ftnoir_tracker_libevdev.h" -#include "opentrack/plugin-api.hpp" - -extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() -{ - return new FTNoIR_TrackerDll; -} |