]> git.sesse.net Git - kdenlive/blobdiff - src/jogshuttle.cpp
Reindent the codebase using 'linux' bracket placement.
[kdenlive] / src / jogshuttle.cpp
index f53f49166d750db849c15c6be3b84cc9be60c724..1a14e3ff0f2fdfba89ff947a00eaffa98417c963 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 <QApplication>
-#include <QEvent>
-
-#include <KDebug>
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <linux/input.h>
-
-
-
-#include "jogshuttle.h"
-
-
-void ShuttleThread::init(QObject *parent, QString device) {
+void ShuttleThread::init(QObject *parent, QString device)
+{
     m_parent = parent;
     m_device = device;
     stop_me = false;
@@ -80,14 +78,16 @@ void ShuttleThread::init(QObject *parent, QString device) {
     jogvalue = 0xffff;
 }
 
-bool ShuttleThread::isWorking() {
+bool ShuttleThread::isWorking()
+{
     return m_isWorking;
 }
 
-void ShuttleThread::run() {
+void ShuttleThread::run()
+{
     kDebug() << "-------  STARTING SHUTTLE: " << m_device;
 
-    const int fd = open((char *) m_device.toUtf8().data(), O_RDONLY);
+    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;;
@@ -100,14 +100,17 @@ void ShuttleThread::run() {
     }
 
     while (!stop_me) {
-        read(fd, &ev, sizeof(ev));
+        if (read(fd, &ev, sizeof(ev)) < 0) {
+            fprintf(stderr, "Failed to read event from Jog Shuttle FILE DESCRIPTOR\n");
+        }
         handle_event(ev);
     }
     close(fd);
 
 }
 
-void ShuttleThread::handle_event(EV ev) {
+void ShuttleThread::handle_event(EV ev)
+{
     switch (ev.type) {
     case KEY :
         key(ev.code, ev.value);
@@ -118,7 +121,8 @@ void ShuttleThread::handle_event(EV ev) {
     }
 }
 
-void ShuttleThread::key(unsigned short code, unsigned int value) {
+void ShuttleThread::key(unsigned short code, unsigned int value)
+{
     if (value == 0) {
         // Button release (ignored)
         return;
@@ -135,7 +139,8 @@ void ShuttleThread::key(unsigned short code, unsigned int value) {
 
 }
 
-void ShuttleThread::shuttle(int value) {
+void ShuttleThread::shuttle(int value)
+{
     //gettimeofday( &last_shuttle, 0 );
     //need_synthetic_shuttle = value != 0;
 
@@ -176,7 +181,8 @@ void ShuttleThread::shuttle(int value) {
 
 }
 
-void ShuttleThread::jog(unsigned int value) {
+void ShuttleThread::jog(unsigned int value)
+{
     // We should generate a synthetic event for the shuttle going
     // to the home position if we have not seen one recently
     //check_synthetic();
@@ -191,7 +197,8 @@ void ShuttleThread::jog(unsigned int value) {
 }
 
 
-void ShuttleThread::jogshuttle(unsigned short code, unsigned int value) {
+void ShuttleThread::jogshuttle(unsigned short code, unsigned int value)
+{
     switch (code) {
     case JOG :
         jog(value);
@@ -203,25 +210,30 @@ void ShuttleThread::jogshuttle(unsigned short code, unsigned int value) {
 }
 
 
-JogShuttle::JogShuttle(QString device, QObject *parent): QObject(parent) {
+JogShuttle::JogShuttle(QString device, QObject *parent): QObject(parent)
+{
     initDevice(device);
 }
 
-JogShuttle::~JogShuttle() {
+JogShuttle::~JogShuttle()
+{
     if (m_shuttleProcess.isRunning()) m_shuttleProcess.exit();
 }
 
-void JogShuttle::initDevice(QString device) {
+void JogShuttle::initDevice(QString device)
+{
     if (m_shuttleProcess.isRunning()) return;
     m_shuttleProcess.init(this, device);
     m_shuttleProcess.start(QThread::LowestPriority);
 }
 
-void JogShuttle::stopDevice() {
+void JogShuttle::stopDevice()
+{
     if (m_shuttleProcess.isRunning()) m_shuttleProcess.stop_me = true;
 }
 
-void JogShuttle::customEvent(QEvent* e) {
+void JogShuttle::customEvent(QEvent* e)
+{
     switch (e->type()) {
     case JOG_BACK1:
         emit rewind1();