#include <spUtilityInputService.hpp>
List of all members.
Classes |
struct | SEvent |
| Event entry structure. Each event can have several entries (to have an alternative input). More...
|
Public Types |
typedef std::vector< SEvent > | TEventEntry |
Public Member Functions |
| InputService () |
virtual | ~InputService () |
void | setMaxInputCount (u32 Count) |
| Sets the input count limitation for each entry. By default 2.
|
void | addEvent (s32 EventID) |
| Adds a new event entry.
|
void | addEvent (s32 EventID, const io::EKeyCodes KeyCode) |
| Adds a new event entry with the specified key.
|
void | addEvent (s32 EventID, const io::EMouseKeyCodes MouseKeyCode) |
| Adds a new event entry with the specified mouse button.
|
void | addEvent (s32 EventID, const io::EMouseWheelMotions MouseWheelMotion) |
| Adds a new event entry with the specified mouse wheel motion.
|
void | addEvent (s32 EventID, const io::EJoystickKeyCodes JoystickKeyCode) |
| Adds a new event entry with the specified joystick button.
|
void | addEvent (s32 EventID, const io::EGamePadButtons GamePadKeyCode, s32 Number) |
| Adds a new event entry with the specified gamepad button.
|
bool | addEventKeyBinding (s32 EventID, s32 Flags=io::INPUTTYPE_ANY) |
void | resetEvent (s32 EventID) |
| Resets the specified event entry. After that it has no input information.
|
void | removeEvent (s32 EventID) |
| Removes the specified event entry.
|
bool | down (s32 EventID) |
| Returns true if the specified event entry is active. Use this for a key-down, mouse-down, mouse-wheel and joystick-down checks.
|
bool | hit (s32 EventID) |
| Returns true if the specified event entry is active. Use this for a key-hit and mouse-hit and mouse-wheel checks.
|
bool | released (s32 EventID) |
| Returns true if the specified event entry is active. Use this for a key-released and mouse-released checks.
|
TEventEntry | getEventEntryList (s32 EventID) const |
| Returns the entry list for the specified event.
|
Protected Member Functions |
void | addEventEntry (s32 EventID, const SEvent &EventEntry) |
bool | checkForKeyBinding (s32 EventID, s32 FirstIndex, s32 LastIndex) |
TEventEntry * | getEvent (s32 EventID) |
Protected Attributes |
u32 | MaxInputCount_ |
std::map< s32, TEventEntry > | EventEntryMap_ |
Detailed Description
The input service is used to simplify the input event handling for your games. Here is a small example which shows how to use the InputService class:
enum MyGameInputEvents
{
GAME_INPUT_MOVE_FORWARDS,
GAME_INPUT_MOVE_BACKWARDS,
GAME_INPUT_MOVE_LEFT,
GAME_INPUT_MOVE_RIGHT,
GAME_INPUT_JUMP,
GAME_INPUT_SHOOT,
GAME_INPUT_RELOAD,
GAME_INPUT_WEAPON_NEXT,
GAME_INPUT_WEAPON_PREVIOUS,
};
InputService service(spControl);
service.addEvent(GAME_INPUT_MOVE_FORWARDS, io::KEY_W );
service.addEvent(GAME_INPUT_MOVE_BACKWARDS, io::KEY_S );
service.addEvent(GAME_INPUT_MOVE_LEFT, io::KEY_A );
service.addEvent(GAME_INPUT_MOVE_RIGHT, io::KEY_D );
service.addEvent(GAME_INPUT_JUMP, io::KEY_SPACE );
service.addEvent(GAME_INPUT_SHOOT, io::MOUSE_LEFT );
service.addEvent(GAME_INPUT_SHOOT, io::KEY_RETURN );
service.addEvent(GAME_INPUT_RELOAD, io::KEY_R );
service.addEvent(GAME_INPUT_WEAPON_NEXT, io::MOUSEWHEEL_UP );
service.addEvent(GAME_INPUT_WEAPON_PREVIOUS, io::MOUSEWHEEL_DOWN );
if (IsChangeGameControlSettings)
{
while (!service.addEventKeyBinding(GAME_INPUT_JUMP))
DrawPressAnyKeyInfo();
}
if (service.down(GAME_INPUT_MOVE_FORWARDS))
MovePlayerForwards();
if (service.hit(GAME_INPUT_SHOOT))
Shoot();
- Since:
- Version 3.2
Member Typedef Documentation
Constructor & Destructor Documentation
sp::tool::InputService::InputService |
( |
|
) |
|
virtual sp::tool::InputService::~InputService |
( |
|
) |
[virtual] |
Member Function Documentation
void sp::tool::InputService::addEvent |
( |
s32 |
EventID |
) |
|
void sp::tool::InputService::addEvent |
( |
s32 |
EventID, |
|
|
const io::EMouseKeyCodes |
MouseKeyCode | |
|
) |
| | |
void sp::tool::InputService::addEvent |
( |
s32 |
EventID, |
|
|
const io::EMouseWheelMotions |
MouseWheelMotion | |
|
) |
| | |
void sp::tool::InputService::addEvent |
( |
s32 |
EventID, |
|
|
const io::EKeyCodes |
KeyCode | |
|
) |
| | |
void sp::tool::InputService::addEvent |
( |
s32 |
EventID, |
|
|
const io::EJoystickKeyCodes |
JoystickKeyCode | |
|
) |
| | |
void sp::tool::InputService::addEvent |
( |
s32 |
EventID, |
|
|
const io::EGamePadButtons |
GamePadKeyCode, |
|
|
s32 |
Number | |
|
) |
| | |
void sp::tool::InputService::addEventEntry |
( |
s32 |
EventID, |
|
|
const SEvent & |
EventEntry | |
|
) |
| | [protected] |
bool sp::tool::InputService::addEventKeyBinding |
( |
s32 |
EventID, |
|
|
s32 |
Flags = io::INPUTTYPE_ANY | |
|
) |
| | |
Adds a new event entry by key binding.
- Parameters:
-
[in] | EventID | Specifies the event ID number. This can be any integer number. It's recommended that you use your own enumerations for this. |
[in] | Flags | Specifies which input types are to be used. By default all (keyboard, mouse, mouse-wheel and joystick). |
- Returns:
- False as long as no input has been detected. Once any key, mouse button, jostick button or mouse wheel motion has been detected the function returns true.
bool sp::tool::InputService::checkForKeyBinding |
( |
s32 |
EventID, |
|
|
s32 |
FirstIndex, |
|
|
s32 |
LastIndex | |
|
) |
| | [protected] |
bool sp::tool::InputService::down |
( |
s32 |
EventID |
) |
|
Returns true if the specified event entry is active. Use this for a key-down, mouse-down, mouse-wheel and joystick-down checks.
TEventEntry* sp::tool::InputService::getEvent |
( |
s32 |
EventID |
) |
[inline, protected] |
TEventEntry sp::tool::InputService::getEventEntryList |
( |
s32 |
EventID |
) |
const |
Returns the entry list for the specified event.
bool sp::tool::InputService::hit |
( |
s32 |
EventID |
) |
|
Returns true if the specified event entry is active. Use this for a key-hit and mouse-hit and mouse-wheel checks.
bool sp::tool::InputService::released |
( |
s32 |
EventID |
) |
|
Returns true if the specified event entry is active. Use this for a key-released and mouse-released checks.
void sp::tool::InputService::removeEvent |
( |
s32 |
EventID |
) |
|
Removes the specified event entry.
void sp::tool::InputService::resetEvent |
( |
s32 |
EventID |
) |
|
Resets the specified event entry. After that it has no input information.
void sp::tool::InputService::setMaxInputCount |
( |
u32 |
Count |
) |
|
Sets the input count limitation for each entry. By default 2.
Member Data Documentation
The documentation for this class was generated from the following file: