#include <xrb_keyrepeater.hpp>
Public Member Functions | |
KeyRepeater (Float repeat_delay=0.25, Float repeat_period=0.033) | |
Constructs a KeyRepeater with the given properties. | |
~KeyRepeater () | |
Destructor. | |
bool | IsEventQueueFull () const |
Returns true iff the key repeat event queue is full. | |
bool | IsEventQueueEmpty () const |
Returns true iff the key repeat event queue is empty. | |
EventKeyRepeat * | DequeueEvent () |
Dequeues a single key repeat event. | |
Protected Member Functions | |
virtual void | HandleFrame () |
Does time-based generation of key repeat events, based on the current state of the most recently pressed key. | |
virtual bool | HandleEvent (Event const *e) |
Processes key events. |
Key repeat events are generated to get the effect of holding a key down while typing, simulating many keystrokes of the same key very quickly.
Keyboard events are processed by this class, and a series of EventKeyRepeat events are queued up when HandleFrame is called to indicate each iteration of the game loop.
Definition at line 33 of file xrb_keyrepeater.hpp.
Xrb::KeyRepeater::KeyRepeater | ( | Float | repeat_delay = 0.25 , |
|
Float | repeat_period = 0.033 | |||
) |
Constructs a KeyRepeater with the given properties.
The default values for repeat_delay
and repeat_period
seem to be the most common values (that I've seen at least). 25 millisecond delay, and then 30 events per second.
repeat_delay | The time that must elapse after a key is pressed before key repeat events are generated. | |
repeat_period | The time between successive key repeat events. |
Definition at line 18 of file xrb_keyrepeater.cpp.
bool Xrb::KeyRepeater::IsEventQueueFull | ( | ) | const [inline] |
Returns true iff the key repeat event queue is full.
HandleFrame generates the key repeat events and queues them so they can be later removed and put in the main EventQueue. This accessor is used when generating the key repeat events, indicating one of the conditions to stop generating key repeat events during this HandleFrame.
Definition at line 59 of file xrb_keyrepeater.hpp.
References Xrb::CircularQueue< T, queue_size >::IsFull().
bool Xrb::KeyRepeater::IsEventQueueEmpty | ( | ) | const [inline] |
Returns true iff the key repeat event queue is empty.
HandleFrame generates the key repeat events and queues them so they can be later removed and put in the main EventQueue. This accessor is used when emptying the queue of key repeat events and putting them into the main EventQueue.
Definition at line 69 of file xrb_keyrepeater.hpp.
References Xrb::CircularQueue< T, queue_size >::IsEmpty().
EventKeyRepeat * Xrb::KeyRepeater::DequeueEvent | ( | ) |
Dequeues a single key repeat event.
The dequeued events should be enqueued into the main EventQueue.
Definition at line 39 of file xrb_keyrepeater.cpp.
References Xrb::CircularQueue< T, queue_size >::Dequeue(), and Xrb::CircularQueue< T, queue_size >::IsEmpty().
bool Xrb::KeyRepeater::HandleEvent | ( | Event const * | e | ) | [protected, virtual] |
Processes key events.
Performs the necessary tracking for most recently pressed key and timings and such.
Implements Xrb::EventHandler.
Definition at line 51 of file xrb_keyrepeater.cpp.
References Xrb::Event::IsKeyEvent(), Xrb::EventKey::KeyCode(), and Xrb::Event::Time().