ruby-ois 0.0.1-x86-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +56 -0
- data/bindings/ois/interface/OIS_Effect.i +8 -0
- data/bindings/ois/interface/OIS_Event.i +8 -0
- data/bindings/ois/interface/OIS_Exception.i +8 -0
- data/bindings/ois/interface/OIS_FactoryCreator.i +8 -0
- data/bindings/ois/interface/OIS_ForceFeedback.i +8 -0
- data/bindings/ois/interface/OIS_InputManager.i +20 -0
- data/bindings/ois/interface/OIS_Interface.i +8 -0
- data/bindings/ois/interface/OIS_JoyStick.i +8 -0
- data/bindings/ois/interface/OIS_Keyboard.i +15 -0
- data/bindings/ois/interface/OIS_Mouse.i +10 -0
- data/bindings/ois/interface/OIS_Object.i +22 -0
- data/bindings/ois/interface/OIS_Prereqs.i +20 -0
- data/bindings/ois/interface/Rakefile +19 -0
- data/bindings/ois/interface/ois.i +3 -0
- data/bindings/ois/interface/ois_all.i +23 -0
- data/bindings/ois/interface/ois_wrap.cpp +19311 -0
- data/bindings/ois/interface/ois_wrap.h +40 -0
- data/bindings/ois/interface/ois_wrap.o +0 -0
- data/deps/include/OIS/OIS.h +41 -0
- data/deps/include/OIS/OISConfig.h +75 -0
- data/deps/include/OIS/OISEffect.h +278 -0
- data/deps/include/OIS/OISEvents.h +43 -0
- data/deps/include/OIS/OISException.h +78 -0
- data/deps/include/OIS/OISFactoryCreator.h +81 -0
- data/deps/include/OIS/OISForceFeedback.h +120 -0
- data/deps/include/OIS/OISInputManager.h +205 -0
- data/deps/include/OIS/OISInterface.h +47 -0
- data/deps/include/OIS/OISJoyStick.h +228 -0
- data/deps/include/OIS/OISKeyboard.h +312 -0
- data/deps/include/OIS/OISMouse.h +138 -0
- data/deps/include/OIS/OISMultiTouch.h +169 -0
- data/deps/include/OIS/OISObject.h +95 -0
- data/deps/include/OIS/OISPrereqs.h +226 -0
- data/deps/lib/libOIS-1.3.0.so +0 -0
- data/deps/lib/libOIS.so +0 -0
- data/lib/ois.so +0 -0
- data/lib/ruby-ois.rb +30 -0
- data/lib/ruby-ois/version.rb +5 -0
- data/ruby-ois.gemspec +30 -0
- metadata +88 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
/*
|
2
|
+
The zlib/libpng License
|
3
|
+
|
4
|
+
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
|
5
|
+
|
6
|
+
This software is provided 'as-is', without any express or implied warranty. In no event will
|
7
|
+
the authors be held liable for any damages arising from the use of this software.
|
8
|
+
|
9
|
+
Permission is granted to anyone to use this software for any purpose, including commercial
|
10
|
+
applications, and to alter it and redistribute it freely, subject to the following
|
11
|
+
restrictions:
|
12
|
+
|
13
|
+
1. The origin of this software must not be misrepresented; you must not claim that
|
14
|
+
you wrote the original software. If you use this software in a product,
|
15
|
+
an acknowledgment in the product documentation would be appreciated but is
|
16
|
+
not required.
|
17
|
+
|
18
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
19
|
+
misrepresented as being the original software.
|
20
|
+
|
21
|
+
3. This notice may not be removed or altered from any source distribution.
|
22
|
+
*/
|
23
|
+
#ifndef OIS_Interface_H
|
24
|
+
#define OIS_Interface_H
|
25
|
+
|
26
|
+
#include "OISPrereqs.h"
|
27
|
+
|
28
|
+
namespace OIS
|
29
|
+
{
|
30
|
+
/**
|
31
|
+
An Object's interface is a way to gain write access to devices which support
|
32
|
+
it. For example, force feedack.
|
33
|
+
*/
|
34
|
+
class _OISExport Interface
|
35
|
+
{
|
36
|
+
public:
|
37
|
+
virtual ~Interface() {};
|
38
|
+
|
39
|
+
//! Type of Interface
|
40
|
+
enum IType
|
41
|
+
{
|
42
|
+
ForceFeedback,
|
43
|
+
Reserved
|
44
|
+
};
|
45
|
+
};
|
46
|
+
}
|
47
|
+
#endif //OIS_Interface_H
|
@@ -0,0 +1,228 @@
|
|
1
|
+
/*
|
2
|
+
The zlib/libpng License
|
3
|
+
|
4
|
+
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
|
5
|
+
|
6
|
+
This software is provided 'as-is', without any express or implied warranty. In no event will
|
7
|
+
the authors be held liable for any damages arising from the use of this software.
|
8
|
+
|
9
|
+
Permission is granted to anyone to use this software for any purpose, including commercial
|
10
|
+
applications, and to alter it and redistribute it freely, subject to the following
|
11
|
+
restrictions:
|
12
|
+
|
13
|
+
1. The origin of this software must not be misrepresented; you must not claim that
|
14
|
+
you wrote the original software. If you use this software in a product,
|
15
|
+
an acknowledgment in the product documentation would be appreciated but is
|
16
|
+
not required.
|
17
|
+
|
18
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
19
|
+
misrepresented as being the original software.
|
20
|
+
|
21
|
+
3. This notice may not be removed or altered from any source distribution.
|
22
|
+
*/
|
23
|
+
#ifndef OIS_Joystick_H
|
24
|
+
#define OIS_Joystick_H
|
25
|
+
#include "OISObject.h"
|
26
|
+
#include "OISEvents.h"
|
27
|
+
|
28
|
+
namespace OIS
|
29
|
+
{
|
30
|
+
/** @remarks default sensitivity for vector3 component of joystick */
|
31
|
+
#define OIS_JOYSTICK_VECTOR3_DEFAULT 2.28f
|
32
|
+
|
33
|
+
//! POV / HAT Joystick component
|
34
|
+
class _OISExport Pov : public Component
|
35
|
+
{
|
36
|
+
public:
|
37
|
+
Pov() : Component(OIS_POV), direction(0) {}
|
38
|
+
|
39
|
+
static const int Centered = 0x00000000;
|
40
|
+
static const int North = 0x00000001;
|
41
|
+
static const int South = 0x00000010;
|
42
|
+
static const int East = 0x00000100;
|
43
|
+
static const int West = 0x00001000;
|
44
|
+
static const int NorthEast = 0x00000101;
|
45
|
+
static const int SouthEast = 0x00000110;
|
46
|
+
static const int NorthWest = 0x00001001;
|
47
|
+
static const int SouthWest = 0x00001010;
|
48
|
+
|
49
|
+
int direction;
|
50
|
+
};
|
51
|
+
|
52
|
+
//! A sliding axis - only used in Win32 Right Now
|
53
|
+
class _OISExport Slider : public Component
|
54
|
+
{
|
55
|
+
public:
|
56
|
+
Slider() : Component(OIS_Slider), abX(0), abY(0) {};
|
57
|
+
//! true if pushed, false otherwise
|
58
|
+
int abX, abY;
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
Represents the state of the joystick
|
63
|
+
All members are valid for both buffered and non buffered mode
|
64
|
+
Sticks with zero values are not present on the device
|
65
|
+
*/
|
66
|
+
class _OISExport JoyStickState
|
67
|
+
{
|
68
|
+
public:
|
69
|
+
//! Constructor
|
70
|
+
JoyStickState() { clear(); }
|
71
|
+
|
72
|
+
//! Represents all the buttons (uses a bitset)
|
73
|
+
std::vector<bool> mButtons;
|
74
|
+
|
75
|
+
//! Represents all the single axes on the device
|
76
|
+
std::vector<Axis> mAxes;
|
77
|
+
|
78
|
+
//! Represents the value of a POV. Maximum of 4
|
79
|
+
Pov mPOV[4];
|
80
|
+
|
81
|
+
//! Represent the max sliders
|
82
|
+
Slider mSliders[4];
|
83
|
+
|
84
|
+
//! Represents all Vector type controls the device exports
|
85
|
+
std::vector<Vector3> mVectors;
|
86
|
+
|
87
|
+
//! internal method to reset all variables to initial values
|
88
|
+
void clear()
|
89
|
+
{
|
90
|
+
for( std::vector<bool>::iterator i = mButtons.begin(), e = mButtons.end(); i != e; ++i )
|
91
|
+
{
|
92
|
+
(*i) = false;
|
93
|
+
}
|
94
|
+
|
95
|
+
for( std::vector<Axis>::iterator i = mAxes.begin(), e = mAxes.end(); i != e; ++i )
|
96
|
+
{
|
97
|
+
i->absOnly = true; //Currently, joysticks only report Absolute values
|
98
|
+
i->clear();
|
99
|
+
}
|
100
|
+
|
101
|
+
for( std::vector<Vector3>::iterator i = mVectors.begin(), e = mVectors.end(); i != e; ++i )
|
102
|
+
{
|
103
|
+
i->clear();
|
104
|
+
}
|
105
|
+
|
106
|
+
for( int i = 0; i < 4; ++i )
|
107
|
+
{
|
108
|
+
mPOV[i].direction = Pov::Centered;
|
109
|
+
mSliders[i].abX = mSliders[i].abY = 0;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
/** Specialised for joystick events */
|
115
|
+
class _OISExport JoyStickEvent : public EventArg
|
116
|
+
{
|
117
|
+
public:
|
118
|
+
JoyStickEvent( Object* obj, const JoyStickState &st ) : EventArg(obj), state(st) {}
|
119
|
+
virtual ~JoyStickEvent() {}
|
120
|
+
|
121
|
+
const JoyStickState &state;
|
122
|
+
};
|
123
|
+
|
124
|
+
/**
|
125
|
+
To recieve buffered joystick input, derive a class from this, and implement the
|
126
|
+
methods here. Then set the call back to your JoyStick instance with JoyStick::setEventCallback
|
127
|
+
Each JoyStick instance can use the same callback class, as a devID number will be provided
|
128
|
+
to differentiate between connected joysticks. Of course, each can have a seperate
|
129
|
+
callback instead.
|
130
|
+
*/
|
131
|
+
class _OISExport JoyStickListener
|
132
|
+
{
|
133
|
+
public:
|
134
|
+
virtual ~JoyStickListener() {}
|
135
|
+
/** @remarks Joystick button down event */
|
136
|
+
virtual bool buttonPressed( const JoyStickEvent &arg, int button ) = 0;
|
137
|
+
|
138
|
+
/** @remarks Joystick button up event */
|
139
|
+
virtual bool buttonReleased( const JoyStickEvent &arg, int button ) = 0;
|
140
|
+
|
141
|
+
/** @remarks Joystick axis moved event */
|
142
|
+
virtual bool axisMoved( const JoyStickEvent &arg, int axis ) = 0;
|
143
|
+
|
144
|
+
//-- Not so common control events, so are not required --//
|
145
|
+
//! Joystick Event, and sliderID
|
146
|
+
virtual bool sliderMoved( const JoyStickEvent &, int index) {return true;}
|
147
|
+
|
148
|
+
//! Joystick Event, and povID
|
149
|
+
virtual bool povMoved( const JoyStickEvent &arg, int index) {return true;}
|
150
|
+
|
151
|
+
//! Joystick Event, and Vector3ID
|
152
|
+
virtual bool vector3Moved( const JoyStickEvent &arg, int index) {return true;}
|
153
|
+
};
|
154
|
+
|
155
|
+
/**
|
156
|
+
Joystick base class. To be implemented by specific system (ie. DirectX joystick)
|
157
|
+
This class is useful as you remain OS independent using this common interface.
|
158
|
+
*/
|
159
|
+
class _OISExport JoyStick : public Object
|
160
|
+
{
|
161
|
+
public:
|
162
|
+
virtual ~JoyStick() {}
|
163
|
+
|
164
|
+
/**
|
165
|
+
@remarks
|
166
|
+
Returns the number of requested components
|
167
|
+
@param cType
|
168
|
+
The ComponentType you are interested in knowing about
|
169
|
+
*/
|
170
|
+
int getNumberOfComponents(ComponentType cType) const;
|
171
|
+
|
172
|
+
/**
|
173
|
+
@remarks
|
174
|
+
Sets a cutoff limit for changes in the Vector3 component for movement to
|
175
|
+
be ignored. Helps reduce much event traffic for frequent small/sensitive
|
176
|
+
changes
|
177
|
+
@param degrees
|
178
|
+
The degree under which Vector3 events should be discarded
|
179
|
+
*/
|
180
|
+
void setVector3Sensitivity(float degrees = OIS_JOYSTICK_VECTOR3_DEFAULT);
|
181
|
+
|
182
|
+
/**
|
183
|
+
@remarks
|
184
|
+
Returns the sensitivity cutoff for Vector3 Component
|
185
|
+
*/
|
186
|
+
float getVector3Sensitivity() const;
|
187
|
+
|
188
|
+
/**
|
189
|
+
@remarks
|
190
|
+
Register/unregister a JoyStick Listener - Only one allowed for simplicity. If broadcasting
|
191
|
+
is neccessary, just broadcast from the callback you registered.
|
192
|
+
@param joyListener
|
193
|
+
Send a pointer to a class derived from JoyStickListener or 0 to clear the callback
|
194
|
+
*/
|
195
|
+
virtual void setEventCallback( JoyStickListener *joyListener );
|
196
|
+
|
197
|
+
/** @remarks Returns currently set callback.. or null */
|
198
|
+
JoyStickListener* getEventCallback() const;
|
199
|
+
|
200
|
+
/** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
|
201
|
+
const JoyStickState& getJoyStickState() const { return mState; }
|
202
|
+
|
203
|
+
//! The minimal axis value
|
204
|
+
static const int MIN_AXIS = -32768;
|
205
|
+
|
206
|
+
//! The maximum axis value
|
207
|
+
static const int MAX_AXIS = 32767;
|
208
|
+
|
209
|
+
protected:
|
210
|
+
JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator);
|
211
|
+
|
212
|
+
//! Number of sliders
|
213
|
+
int mSliders;
|
214
|
+
|
215
|
+
//! Number of POVs
|
216
|
+
int mPOVs;
|
217
|
+
|
218
|
+
//! The JoyStickState structure (contains all component values)
|
219
|
+
JoyStickState mState;
|
220
|
+
|
221
|
+
//! The callback listener
|
222
|
+
JoyStickListener *mListener;
|
223
|
+
|
224
|
+
//! Adjustment factor for orientation vector accuracy
|
225
|
+
float mVector3Sensitivity;
|
226
|
+
};
|
227
|
+
}
|
228
|
+
#endif
|
@@ -0,0 +1,312 @@
|
|
1
|
+
/*
|
2
|
+
The zlib/libpng License
|
3
|
+
|
4
|
+
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
|
5
|
+
|
6
|
+
This software is provided 'as-is', without any express or implied warranty. In no event will
|
7
|
+
the authors be held liable for any damages arising from the use of this software.
|
8
|
+
|
9
|
+
Permission is granted to anyone to use this software for any purpose, including commercial
|
10
|
+
applications, and to alter it and redistribute it freely, subject to the following
|
11
|
+
restrictions:
|
12
|
+
|
13
|
+
1. The origin of this software must not be misrepresented; you must not claim that
|
14
|
+
you wrote the original software. If you use this software in a product,
|
15
|
+
an acknowledgment in the product documentation would be appreciated but is
|
16
|
+
not required.
|
17
|
+
|
18
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
19
|
+
misrepresented as being the original software.
|
20
|
+
|
21
|
+
3. This notice may not be removed or altered from any source distribution.
|
22
|
+
*/
|
23
|
+
#ifndef OIS_Keyboard_H
|
24
|
+
#define OIS_Keyboard_H
|
25
|
+
#include "OISObject.h"
|
26
|
+
#include "OISEvents.h"
|
27
|
+
|
28
|
+
namespace OIS
|
29
|
+
{
|
30
|
+
//! Keyboard scan codes
|
31
|
+
enum KeyCode
|
32
|
+
{
|
33
|
+
KC_UNASSIGNED = 0x00,
|
34
|
+
KC_ESCAPE = 0x01,
|
35
|
+
KC_1 = 0x02,
|
36
|
+
KC_2 = 0x03,
|
37
|
+
KC_3 = 0x04,
|
38
|
+
KC_4 = 0x05,
|
39
|
+
KC_5 = 0x06,
|
40
|
+
KC_6 = 0x07,
|
41
|
+
KC_7 = 0x08,
|
42
|
+
KC_8 = 0x09,
|
43
|
+
KC_9 = 0x0A,
|
44
|
+
KC_0 = 0x0B,
|
45
|
+
KC_MINUS = 0x0C, // - on main keyboard
|
46
|
+
KC_EQUALS = 0x0D,
|
47
|
+
KC_BACK = 0x0E, // backspace
|
48
|
+
KC_TAB = 0x0F,
|
49
|
+
KC_Q = 0x10,
|
50
|
+
KC_W = 0x11,
|
51
|
+
KC_E = 0x12,
|
52
|
+
KC_R = 0x13,
|
53
|
+
KC_T = 0x14,
|
54
|
+
KC_Y = 0x15,
|
55
|
+
KC_U = 0x16,
|
56
|
+
KC_I = 0x17,
|
57
|
+
KC_O = 0x18,
|
58
|
+
KC_P = 0x19,
|
59
|
+
KC_LBRACKET = 0x1A,
|
60
|
+
KC_RBRACKET = 0x1B,
|
61
|
+
KC_RETURN = 0x1C, // Enter on main keyboard
|
62
|
+
KC_LCONTROL = 0x1D,
|
63
|
+
KC_A = 0x1E,
|
64
|
+
KC_S = 0x1F,
|
65
|
+
KC_D = 0x20,
|
66
|
+
KC_F = 0x21,
|
67
|
+
KC_G = 0x22,
|
68
|
+
KC_H = 0x23,
|
69
|
+
KC_J = 0x24,
|
70
|
+
KC_K = 0x25,
|
71
|
+
KC_L = 0x26,
|
72
|
+
KC_SEMICOLON = 0x27,
|
73
|
+
KC_APOSTROPHE = 0x28,
|
74
|
+
KC_GRAVE = 0x29, // accent
|
75
|
+
KC_LSHIFT = 0x2A,
|
76
|
+
KC_BACKSLASH = 0x2B,
|
77
|
+
KC_Z = 0x2C,
|
78
|
+
KC_X = 0x2D,
|
79
|
+
KC_C = 0x2E,
|
80
|
+
KC_V = 0x2F,
|
81
|
+
KC_B = 0x30,
|
82
|
+
KC_N = 0x31,
|
83
|
+
KC_M = 0x32,
|
84
|
+
KC_COMMA = 0x33,
|
85
|
+
KC_PERIOD = 0x34, // . on main keyboard
|
86
|
+
KC_SLASH = 0x35, // / on main keyboard
|
87
|
+
KC_RSHIFT = 0x36,
|
88
|
+
KC_MULTIPLY = 0x37, // * on numeric keypad
|
89
|
+
KC_LMENU = 0x38, // left Alt
|
90
|
+
KC_SPACE = 0x39,
|
91
|
+
KC_CAPITAL = 0x3A,
|
92
|
+
KC_F1 = 0x3B,
|
93
|
+
KC_F2 = 0x3C,
|
94
|
+
KC_F3 = 0x3D,
|
95
|
+
KC_F4 = 0x3E,
|
96
|
+
KC_F5 = 0x3F,
|
97
|
+
KC_F6 = 0x40,
|
98
|
+
KC_F7 = 0x41,
|
99
|
+
KC_F8 = 0x42,
|
100
|
+
KC_F9 = 0x43,
|
101
|
+
KC_F10 = 0x44,
|
102
|
+
KC_NUMLOCK = 0x45,
|
103
|
+
KC_SCROLL = 0x46, // Scroll Lock
|
104
|
+
KC_NUMPAD7 = 0x47,
|
105
|
+
KC_NUMPAD8 = 0x48,
|
106
|
+
KC_NUMPAD9 = 0x49,
|
107
|
+
KC_SUBTRACT = 0x4A, // - on numeric keypad
|
108
|
+
KC_NUMPAD4 = 0x4B,
|
109
|
+
KC_NUMPAD5 = 0x4C,
|
110
|
+
KC_NUMPAD6 = 0x4D,
|
111
|
+
KC_ADD = 0x4E, // + on numeric keypad
|
112
|
+
KC_NUMPAD1 = 0x4F,
|
113
|
+
KC_NUMPAD2 = 0x50,
|
114
|
+
KC_NUMPAD3 = 0x51,
|
115
|
+
KC_NUMPAD0 = 0x52,
|
116
|
+
KC_DECIMAL = 0x53, // . on numeric keypad
|
117
|
+
KC_OEM_102 = 0x56, // < > | on UK/Germany keyboards
|
118
|
+
KC_F11 = 0x57,
|
119
|
+
KC_F12 = 0x58,
|
120
|
+
KC_F13 = 0x64, // (NEC PC98)
|
121
|
+
KC_F14 = 0x65, // (NEC PC98)
|
122
|
+
KC_F15 = 0x66, // (NEC PC98)
|
123
|
+
KC_KANA = 0x70, // (Japanese keyboard)
|
124
|
+
KC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards
|
125
|
+
KC_CONVERT = 0x79, // (Japanese keyboard)
|
126
|
+
KC_NOCONVERT = 0x7B, // (Japanese keyboard)
|
127
|
+
KC_YEN = 0x7D, // (Japanese keyboard)
|
128
|
+
KC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards
|
129
|
+
KC_NUMPADEQUALS= 0x8D, // = on numeric keypad (NEC PC98)
|
130
|
+
KC_PREVTRACK = 0x90, // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
|
131
|
+
KC_AT = 0x91, // (NEC PC98)
|
132
|
+
KC_COLON = 0x92, // (NEC PC98)
|
133
|
+
KC_UNDERLINE = 0x93, // (NEC PC98)
|
134
|
+
KC_KANJI = 0x94, // (Japanese keyboard)
|
135
|
+
KC_STOP = 0x95, // (NEC PC98)
|
136
|
+
KC_AX = 0x96, // (Japan AX)
|
137
|
+
KC_UNLABELED = 0x97, // (J3100)
|
138
|
+
KC_NEXTTRACK = 0x99, // Next Track
|
139
|
+
KC_NUMPADENTER = 0x9C, // Enter on numeric keypad
|
140
|
+
KC_RCONTROL = 0x9D,
|
141
|
+
KC_MUTE = 0xA0, // Mute
|
142
|
+
KC_CALCULATOR = 0xA1, // Calculator
|
143
|
+
KC_PLAYPAUSE = 0xA2, // Play / Pause
|
144
|
+
KC_MEDIASTOP = 0xA4, // Media Stop
|
145
|
+
KC_VOLUMEDOWN = 0xAE, // Volume -
|
146
|
+
KC_VOLUMEUP = 0xB0, // Volume +
|
147
|
+
KC_WEBHOME = 0xB2, // Web home
|
148
|
+
KC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98)
|
149
|
+
KC_DIVIDE = 0xB5, // / on numeric keypad
|
150
|
+
KC_SYSRQ = 0xB7,
|
151
|
+
KC_RMENU = 0xB8, // right Alt
|
152
|
+
KC_PAUSE = 0xC5, // Pause
|
153
|
+
KC_HOME = 0xC7, // Home on arrow keypad
|
154
|
+
KC_UP = 0xC8, // UpArrow on arrow keypad
|
155
|
+
KC_PGUP = 0xC9, // PgUp on arrow keypad
|
156
|
+
KC_LEFT = 0xCB, // LeftArrow on arrow keypad
|
157
|
+
KC_RIGHT = 0xCD, // RightArrow on arrow keypad
|
158
|
+
KC_END = 0xCF, // End on arrow keypad
|
159
|
+
KC_DOWN = 0xD0, // DownArrow on arrow keypad
|
160
|
+
KC_PGDOWN = 0xD1, // PgDn on arrow keypad
|
161
|
+
KC_INSERT = 0xD2, // Insert on arrow keypad
|
162
|
+
KC_DELETE = 0xD3, // Delete on arrow keypad
|
163
|
+
KC_LWIN = 0xDB, // Left Windows key
|
164
|
+
KC_RWIN = 0xDC, // Right Windows key
|
165
|
+
KC_APPS = 0xDD, // AppMenu key
|
166
|
+
KC_POWER = 0xDE, // System Power
|
167
|
+
KC_SLEEP = 0xDF, // System Sleep
|
168
|
+
KC_WAKE = 0xE3, // System Wake
|
169
|
+
KC_WEBSEARCH = 0xE5, // Web Search
|
170
|
+
KC_WEBFAVORITES= 0xE6, // Web Favorites
|
171
|
+
KC_WEBREFRESH = 0xE7, // Web Refresh
|
172
|
+
KC_WEBSTOP = 0xE8, // Web Stop
|
173
|
+
KC_WEBFORWARD = 0xE9, // Web Forward
|
174
|
+
KC_WEBBACK = 0xEA, // Web Back
|
175
|
+
KC_MYCOMPUTER = 0xEB, // My Computer
|
176
|
+
KC_MAIL = 0xEC, // Mail
|
177
|
+
KC_MEDIASELECT = 0xED // Media Select
|
178
|
+
};
|
179
|
+
|
180
|
+
/**
|
181
|
+
Specialised for key events
|
182
|
+
*/
|
183
|
+
class _OISExport KeyEvent : public EventArg
|
184
|
+
{
|
185
|
+
public:
|
186
|
+
KeyEvent(Object* obj, KeyCode kc, unsigned int txt) : EventArg(obj), key(kc), text(txt) {}
|
187
|
+
virtual ~KeyEvent() {}
|
188
|
+
|
189
|
+
//! KeyCode of event
|
190
|
+
const KeyCode key;
|
191
|
+
//! Text character, depends on current TextTranslationMode
|
192
|
+
unsigned int text;
|
193
|
+
};
|
194
|
+
|
195
|
+
/**
|
196
|
+
To recieve buffered keyboard input, derive a class from this, and implement the
|
197
|
+
methods here. Then set the call back to your Keyboard instance with Keyboard::setEventCallback
|
198
|
+
*/
|
199
|
+
class _OISExport KeyListener
|
200
|
+
{
|
201
|
+
public:
|
202
|
+
virtual ~KeyListener() {}
|
203
|
+
virtual bool keyPressed(const KeyEvent &arg) = 0;
|
204
|
+
virtual bool keyReleased(const KeyEvent &arg) = 0;
|
205
|
+
};
|
206
|
+
|
207
|
+
/**
|
208
|
+
Keyboard base class. To be implemented by specific system (ie. DirectX Keyboard)
|
209
|
+
This class is useful as you remain OS independent using this common interface.
|
210
|
+
*/
|
211
|
+
class _OISExport Keyboard : public Object
|
212
|
+
{
|
213
|
+
public:
|
214
|
+
virtual ~Keyboard() {};
|
215
|
+
|
216
|
+
/**
|
217
|
+
@remarks
|
218
|
+
Returns true if key is donwn
|
219
|
+
@param key
|
220
|
+
A KeyCode to check
|
221
|
+
*/
|
222
|
+
virtual bool isKeyDown(KeyCode key) const = 0;
|
223
|
+
|
224
|
+
/**
|
225
|
+
@remarks
|
226
|
+
Register/unregister a Keyboard Listener - Only one allowed for simplicity. If broadcasting
|
227
|
+
is neccessary, just broadcast from the callback you registered.
|
228
|
+
@param keyListener
|
229
|
+
Send a pointer to a class derived from KeyListener or 0 to clear the callback
|
230
|
+
*/
|
231
|
+
virtual void setEventCallback(KeyListener *keyListener) { mListener = keyListener;}
|
232
|
+
|
233
|
+
/**
|
234
|
+
@remarks
|
235
|
+
Returns currently set callback.. or 0
|
236
|
+
*/
|
237
|
+
KeyListener* getEventCallback() const {return mListener;}
|
238
|
+
|
239
|
+
//! TextTranslation Mode
|
240
|
+
enum TextTranslationMode
|
241
|
+
{
|
242
|
+
Off,
|
243
|
+
Unicode,
|
244
|
+
Ascii
|
245
|
+
};
|
246
|
+
|
247
|
+
/**
|
248
|
+
@remarks
|
249
|
+
Enable extra processing to translate KC_*** to an
|
250
|
+
actual text character based off of locale. Different
|
251
|
+
managers may implement none or all. Check the
|
252
|
+
translation mode after setting to be sure
|
253
|
+
@param mode
|
254
|
+
Off, Unicode, Ascii
|
255
|
+
*/
|
256
|
+
virtual void setTextTranslation(TextTranslationMode mode);
|
257
|
+
|
258
|
+
/**
|
259
|
+
@remarks
|
260
|
+
Returns current translation mode
|
261
|
+
*/
|
262
|
+
TextTranslationMode getTextTranslation() const {return mTextMode;}
|
263
|
+
|
264
|
+
/**
|
265
|
+
@remarks
|
266
|
+
Translates KeyCode to string representation.
|
267
|
+
For example, KC_ENTER will be "Enter" - Locale
|
268
|
+
specific of course.
|
269
|
+
@param kc
|
270
|
+
KeyCode to convert
|
271
|
+
@returns
|
272
|
+
The string as determined from the current locale
|
273
|
+
*/
|
274
|
+
virtual const std::string& getAsString(KeyCode kc) = 0;
|
275
|
+
|
276
|
+
//! Enum of bit position of modifer
|
277
|
+
enum Modifier
|
278
|
+
{
|
279
|
+
Shift = 0x0000001,
|
280
|
+
Ctrl = 0x0000010,
|
281
|
+
Alt = 0x0000100
|
282
|
+
};
|
283
|
+
|
284
|
+
/**
|
285
|
+
@remarks
|
286
|
+
Check modifier status
|
287
|
+
*/
|
288
|
+
bool isModifierDown(Modifier mod) const;
|
289
|
+
|
290
|
+
/**
|
291
|
+
@remarks
|
292
|
+
Copies the state of the keys into the sent buffer
|
293
|
+
(in the form of 1 is down and 0 is up)
|
294
|
+
*/
|
295
|
+
virtual void copyKeyStates(char keys[256]) const = 0;
|
296
|
+
|
297
|
+
protected:
|
298
|
+
Keyboard(const std::string &vendor, bool buffered, int devID, InputManager* creator)
|
299
|
+
: Object(vendor, OISKeyboard, buffered, devID, creator),
|
300
|
+
mModifiers(0), mListener(0), mTextMode(Unicode) {}
|
301
|
+
|
302
|
+
//! Bit field that holds status of Alt, Ctrl, Shift
|
303
|
+
unsigned int mModifiers;
|
304
|
+
|
305
|
+
//! Used for buffered/actionmapping callback
|
306
|
+
KeyListener *mListener;
|
307
|
+
|
308
|
+
//! The current translation mode
|
309
|
+
TextTranslationMode mTextMode;
|
310
|
+
};
|
311
|
+
}
|
312
|
+
#endif
|