author | František Kučera <franta-hg@frantovo.cz> |
Thu, 24 Oct 2019 21:49:24 +0200 | |
branch | v_0 |
changeset 11 | aaa89fe98b63 |
parent 9 | d3716f03efcd |
permissions | -rw-r--r-- |
4 | 1 |
/** |
2 |
* Spacenav Demo Qt |
|
3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
|
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 |
|
11
aaa89fe98b63
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
4 | 8 |
* |
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
#pragma once |
|
18 |
||
19 |
#include <iostream> |
|
20 |
||
21 |
/** |
|
22 |
* This wrapper separates spnav.h and X headers from the rest of the application. |
|
23 |
* Some definitions like Status would collide with Qt if mixed in a single file with QObjects and processed by MOC. |
|
24 |
* |
|
25 |
* This wrapper also abstracts from the connection type – tries AF_UNIX socket first and then X11. |
|
26 |
*/ |
|
27 |
class SpacenavWrapper { |
|
28 |
public: |
|
29 |
||
30 |
class Event { |
|
6
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
31 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
32 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
33 |
enum class Type { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
34 |
MOTION, |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
35 |
BUTTON |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
36 |
}; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
37 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
38 |
class MotionEvent { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
39 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
40 |
int x; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
41 |
int y; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
42 |
int z; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
43 |
int rx; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
44 |
int ry; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
45 |
int rz; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
46 |
int type; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
47 |
unsigned int period; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
48 |
}; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
49 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
50 |
class ButtonEvent { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
51 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
52 |
int number; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
53 |
bool pressed; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
54 |
}; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
55 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
56 |
Type type; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
57 |
MotionEvent motion; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
58 |
ButtonEvent button; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
59 |
|
4 | 60 |
}; |
61 |
||
9
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
62 |
enum class ConnectionStatus { |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
63 |
NONE, |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
64 |
DOMAIN_SOCKET, |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
65 |
X11 |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
66 |
}; |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
67 |
|
4 | 68 |
SpacenavWrapper(); |
69 |
||
70 |
virtual ~SpacenavWrapper(); |
|
71 |
||
9
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
72 |
ConnectionStatus getConnectionStatus(); |
4 | 73 |
Event waitEvent(); |
74 |
||
9
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
75 |
private: |
d3716f03efcd
display status – connection type (domain socket or X11)
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
76 |
ConnectionStatus connectionStatus; |
4 | 77 |
}; |