Manages keyboard and mouse inputs.
More...
#include <InputManager.h>
|
int | onKeyUp (Callback< Keyboard::Key > callback) |
| Add an event listener to a key up event. More...
|
|
int | onKeyDown (Callback< Keyboard::Key > callback) |
| Add an event listener to a key down event. More...
|
|
int | onKeyHeld (Callback< Keyboard::Key > callback) |
| Add an event listener to a key held event. More...
|
|
bool | unsubscribe (KeyboardEvent event, int id) |
| Remove an event listener from a key down or key up event. More...
|
|
int | onMouseUp (Callback< Mouse::Button, int, int > callback) |
| Add an event listener to a mouse button up event. More...
|
|
int | onMouseUp (Callback< Mouse::Button > callback) |
| Add an event listener to a mouse button up event. More...
|
|
int | onMouseDown (Callback< Mouse::Button, int, int > callback) |
| Add an event listener to a mouse button up event. More...
|
|
int | onMouseDown (Callback< Mouse::Button > callback) |
| Add an event listener to a mouse button down event. More...
|
|
int | onMouseMove (Callback< int, int > callback) |
| Add an event listener to a mouse move event. More...
|
|
int | onMouseWheelScroll (Callback< Mouse::Wheel, float, int, int > callback) |
| Add an event listener to a mouse wheel scroll event. More...
|
|
bool | unsubscribe (MouseEvent event, int id) |
| Remove an event listener from a mouse event. More...
|
|
void | handleEvent (Event event) |
| Update the event manager. More...
|
|
Manages keyboard and mouse inputs.
You usually don't instantiate this class directly, you either use the input manager that is local to a Scene or the global input manager that from the Engine class
Definition at line 42 of file InputManager.h.
◆ handleEvent()
void ime::input::InputManager::handleEvent |
( |
Event |
event | ) |
|
Update the event manager.
- Parameters
-
◆ isKeyPressed()
static bool ime::input::InputManager::isKeyPressed |
( |
Keyboard::Key |
key | ) |
|
|
static |
Check if a key is currently pressed or not.
- Parameters
-
- Returns
- True if the key is pressed, otherwise false
This function checks the state of the key in real time
◆ isMouseDown()
static bool ime::input::InputManager::isMouseDown |
( |
Mouse::Button |
button | ) |
|
|
static |
Check if a mouse button is currently pressed or not.
- Parameters
-
button | Mouse button to check |
- Returns
- True if the mouse button is pressed, otherwise false
This function checks the state of a mouse button in real time
◆ onKeyDown()
Add an event listener to a key down event.
- Parameters
-
callback | Function to be executed when a key is down |
- Returns
- The event listeners identification number
The key down event fires once when a key is depressed. If the key remains depressed a key held event fires. In other words, if you press and hold a key on the keyboard, the key down event will fire once and wil not fire again until the key is released and pressed again
- See also
- onKeyUp and onKeyHeld
◆ onKeyHeld()
Add an event listener to a key held event.
- Parameters
-
callback | Function to be executed when a key is held |
- Returns
- The event listeners identification number
The key held event will continue to fire while a key is held down. The event always fires after a key down event. The callback is passed the key that is held down
- See also
- onKeyDown
◆ onKeyUp()
Add an event listener to a key up event.
- Parameters
-
callback | Function to be executed when the key is released |
- Returns
- The event listeners identification number
This event is triggered only when a depressed/held key is released. The callback is passed the key that was released
- See also
- onKeyDown and onKeyHeld
◆ onMouseDown() [1/2]
Add an event listener to a mouse button down event.
- Parameters
-
callback | The function to be executed when the mouse button is depressed |
- Returns
- The event listeners identification number
The callback is passed the button that was depressed
- Note
- This event does NOT fire repetitively while the mouse button is depressed
◆ onMouseDown() [2/2]
Add an event listener to a mouse button up event.
- Parameters
-
callback | The function to be executed when the event a mouse button is released |
- Returns
- The event listeners identification number
The mouse button down event is fired when a mouse button is depressed. The callback is passed the button that was depressed and the coordinates of the mouse cursor when the button was depressed. The mouse cursor coordinates are relative to the game window
- Note
- This event does NOT fire repetitively while the mouse button is depressed
◆ onMouseMove()
int ime::input::InputManager::onMouseMove |
( |
Callback< int, int > |
callback | ) |
|
Add an event listener to a mouse move event.
- Parameters
-
callback | Function to execute when the mouse moves |
- Returns
- The event listeners identification number
The callback function will be passed the new position of the mouse cursor
◆ onMouseUp() [1/2]
Add an event listener to a mouse button up event.
- Parameters
-
callback | The function to be executed when the mouse button is released |
- Returns
- The event listeners identification number
The mouse button up event is fired when a depressed mouse button is released. The callback is passed the button that was released
◆ onMouseUp() [2/2]
Add an event listener to a mouse button up event.
- Parameters
-
callback | The function to be executed when the mouse button is released |
- Returns
- The event listeners identification number
The mouse button up event is fired when a depressed mouse button is released. The callback is passed the button that was released and the coordinates of the mouse cursor when the button was released. The mouse cursor coordinates are relative to the game window
◆ onMouseWheelScroll()
int ime::input::InputManager::onMouseWheelScroll |
( |
Callback< Mouse::Wheel, float, int, int > |
callback | ) |
|
Add an event listener to a mouse wheel scroll event.
- Parameters
-
callback | Function to be executed when the mouse wheel is scrolled |
- Returns
- The event listeners identification number
The callback is passed the scrolled wheel and the wheel offset (positive is up/left, negative is down/right), and the mouse coordinates relative to the game window
◆ unsubscribe() [1/2]
bool ime::input::InputManager::unsubscribe |
( |
KeyboardEvent |
event, |
|
|
int |
id |
|
) |
| |
Remove an event listener from a key down or key up event.
- Parameters
-
event | Event to remove event listener from |
id | Identification number of the listener to be removed |
- Returns
- True if the event listener was removed from the event, or false if the specified event does not have an event listener with the specified id
◆ unsubscribe() [2/2]
bool ime::input::InputManager::unsubscribe |
( |
MouseEvent |
event, |
|
|
int |
id |
|
) |
| |
Remove an event listener from a mouse event.
- Parameters
-
event | The event to remove the event listener from |
id | The id of the event listener |
- Returns
- True if the event listener was removed or false if the given event does not have the specified event listener
The documentation for this class was generated from the following file: