Ocular Engine
Ocular::Core::InputHandler Class Reference

#include <InputHandler.hpp>

Public Member Functions

void update ()
 
void triggerKeyboardKeyDown (KeyboardKeys key)
 
void triggerMouseButtonDown (MouseButtons button)
 
void triggerKeyboardKeyUp (KeyboardKeys key)
 
void triggerMouseButtonUp (MouseButtons button)
 
void triggerMouseMoveDelta (Math::Vector2i const &delta)
 
void setMousePosition (Math::Vector2i const &position)
 
void triggerMouseScrollDelta (int8_t delta)
 
Math::Vector2i const & getMousePosition () const
 
bool isKeyboardKeyDown (KeyboardKeys key) const
 
bool isMouseButtonDown (MouseButtons button) const
 
bool isLeftShiftDown () const
 
bool isRightShiftDown () const
 
bool isLeftCtrlDown () const
 
bool isRightCtrlDown () const
 
bool isLeftAltDown () const
 
bool isRightAltDown () const
 
bool isLeftMouseDown () const
 
bool isRightMouseDown () const
 

Static Public Member Functions

static std::string ToString (KeyState state)
 
static std::string ToString (MouseButtons button)
 
static std::string ToString (KeyboardKeys key)
 

Detailed Description

Receives all low-level system input messages regarding the keyboard and mouse devices, and generates appropriate input events off of them.

Also allows for any-time querying of the state of the input devices.

Member Function Documentation

Math::Vector2i const & Ocular::Core::InputHandler::getMousePosition ( ) const

Retrieves the current mouse position in window coordinates.

bool Ocular::Core::InputHandler::isKeyboardKeyDown ( KeyboardKeys  key) const

Checks if the specified keyboard key is down. See Ocular::Core::KeyboardKeys for supported keys to query.

Parameters
[in]keyWhich key to check the state of.
Returns
TRUE if the key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isLeftAltDown ( ) const

Checks if the left alt keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::AltLeft);

Returns
TRUE if they left alt key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isLeftCtrlDown ( ) const

Checks if the left ctrl keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::CtrlLeft);

Returns
TRUE if they left ctrl key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isLeftMouseDown ( ) const

Checks if the left mouse button is down. Convenience method that works identically to:

isMouseButtonDown(MouseButtons::Left);

Returns
TRUE if the left mouse key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isLeftShiftDown ( ) const

Checks if the left shift keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::ShiftLeft);

Returns
TRUE if they left shift key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isMouseButtonDown ( MouseButtons  button) const

Checks if the specified mouse key is down. See Ocular::Core::MouseButtons for supported keys to query.

Parameters
[in]buttonWhich key to check the state of.
Returns
TRUE if the key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isRightAltDown ( ) const

Checks if the right alt keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::AltRight);

Returns
TRUE if they right alt key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isRightCtrlDown ( ) const

Checks if the right ctrl keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::CtrlRight);

Returns
TRUE if they right ctrl key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isRightMouseDown ( ) const

Checks if the right mouse button is down. Convenience method that works identically to:

isMouseButtonDown(MouseButtons::Right);

Returns
TRUE if the right mouse key is currently down and has not yet been released.
bool Ocular::Core::InputHandler::isRightShiftDown ( ) const

Checks if the right shift keyboard key is down. Convenience method that works identically to:

isKeyboardKeyDown(KeyboardKeys::ShiftRight);

Returns
TRUE if they right shift key is currently down and has not yet been released.
void Ocular::Core::InputHandler::setMousePosition ( Math::Vector2i const &  position)

Sets the mouse position.

Typically used by the low-level input readers, but can also be used to simulate mouse movement if needed.

Parameters
[in]positionNew mouse position.
void Ocular::Core::InputHandler::triggerKeyboardKeyDown ( KeyboardKeys  key)

Triggers the specified keyboard key down.

Typically used by the low-level input readers, but can also be used to simulate a key press if needed.

Parameters
[in]keyThe keyboard key to trigger. See Ocular::Core::KeyboardKeys
void Ocular::Core::InputHandler::triggerKeyboardKeyUp ( KeyboardKeys  key)

Triggers the specified keyboard key up.

Typically used by the low-level input readers, but can also be used to simulate a key release if needed.

Parameters
[in]keyThe keyboard key to trigger. See Ocular::Core::KeyboardKeys
void Ocular::Core::InputHandler::triggerMouseButtonDown ( MouseButtons  button)

Triggers the specified mouse button down.

Typically used by the low-level input readers, but can also be used to simulate a button press if needed.

Parameters
[in]buttonThe mouse button to trigger. See Ocular::Core::MouseButtons
void Ocular::Core::InputHandler::triggerMouseButtonUp ( MouseButtons  button)

Triggers the specified mouse button up.

Typically used by the low-level input readers, but can also be used to simulate a button release if needed.

Parameters
[in]buttonThe mouse button to trigger. See Ocular::Core::MouseButtons
void Ocular::Core::InputHandler::triggerMouseMoveDelta ( Math::Vector2i const &  delta)
Parameters
[in]xDelta
[in]yDelta
void Ocular::Core::InputHandler::triggerMouseScrollDelta ( int8_t  delta)

Applies a delta value to the mouse wheel.

Parameters
[in]delta
void Ocular::Core::InputHandler::update ( )

If enough time has elapsed, the keyboard and mouse states are checked. Input events are generated if any keys or buttons have been changed.


The documentation for this class was generated from the following files: