LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::Input Class Reference

Default window event listener to receive user input. More...

#include <Input.h>

Inheritance diagram for LLGL::Input:
LLGL::Interface LLGL::NonCopyable

Public Member Functions

 Input ()
 Default initializes the input handler without assigning to any surface.
 Input (Surface &surface)
 Assigns an event listener for this input handler to the specified surface.
 ~Input ()
 Releases the internal data.
void Reset ()
 Resets the internal state. remarks This should be called once before Surface::ProcessEvents is invoked.
void Listen (Surface &surface)
 Adds an event listener for this input handler to the specified surface.
void Drop (Surface &surface)
 Removes the event listener for this input handler from the specified surface.
bool KeyPressed (Key keyCode) const
 Returns true if the specified key is currently being pressed down.
bool KeyDown (Key keyCode) const
 Returns true if the specified key was pressed down in the previous event processing.
bool KeyDownRepeated (Key keyCode) const
 Returns true if the specified key was pressed down in the previous event processing (this event will be repeated, depending on the platform settings).
bool KeyUp (Key keyCode) const
 Returns true if the specified key was released in the previous event processing.
bool KeyDoubleClick (Key keyCode) const
 Returns true if the specified key was double clicked.
Offset2D GetMousePosition () const
 Returns the local mouse position.
Offset2D GetMouseMotion () const
 Returns the global mouse motion.
int GetWheelMotion () const
 Returns the mouse wheel motion.
const UTF8String & GetEnteredChars () const
 Returns the entered characters.
unsigned GetAnyKeyCount () const
 Returns the number of any keys being pressed.
Public Member Functions inherited from LLGL::Interface
virtual bool IsInstanceOf (int id) const
 Returns true if this object is an instance of the specified interface.
Public Member Functions inherited from LLGL::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
virtual ~NonCopyable ()=default

Additional Inherited Members

Protected Member Functions inherited from LLGL::NonCopyable
 NonCopyable ()=default

Detailed Description

Default window event listener to receive user input.

Remarks
This class stores all received user input for a simple evaluation. However, for efficient evaluation, write your own sub class and only respond to user input when the appropriate callback is invoked. Here is an example usage:
LLGL::Input myInput;
myInput.Listen(*myWindow);
// Quit main loop when user hit the escape key.
if (myInput.KeyDown(LLGL::Key::Escape))
break;
// Rendering goes here ...
// Reset input states
myInput.Reset();
}
Default window event listener to receive user input.
Definition Input.h:43
void Listen(Surface &surface)
Adds an event listener for this input handler to the specified surface.
void Reset()
Resets the internal state. remarks This should be called once before Surface::ProcessEvents is invoke...
bool KeyDown(Key keyCode) const
Returns true if the specified key was pressed down in the previous event processing.
static bool ProcessEvents()
Processes all windowing system events, i.e. input-, movement-, resize-, and other events for all surf...
@ Escape
Escape (ESC) key.
Definition Key.h:43
Todo
Make Window::EventListener a member of Input instead of extending it. Also add a member of Canvas::EventListener and add touch event functions.

Constructor & Destructor Documentation

◆ Input() [1/2]

LLGL::Input::Input ( )

Default initializes the input handler without assigning to any surface.

◆ Input() [2/2]

LLGL::Input::Input ( Surface & surface)

Assigns an event listener for this input handler to the specified surface.

◆ ~Input()

LLGL::Input::~Input ( )

Releases the internal data.

Member Function Documentation

◆ Drop()

void LLGL::Input::Drop ( Surface & surface)

Removes the event listener for this input handler from the specified surface.

◆ GetAnyKeyCount()

unsigned LLGL::Input::GetAnyKeyCount ( ) const

Returns the number of any keys being pressed.

◆ GetEnteredChars()

const UTF8String & LLGL::Input::GetEnteredChars ( ) const

Returns the entered characters.

◆ GetMouseMotion()

Offset2D LLGL::Input::GetMouseMotion ( ) const

Returns the global mouse motion.

◆ GetMousePosition()

Offset2D LLGL::Input::GetMousePosition ( ) const

Returns the local mouse position.

◆ GetWheelMotion()

int LLGL::Input::GetWheelMotion ( ) const

Returns the mouse wheel motion.

◆ KeyDoubleClick()

bool LLGL::Input::KeyDoubleClick ( Key keyCode) const

Returns true if the specified key was double clicked.

Remarks
This can only be true for the key codes: Key::LButton, Key::RButton, and Key::MButton.

◆ KeyDown()

bool LLGL::Input::KeyDown ( Key keyCode) const

Returns true if the specified key was pressed down in the previous event processing.

◆ KeyDownRepeated()

bool LLGL::Input::KeyDownRepeated ( Key keyCode) const

Returns true if the specified key was pressed down in the previous event processing (this event will be repeated, depending on the platform settings).

◆ KeyPressed()

bool LLGL::Input::KeyPressed ( Key keyCode) const

Returns true if the specified key is currently being pressed down.

◆ KeyUp()

bool LLGL::Input::KeyUp ( Key keyCode) const

Returns true if the specified key was released in the previous event processing.

◆ Listen()

void LLGL::Input::Listen ( Surface & surface)

Adds an event listener for this input handler to the specified surface.

◆ Reset()

void LLGL::Input::Reset ( )

Resets the internal state. remarks This should be called once before Surface::ProcessEvents is invoked.

See also
Surface::ProcessEvents
Todo
Rename to Tick() or something else to indicate this needs to be called once a frame.

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