author | František Kučera <franta-hg@frantovo.cz> |
Thu, 07 Mar 2019 16:20:51 +0100 | |
branch | v_0 |
changeset 6 | 49560660d230 |
parent 4 | 1383ad1c4f57 |
child 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 |
|
7 |
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
#pragma once |
|
19 |
||
20 |
#include <iostream> |
|
21 |
||
22 |
/** |
|
23 |
* This wrapper separates spnav.h and X headers from the rest of the application. |
|
24 |
* Some definitions like Status would collide with Qt if mixed in a single file with QObjects and processed by MOC. |
|
25 |
* |
|
26 |
* This wrapper also abstracts from the connection type – tries AF_UNIX socket first and then X11. |
|
27 |
*/ |
|
28 |
class SpacenavWrapper { |
|
29 |
public: |
|
30 |
||
31 |
class Event { |
|
6
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
32 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
33 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
34 |
enum class Type { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
35 |
MOTION, |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
36 |
BUTTON |
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 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
39 |
class MotionEvent { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
40 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
41 |
int x; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
42 |
int y; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
43 |
int z; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
44 |
int rx; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
45 |
int ry; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
46 |
int rz; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
47 |
int type; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
48 |
unsigned int period; |
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 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
51 |
class ButtonEvent { |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
52 |
public: |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
53 |
int number; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
54 |
bool pressed; |
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 |
|
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
57 |
Type type; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
58 |
MotionEvent motion; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
59 |
ButtonEvent button; |
49560660d230
emit MotionEvent and ButtonEvent + display button status
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
60 |
|
4 | 61 |
}; |
62 |
||
63 |
SpacenavWrapper(); |
|
64 |
||
65 |
virtual ~SpacenavWrapper(); |
|
66 |
||
67 |
Event waitEvent(); |
|
68 |
||
69 |
||
70 |
}; |