00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_KEYREPEATER_HPP_)
00012 #define _XRB_KEYREPEATER_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include "xrb_circularqueue.hpp"
00017 #include "xrb_eventhandler.hpp"
00018 #include "xrb_framehandler.hpp"
00019 #include "xrb_input_events.hpp"
00020
00021 namespace Xrb
00022 {
00023
00033 class KeyRepeater : public EventHandler, public FrameHandler
00034 {
00035 public:
00036
00045 KeyRepeater (
00046 Float repeat_delay = 0.25,
00047 Float repeat_period = 0.033);
00050 ~KeyRepeater ();
00051
00059 inline bool IsEventQueueFull () const
00060 {
00061 return m_key_event_queue.IsFull();
00062 }
00069 inline bool IsEventQueueEmpty () const
00070 {
00071 return m_key_event_queue.IsEmpty();
00072 }
00073
00077 EventKeyRepeat *DequeueEvent ();
00078
00079 protected:
00080
00084 virtual void HandleFrame ();
00089 virtual bool HandleEvent (Event const *e);
00090
00091 private:
00092
00093 void GenerateKeyEvents (Float time);
00094
00095 enum
00096 {
00097 DEFAULT_KEY_EVENT_BUFFER_SIZE = 32
00098 };
00099
00100
00101
00102 bool m_is_current_key_event_active;
00103
00104
00105 EventKeyDown m_current_key_event;
00106
00107 Float m_repeat_delay;
00108
00109
00110 Float m_repeat_period;
00111
00112 Float m_next_repeat_time;
00113
00114 CircularQueue<EventKeyRepeat *, DEFAULT_KEY_EVENT_BUFFER_SIZE> m_key_event_queue;
00115 };
00116
00117 }
00118
00119 #endif // !defined(_XRB_KEYREPEATER_HPP_)
00120