]> git.sesse.net Git - kdenlive/commitdiff
jogshuttle: add support for shuttles on newer systems - part1
authorEd Rogalsky <ed.rogalsky@googlemail.com>
Sun, 23 Feb 2014 20:09:29 +0000 (21:09 +0100)
committerEd Rogalsky <ed.rogalsky@googlemail.com>
Sun, 23 Feb 2014 20:09:29 +0000 (21:09 +0100)
src/jogshuttle.cpp
src/jogshuttle.h
src/kdenlivesettingsdialog.cpp
src/mainwindow.cpp

index b6095afd823d4df4b37fcc5c17361500049a9516..44517d7745a839db137310c716bb256b90d3c618 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <QApplication>
 #include <QEvent>
+#include <QDir>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -343,6 +344,12 @@ void JogShuttle::customEvent(QEvent* e)
     emit button(e->type() - KEY_EVENT_OFFSET);
 }
 
+QString JogShuttle::enumerateDevice(const QString &device)
+{
+    QDir canonDir(device);
+    //return QDir::canonicalPath(device);
+    return canonDir.canonicalPath();
+}
 
 
 // #include "jogshuttle.moc"
index d0bb786753e4984091d60f3153e5f3674957c46a..1a337868fd2e7ab304da133d96e1dcecbedd41c7 100644 (file)
@@ -54,11 +54,13 @@ private:
 
 class JogShuttle: public QObject
 {
-Q_OBJECT public:
+    Q_OBJECT
+public:
     explicit JogShuttle(const QString &device, QObject * parent = 0);
     ~JogShuttle();
     void stopDevice();
     void initDevice(const QString &device);
+    static QString enumerateDevice(const QString &device);
 
 protected:
     virtual void customEvent(QEvent * e);
index f8eb77f24445a6353b5353410dca099d8b2ebec8..42e5813338897ecd55a89a2c52e288507b8b06d3 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
+
 #ifdef USE_JOGSHUTTLE
-#include "jogaction.h"
-#include "jogshuttleconfig.h"
-#include <linux/input.h>
+  #include "jogaction.h"
+  #include "jogshuttleconfig.h"
+  #include <linux/input.h>
 #endif
 
 
@@ -523,21 +524,42 @@ void KdenliveSettingsDialog::slotCheckShuttle(int state)
 #ifdef USE_JOGSHUTTLE
     m_configShuttle.config_group->setEnabled(state);
     if (m_configShuttle.shuttledevicelist->count() == 0) {
-        // parse devices
-        QString baseName = "/dev/input/event";
-        int fd;
-        for (int i = 0; i < 30; ++i) {
-            QString filename = baseName + QString::number(i);
-            kDebug() << "/// CHECKING device: " << filename;
-
-            char name[256] = "unknown";
-            fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
-            if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
-                m_configShuttle.shuttledevicelist->addItem(name, filename);
+        QString devDirStr = "/dev/input/by-id/";
+        QDir devDir(devDirStr);
+        if (devDir.exists()) {
+            QStringList fileList = devDir.entryList(QDir::Files);
+            foreach (const QString &fileName, fileList) {
+                QString devFullPath(devDirStr + fileName);
+                QString fileLink = JogShuttle::enumerateDevice(devFullPath);
+                kDebug() << QString(" [%1] ").arg(fileName);
+                kDebug() << QString(" [%1] ").arg(fileLink);
+                char name[256] = "unknown";
+                int fd = KDE_open((char*)fileLink.toUtf8().data(), O_RDONLY);
+                if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
+                    m_configShuttle.shuttledevicelist->addItem(name, devFullPath);
+                }
+                ::close(fd);
+            }
+        } else {
+            // parse devices
+            QString baseName = "/dev/input/event";
+            int fd;
+            for (int i = 0; i < 30; ++i) {
+                QString filename = baseName + QString::number(i);
+                kDebug() << "/// CHECKING device: " << filename;
+
+                char name[256] = "unknown";
+                fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
+                if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
+                    m_configShuttle.shuttledevicelist->addItem(name, filename);
+                }
+                ::close(fd);
             }
-            ::close(fd);
         }
-        if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
+
+        if (KdenliveSettings::shuttledevice().isEmpty()) {
+            QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
+        }
     }
 #endif /* USE_JOGSHUTTLE */
 }
index 455adaa19fc430b683f35e1d8f62cc43120e6d18..cee87ec7fec5162114d9734570aedd18af473a6f 100644 (file)
@@ -882,7 +882,7 @@ void MainWindow::activateShuttleDevice()
     m_jogProcess = NULL;
     if (KdenliveSettings::enableshuttle() == false) return;
 
-    m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
+    m_jogProcess = new JogShuttle(JogShuttle::enumerateDevice(KdenliveSettings::shuttledevice()));
     m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
 
     connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));