X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fjogshuttle.cpp;h=f53f49166d750db849c15c6be3b84cc9be60c724;hb=67b516688ebe28ebae23296ea72e11ae2fb52cf2;hp=6988045af09571d83a82c95734c920347271513b;hpb=5e706476c65bb87b1c7e1159a82048067d400bcd;p=kdenlive diff --git a/src/jogshuttle.cpp b/src/jogshuttle.cpp index 6988045a..f53f4916 100644 --- a/src/jogshuttle.cpp +++ b/src/jogshuttle.cpp @@ -54,28 +54,23 @@ #define JOG_STOP 10009 -#include -#include -#include - -#include -#include #include #include #include +#include +#include +#include +#include +#include + + #include "jogshuttle.h" -/*unsigned short jogvalue = 0xffff; -int shuttlevalue = 0xffff; -struct timeval last_shuttle; -int need_synthetic_shuttle; -*/ - void ShuttleThread::init(QObject *parent, QString device) { m_parent = parent; m_device = device; @@ -92,18 +87,23 @@ bool ShuttleThread::isWorking() { void ShuttleThread::run() { kDebug() << "------- STARTING SHUTTLE: " << m_device; + const int fd = open((char *) m_device.toUtf8().data(), O_RDONLY); + if (fd < 0) { + fprintf(stderr, "Can't open Jog Shuttle FILE DESCRIPTOR\n"); + return;; + } EV ev; - FILE * fd = fopen((char *) m_device.toUtf8().data(), "r"); - if (!fd) { - fprintf(stderr, "Can't open file\n"); - exit(1); + if (ioctl(fd, EVIOCGRAB, 1) < 0) { + fprintf(stderr, "Can't get exclusive access on Jog Shuttle FILE DESCRIPTOR\n"); + return;; } while (!stop_me) { - while (fread(&ev, sizeof(ev), 1, fd) == 1) handle_event(ev); + read(fd, &ev, sizeof(ev)); + handle_event(ev); } - + close(fd); }