]> git.sesse.net Git - kdenlive/blob - src/jogshuttle.h
jogshuttle: use call by reference
[kdenlive] / src / jogshuttle.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *   Based on code by Arendt David <admin@prnet.org>                       *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
19  ***************************************************************************/
20
21 #ifndef SHUTTLE_H
22 #define SHUTTLE_H
23
24 #include <QThread>
25 #include <QObject>
26 #include <QMap>
27
28 #include <linux/input.h>
29 #include <sys/time.h>
30 #include <media_ctrl/mediactrl.h>
31
32 typedef struct input_event EV;
33
34 class ShuttleThread : public QThread
35 {
36
37 public:
38     virtual void run();
39     void init(QObject *parent, const QString &device);
40     QObject *m_parent;
41     int shuttlevalue;
42     int shuttlecounter;
43     unsigned short jogvalue;
44     bool isWorking();
45     volatile bool stop_me;
46     QString m_device;
47
48 private:
49     bool m_isWorking;
50     void handle_event(const struct media_ctrl_event& ev);
51     void jog(const struct media_ctrl_event& ev);
52     void shuttle(const struct media_ctrl_event& ev);
53     void key(const struct media_ctrl_event& ev);
54
55 #ifdef USE_DEPRECATED
56     void handle_event(EV ev);
57     void jog(unsigned int value);
58     void shuttle(int value);
59     void key(unsigned short code, unsigned int value);
60 #endif
61 };
62
63 typedef QMap<QString, QString> DeviceMap;
64 typedef QMap<QString, QString>::iterator DeviceMapIter;
65
66 class JogShuttle: public QObject
67 {
68     Q_OBJECT
69 public:
70     explicit JogShuttle(const QString &device, QObject * parent = 0);
71     ~JogShuttle();
72     void stopDevice();
73     void initDevice(const QString &device);
74     static QString canonicalDevice(const QString& device);
75     static DeviceMap enumerateDevices(const QString& devPath);
76     static int keysCount(const QString& devPath);
77
78 protected:
79     virtual void customEvent(QEvent * e);
80
81 private:
82     ShuttleThread m_shuttleProcess;
83
84 signals:
85     void jogBack();
86     void jogForward();
87     void shuttlePos(int);
88     void button(int);
89 };
90
91 #endif