Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
MotionController.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: MotionController.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Abstract MotionController class (hides details of Joystick, Keyboard, etc.)
13
*/
14
15
#ifndef MoCon_h
16
#define MoCon_h
17
18
// +--------------------------------------------------------------------+
19
20
struct
KeyMapEntry
21
{
22
static
const
char
*
TYPENAME
() {
return
"KeyMapEntry"
; }
23
24
KeyMapEntry
() :
act
(0),
key
(0),
alt
(0),
joy
(0) { }
25
KeyMapEntry
(
int
a,
int
k,
int
s=0,
int
j=0) :
act
(a),
key
(k),
alt
(s),
joy
(j) { }
26
27
int
operator==
(
const
KeyMapEntry
& k)
const
{
return
act
==k.
act
&&
key
==k.
key
&&
alt
==k.
alt
&&
joy
==k.
joy
; }
28
int
operator!=
(
const
KeyMapEntry
& k)
const
{
return
!(*
this
==k); }
29
30
int
act
;
31
int
key
;
32
int
alt
;
33
int
joy
;
34
};
35
36
// +--------------------------------------------------------------------+
37
38
const
int
KEY_MAP_SIZE
= 256;
39
const
int
KEY_BASE_SIZE
= 64;
40
const
int
KEY_USER_SIZE
=
KEY_MAP_SIZE
-
KEY_BASE_SIZE
;
41
42
const
int
KEY_MAP_BASE
= 0;
43
const
int
KEY_MAP_END
=
KEY_MAP_BASE
+
KEY_BASE_SIZE
- 1;
44
45
const
int
KEY_USER_BASE
=
KEY_MAP_END
+ 1;
46
const
int
KEY_USER_END
=
KEY_USER_BASE
+
KEY_USER_SIZE
- 1;
47
48
const
int
KEY_MAP_FIRST
=
KEY_MAP_BASE
;
49
const
int
KEY_MAP_LAST
=
KEY_MAP_BASE
+
KEY_MAP_SIZE
- 1;
50
51
// MAP NAMES:
52
53
const
int
KEY_PLUS_X
= 1;
54
const
int
KEY_MINUS_X
= 2;
55
const
int
KEY_PLUS_Y
= 3;
56
const
int
KEY_MINUS_Y
= 4;
57
const
int
KEY_PLUS_Z
= 5;
58
const
int
KEY_MINUS_Z
= 6;
59
60
const
int
KEY_PITCH_UP
= 7;
61
const
int
KEY_PITCH_DOWN
= 8;
62
const
int
KEY_YAW_LEFT
= 9;
63
const
int
KEY_YAW_RIGHT
= 10;
64
const
int
KEY_ROLL_LEFT
= 11;
65
const
int
KEY_ROLL_RIGHT
= 12;
66
const
int
KEY_CENTER
= 13;
67
const
int
KEY_ROLL_ENABLE
= 14;
68
69
const
int
KEY_ACTION_0
= 15;
70
const
int
KEY_ACTION_1
= 16;
71
const
int
KEY_ACTION_2
= 17;
72
const
int
KEY_ACTION_3
= 18;
73
74
const
int
KEY_CONTROL_MODEL
= 19;
75
const
int
KEY_MOUSE_SELECT
= 20;
76
const
int
KEY_MOUSE_SENSE
= 21;
77
const
int
KEY_MOUSE_SWAP
= 22;
78
const
int
KEY_MOUSE_INVERT
= 23;
79
const
int
KEY_MOUSE_ACTIVE
= 24;
80
81
const
int
KEY_JOY_SELECT
= 25;
82
const
int
KEY_JOY_THROTTLE
= 26;
83
const
int
KEY_JOY_RUDDER
= 27;
84
const
int
KEY_JOY_SENSE
= 28;
85
const
int
KEY_JOY_DEAD_ZONE
= 29;
86
const
int
KEY_JOY_SWAP
= 30;
87
88
const
int
KEY_AXIS_YAW
= 32;
89
const
int
KEY_AXIS_PITCH
= 33;
90
const
int
KEY_AXIS_ROLL
= 34;
91
const
int
KEY_AXIS_THROTTLE
= 35;
92
93
const
int
KEY_AXIS_YAW_INVERT
= 38;
94
const
int
KEY_AXIS_PITCH_INVERT
= 39;
95
const
int
KEY_AXIS_ROLL_INVERT
= 40;
96
const
int
KEY_AXIS_THROTTLE_INVERT
= 41;
97
98
99
// CONTROL VALUES:
100
101
// joystick buttons and switches must use
102
// ids greater than 255 so they don't interfere
103
// with extended ascii numbers for keyboard keys
104
105
const
int
KEY_JOY_AXIS_X
= 0x1A0;
106
const
int
KEY_JOY_AXIS_Y
= 0x1A1;
107
const
int
KEY_JOY_AXIS_Z
= 0x1A2;
108
const
int
KEY_JOY_AXIS_RX
= 0x1A3;
109
const
int
KEY_JOY_AXIS_RY
= 0x1A4;
110
const
int
KEY_JOY_AXIS_RZ
= 0x1A5;
111
const
int
KEY_JOY_AXIS_S0
= 0x1A6;
112
const
int
KEY_JOY_AXIS_S1
= 0x1A7;
113
114
const
int
KEY_JOY_1
= 0x1C1;
115
const
int
KEY_JOY_2
= 0x1C2;
116
const
int
KEY_JOY_3
= 0x1C3;
117
const
int
KEY_JOY_4
= 0x1C4;
118
const
int
KEY_JOY_5
= 0x1C5;
119
const
int
KEY_JOY_6
= 0x1C6;
120
const
int
KEY_JOY_7
= 0x1C7;
121
const
int
KEY_JOY_8
= 0x1C8;
122
const
int
KEY_JOY_9
= 0x1C9;
123
const
int
KEY_JOY_10
= 0x1CA;
124
const
int
KEY_JOY_11
= 0x1CB;
125
const
int
KEY_JOY_12
= 0x1CC;
126
const
int
KEY_JOY_13
= 0x1CD;
127
const
int
KEY_JOY_14
= 0x1CE;
128
const
int
KEY_JOY_15
= 0x1CF;
129
const
int
KEY_JOY_16
= 0x1D0;
130
131
const
int
KEY_JOY_32
= 0x1E0;
132
133
const
int
KEY_POV_0_UP
= 0x1F0;
134
const
int
KEY_POV_0_DOWN
= 0x1F1;
135
const
int
KEY_POV_0_LEFT
= 0x1F2;
136
const
int
KEY_POV_0_RIGHT
= 0x1F3;
137
138
const
int
KEY_POV_1_UP
= 0x1F4;
139
const
int
KEY_POV_1_DOWN
= 0x1F5;
140
const
int
KEY_POV_1_LEFT
= 0x1F6;
141
const
int
KEY_POV_1_RIGHT
= 0x1F7;
142
143
const
int
KEY_POV_2_UP
= 0x1F8;
144
const
int
KEY_POV_2_DOWN
= 0x1F9;
145
const
int
KEY_POV_2_LEFT
= 0x1FA;
146
const
int
KEY_POV_2_RIGHT
= 0x1FB;
147
148
const
int
KEY_POV_3_UP
= 0x1FC;
149
const
int
KEY_POV_3_DOWN
= 0x1FD;
150
const
int
KEY_POV_3_LEFT
= 0x1FE;
151
const
int
KEY_POV_3_RIGHT
= 0x1FF;
152
153
// +--------------------------------------------------------------------+
154
155
class
MotionController
156
{
157
public
:
158
static
const
char
*
TYPENAME
() {
return
"MotionController"
; }
159
160
MotionController
()
161
:
status
(
StatusOK
),
sensitivity
(1),
dead_zone
(0),
162
swapped
(0),
inverted
(0),
rudder
(0),
throttle
(0),
select
(0) { }
163
164
virtual
~MotionController
() { }
165
166
enum
StatusValue
{
StatusOK
,
StatusErr
,
StatusBadParm
};
167
enum
ActionValue
{
MaxActions
= 32 };
168
169
StatusValue
Status
()
const
{
return
status
; }
170
int
Sensitivity
()
const
{
return
sensitivity
; }
171
int
DeadZone
()
const
{
return
dead_zone
; }
172
int
Swapped
()
const
{
return
swapped
; }
173
int
Inverted
()
const
{
return
inverted
; }
174
int
RudderEnabled
()
const
{
return
rudder
; }
175
int
ThrottleEnabled
()
const
{
return
throttle
; }
176
int
Selector
()
const
{
return
select
; }
177
178
179
// setup:
180
virtual
void
SetSensitivity
(
int
sense,
int
dead)
181
{
182
if
(sense > 0)
sensitivity
= sense;
183
if
(dead > 0)
dead_zone
= dead;
184
}
185
186
virtual
void
SetSelector
(
int
sel) {
select
= sel; }
187
virtual
void
SetRudderEnabled
(
int
rud) {
rudder
= rud; }
188
virtual
void
SetThrottleEnabled
(
int
t) {
throttle
= t; }
189
190
virtual
void
SwapYawRoll
(
int
swap) {
swapped
= swap; }
191
virtual
int
GetSwapYawRoll
() {
return
swapped
; }
192
virtual
void
InvertPitch
(
int
inv) {
inverted
= inv; }
193
virtual
int
GetInverted
() {
return
inverted
; }
194
195
virtual
void
MapKeys
(
KeyMapEntry
* mapping,
int
nkeys) { }
196
197
// sample the physical device
198
virtual
void
Acquire
() { }
199
200
// translations
201
virtual
double
X
() {
return
0; }
202
virtual
double
Y
() {
return
0; }
203
virtual
double
Z
() {
return
0; }
204
205
// rotations
206
virtual
double
Pitch
() {
return
0; }
207
virtual
double
Roll
() {
return
0; }
208
virtual
double
Yaw
() {
return
0; }
209
virtual
int
Center
() {
return
0; }
210
211
// throttle
212
virtual
double
Throttle
() {
return
0; }
213
virtual
void
SetThrottle
(
double
t) { }
214
215
// actions
216
virtual
int
Action
(
int
n) {
return
0; }
217
virtual
int
ActionMap
(
int
n) {
return
0; }
218
219
protected
:
220
StatusValue
status
;
221
int
sensitivity
;
222
int
dead_zone
;
223
int
swapped
;
224
int
inverted
;
225
int
rudder
;
226
int
throttle
;
227
int
select
;
228
};
229
230
#endif MoCon_h
231
nGenEx
MotionController.h
Generated on Thu May 31 2012 16:30:56 for Starshatter_Open by
1.8.1