]> git.sesse.net Git - kdenlive/blobdiff - src/jogshuttle.cpp
Krazy fixes: cleanup all headers
[kdenlive] / src / jogshuttle.cpp
index 6988045af09571d83a82c95734c920347271513b..1b6df679dbac2ba348eaaa17dcff3c3793069faa 100644 (file)
  ***************************************************************************/
 
 
+#include "jogshuttle.h"
+
+#include <KDebug>
+#include <kde_file.h>
+
+#include <QApplication>
+#include <QEvent>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/input.h>
+
 
 #define DELAY 10
 
 #define JOG_STOP 10009
 
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <QFile>
-#include <QTextStream>
-#include <QApplication>
-#include <QEvent>
-
-#include <KDebug>
-
-
-
-#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 +84,23 @@ bool ShuttleThread::isWorking() {
 void ShuttleThread::run() {
     kDebug() << "-------  STARTING SHUTTLE: " << m_device;
 
+    const int fd = KDE_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);
 
 }