change InputEvent to a class instead of a struct

This commit is contained in:
Josh Holtrop 2013-03-10 21:34:40 -04:00
parent 23f58602e2
commit 89c88b3469

View File

@ -10,11 +10,11 @@ enum
typedef bool[INPUT_COUNT] Inputs; typedef bool[INPUT_COUNT] Inputs;
struct InputEvent class InputEvent
{ {
uint tick; uint tick;
Inputs inputs; Inputs inputs;
InputEvent *next; InputEvent next;
}; };
class InputEventList class InputEventList
@ -22,10 +22,10 @@ class InputEventList
public: public:
void add_event(uint tick, int event, bool active) void add_event(uint tick, int event, bool active)
{ {
InputEvent *ie = get_event_for_tick(tick); InputEvent ie = get_event_for_tick(tick);
ie.inputs[event] = active; ie.inputs[event] = active;
} }
InputEvent *get_event_for_tick(uint tick) InputEvent get_event_for_tick(uint tick)
{ {
if (m_last_event is null) if (m_last_event is null)
{ {
@ -41,7 +41,7 @@ public:
} }
return m_last_event; return m_last_event;
} }
InputEvent *get_first_event() { return m_events; } InputEvent get_first_event() { return m_events; }
void remove_older_than(uint tick) void remove_older_than(uint tick)
{ {
while ((m_events !is null) && (m_events.tick <= tick)) while ((m_events !is null) && (m_events.tick <= tick))
@ -55,6 +55,6 @@ public:
} }
protected: protected:
InputEvent *m_events; InputEvent m_events;
InputEvent *m_last_event; InputEvent m_last_event;
}; };