Input - simple-entertainment/simplicity GitHub Wiki
The input API provides structures that contain information about input events. Events are propagated using the messaging API, see that documentation for information on how to register a message receiver.
Keyboard Button Events
When receiving a message from a keyboard button event (Subject::KEYBOARD_BUTTON
), cast the message to a KeyboardButtonEvent
:
void onKeyboardButton(const void* message)
{
const KeyboardButtonEvent* event = static_cast<const KeyboardButtonEvent*>(message);
// Handle event here...
}
Mouse Button Events
When receiving a message from a mouse button event (Subject::MOUSE_BUTTON
), cast the message to a MouseButtonEvent
:
void onMouseButton(unsigned short subject, const void* message)
{
const MouseButtonEvent* event = static_cast<const MouseButtonEvent*>(message);
// Handle event here...
}
Mouse Movement Events
When receiving a message from a mouse movement event (Subject::MOUSE_MOVE
), cast the message to a MouseMoveEvent
:
void onMouseButton(unsigned short subject, const void* message)
{
const MouseMoveEvent* event = static_cast<const MouseMoveEvent*>(message);
// Handle event here...
}