#define JOG_STOP 10009
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <QFile>
-#include <QTextStream>
#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"
-/*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;
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);
}
***************************************************************************/
#include <QDir>
+#include <QTimer>
#include <KStandardDirs>
#include <KDebug>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/input.h>
+
#include "profilesdialog.h"
#include "kdenlivesettings.h"
#include "kdenlivesettingsdialog.h"
QWidget *p5 = new QWidget;
m_configShuttle.setupUi(p5);
+ connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
+ connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
+ slotCheckShuttle(KdenliveSettings::enableshuttle());
page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
QStringList actions;
m_configMisc.profiles_list->addItems(profilesNames);
m_defaulfProfile = ProfilesDialog::getSettingsFromFile(KdenliveSettings::default_profile()).value("description");
if (profilesNames.contains(m_defaulfProfile)) m_configMisc.profiles_list->setCurrentItem(m_defaulfProfile);
-
slotUpdateDisplay();
connect(m_configMisc.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
}
KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
+void KdenliveSettingsDialog::slotCheckShuttle(int state) {
+ 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 OFR: " << filename;
+
+ char name[256] = "unknown";
+ fd = ::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);
+ }
+ if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
+ }
+}
+
+void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix) {
+ QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
+ //KdenliveSettings::setShuttledevice(device);
+ m_configShuttle.kcfg_shuttledevice->setText(device);
+}
+
void KdenliveSettingsDialog::rebuildVideo4Commands() {
QString captureCommand;
if (!m_configCapture.kcfg_video4adevice->text().isEmpty()) captureCommand = "-f " + m_configCapture.kcfg_video4aformat->text() + " -i " + m_configCapture.kcfg_video4adevice->text();
<rect>
<x>0</x>
<y>0</y>
- <width>299</width>
- <height>260</height>
+ <width>325</width>
+ <height>285</height>
</rect>
</property>
- <layout class="QGridLayout" name="gridLayout" >
- <item row="0" column="0" colspan="2" >
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <item row="0" column="0" >
<widget class="QCheckBox" name="kcfg_enableshuttle" >
<property name="text" >
<string>Enable Jog Shuttle device</string>
</widget>
</item>
<item row="1" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Device path</string>
+ <widget class="QGroupBox" name="config_group" >
+ <property name="enabled" >
+ <bool>false</bool>
</property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="KLineEdit" name="kcfg_shuttledevice" >
- <property name="text" >
- <string>/dev/input/event1</string>
+ <property name="title" >
+ <string>Device configuration</string>
</property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Device</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="KComboBox" name="shuttledevicelist" />
+ </item>
+ <item row="0" column="2" >
+ <widget class="KLineEdit" name="kcfg_shuttledevice" >
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Button 1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2" >
+ <widget class="KComboBox" name="kcfg_shuttle1" />
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Button 2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2" >
+ <widget class="KComboBox" name="kcfg_shuttle2" />
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Button 3</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2" >
+ <widget class="KComboBox" name="kcfg_shuttle3" />
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_7" >
+ <property name="text" >
+ <string>Button 4</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" colspan="2" >
+ <widget class="KComboBox" name="kcfg_shuttle4" />
+ </item>
+ <item row="5" column="0" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>Button 5</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1" colspan="2" >
+ <widget class="KComboBox" name="kcfg_shuttle5" />
+ </item>
+ </layout>
</widget>
</item>
<item row="2" column="0" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Button 1</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="KComboBox" name="kcfg_shuttle1" />
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="label_4" >
- <property name="text" >
- <string>Button 2</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="KComboBox" name="kcfg_shuttle2" />
- </item>
- <item row="4" column="0" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>Button 3</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1" >
- <widget class="KComboBox" name="kcfg_shuttle3" />
- </item>
- <item row="5" column="0" >
- <widget class="QLabel" name="label_7" >
- <property name="text" >
- <string>Button 4</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1" >
- <widget class="KComboBox" name="kcfg_shuttle4" />
- </item>
- <item row="6" column="0" >
- <widget class="QLabel" name="label_5" >
- <property name="text" >
- <string>Button 5</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1" >
- <widget class="KComboBox" name="kcfg_shuttle5" />
- </item>
- <item row="7" column="1" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>