1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 | #ifndef QVFBPROTOCOL_H
|
---|
42 | #define QVFBPROTOCOL_H
|
---|
43 |
|
---|
44 | #include <QImage>
|
---|
45 | #include <QVector>
|
---|
46 | #include <QColor>
|
---|
47 |
|
---|
48 | QT_BEGIN_NAMESPACE
|
---|
49 |
|
---|
50 | class QVFbKeyProtocol;
|
---|
51 | class QVFbMouseProtocol;
|
---|
52 | class QVFbViewProtocol : public QObject
|
---|
53 | {
|
---|
54 | Q_OBJECT
|
---|
55 | public:
|
---|
56 | QVFbViewProtocol(int display_id, QObject *parent = 0);
|
---|
57 |
|
---|
58 | virtual ~QVFbViewProtocol();
|
---|
59 |
|
---|
60 | int id() const { return mDisplayId; }
|
---|
61 |
|
---|
62 | void sendKeyboardData(QString unicode, int keycode,
|
---|
63 | int modifiers, bool press, bool repeat);
|
---|
64 | void sendMouseData(const QPoint &pos, int buttons, int wheel);
|
---|
65 |
|
---|
66 | virtual int width() const = 0;
|
---|
67 | virtual int height() const = 0;
|
---|
68 | virtual int depth() const = 0;
|
---|
69 | virtual int linestep() const = 0;
|
---|
70 | virtual int numcols() const = 0;
|
---|
71 | virtual QVector<QRgb> clut() const = 0;
|
---|
72 | virtual unsigned char *data() const = 0;
|
---|
73 | virtual int brightness() const = 0;
|
---|
74 |
|
---|
75 | virtual void setRate(int) {}
|
---|
76 | public slots:
|
---|
77 | virtual void flushChanges();
|
---|
78 |
|
---|
79 | signals:
|
---|
80 | void displayDataChanged(const QRect &);
|
---|
81 | void displayEmbedRequested(WId windowId);
|
---|
82 |
|
---|
83 | protected:
|
---|
84 | virtual QVFbKeyProtocol *keyHandler() const = 0;
|
---|
85 | virtual QVFbMouseProtocol *mouseHandler() const = 0;
|
---|
86 |
|
---|
87 | private:
|
---|
88 | int mDisplayId;
|
---|
89 | };
|
---|
90 |
|
---|
91 | class QVFbKeyProtocol
|
---|
92 | {
|
---|
93 | public:
|
---|
94 | QVFbKeyProtocol(int display_id) : mDisplayId(display_id) {}
|
---|
95 | virtual ~QVFbKeyProtocol() {}
|
---|
96 |
|
---|
97 | int id() const { return mDisplayId; }
|
---|
98 |
|
---|
99 | virtual void sendKeyboardData(QString unicode, int keycode,
|
---|
100 | int modifiers, bool press, bool repeat) = 0;
|
---|
101 |
|
---|
102 | private:
|
---|
103 | int mDisplayId;
|
---|
104 | };
|
---|
105 |
|
---|
106 | class QVFbMouseProtocol
|
---|
107 | {
|
---|
108 | public:
|
---|
109 | QVFbMouseProtocol(int display_id) : mDisplayId(display_id) {}
|
---|
110 | virtual ~QVFbMouseProtocol() {}
|
---|
111 |
|
---|
112 | int id() const { return mDisplayId; }
|
---|
113 |
|
---|
114 | virtual void sendMouseData(const QPoint &pos, int buttons, int wheel) = 0;
|
---|
115 |
|
---|
116 | private:
|
---|
117 | int mDisplayId;
|
---|
118 | };
|
---|
119 |
|
---|
120 | /* since there is very little variation in input protocols defaults are
|
---|
121 | provided */
|
---|
122 |
|
---|
123 | class QVFbKeyPipeProtocol : public QVFbKeyProtocol
|
---|
124 | {
|
---|
125 | public:
|
---|
126 | QVFbKeyPipeProtocol(int display_id);
|
---|
127 | ~QVFbKeyPipeProtocol();
|
---|
128 |
|
---|
129 | void sendKeyboardData(QString unicode, int keycode,
|
---|
130 | int modifiers, bool press, bool repeat);
|
---|
131 |
|
---|
132 | QString pipeName() const { return fileName; }
|
---|
133 | private:
|
---|
134 | int fd;
|
---|
135 | QString fileName;
|
---|
136 | };
|
---|
137 |
|
---|
138 | class QVFbMousePipe: public QVFbMouseProtocol
|
---|
139 | {
|
---|
140 | public:
|
---|
141 | QVFbMousePipe(int display_id);
|
---|
142 | ~QVFbMousePipe();
|
---|
143 |
|
---|
144 | void sendMouseData(const QPoint &pos, int buttons, int wheel);
|
---|
145 |
|
---|
146 | QString pipeName() const { return fileName; }
|
---|
147 | protected:
|
---|
148 | int fd;
|
---|
149 | QString fileName;
|
---|
150 | };
|
---|
151 |
|
---|
152 | class QTimer;
|
---|
153 | class QVFbMouseLinuxTP : public QObject, public QVFbMousePipe
|
---|
154 | {
|
---|
155 | Q_OBJECT
|
---|
156 | public:
|
---|
157 | QVFbMouseLinuxTP(int display_id);
|
---|
158 | ~QVFbMouseLinuxTP();
|
---|
159 |
|
---|
160 | void sendMouseData(const QPoint &pos, int buttons, int wheel);
|
---|
161 |
|
---|
162 | protected slots:
|
---|
163 | void repeatLastPress();
|
---|
164 |
|
---|
165 | protected:
|
---|
166 | void writeToPipe(const QPoint &pos, ushort pressure);
|
---|
167 | QPoint lastPos;
|
---|
168 | QTimer *repeater;
|
---|
169 | };
|
---|
170 |
|
---|
171 | QT_END_NAMESPACE
|
---|
172 |
|
---|
173 | #endif
|
---|