***************************************************************************/
+#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 <kde_file.h>
-
-#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;
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 = KDE_open((char *) m_device.toUtf8().data(), O_RDONLY);
}
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);
}
}
-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;
}
-void ShuttleThread::shuttle(int value) {
+void ShuttleThread::shuttle(int value)
+{
//gettimeofday( &last_shuttle, 0 );
//need_synthetic_shuttle = value != 0;
}
-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();
}
-void ShuttleThread::jogshuttle(unsigned short code, unsigned int value) {
+void ShuttleThread::jogshuttle(unsigned short code, unsigned int value)
+{
switch (code) {
case JOG :
jog(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();