mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[ion] Introduce Ion::Events::None
Which allows Ion::Events::getEvent to be non-blocking Change-Id: I2715b10ace2ecbac153b0f7d00ea5f2ca5de399c
This commit is contained in:
@@ -37,6 +37,9 @@ void Container::run() {
|
||||
|
||||
void Container::step() {
|
||||
Ion::Events::Event event = Ion::Events::getEvent(); // This is a blocking call
|
||||
if (event == Ion::Events::None) {
|
||||
return;
|
||||
}
|
||||
if (handleEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,12 @@ public:
|
||||
static constexpr Event ShiftKey(Keyboard::Key k) { return Event(k_eventPageSize+(int)k); }
|
||||
static constexpr Event AlphaKey(Keyboard::Key k) { return Event(2*k_eventPageSize+(int)k); }
|
||||
static constexpr Event ShiftAlphaKey(Keyboard::Key k) { return Event(3*k_eventPageSize+(int)k); }
|
||||
static constexpr Event Special(int i) { return Event(4*k_eventPageSize+i); }
|
||||
|
||||
constexpr Event(int i) : m_id(i){}
|
||||
Event(Keyboard::Key key, bool shift, bool alpha);
|
||||
|
||||
bool operator ==(const Event &other) const {
|
||||
bool operator==(const Event & other) const {
|
||||
return (m_id == other.m_id);
|
||||
}
|
||||
const char * text() const;
|
||||
@@ -185,6 +186,8 @@ constexpr Event UpperX = Event::ShiftAlphaKey(Keyboard::Key::H2);
|
||||
constexpr Event UpperY = Event::ShiftAlphaKey(Keyboard::Key::H3);
|
||||
constexpr Event UpperZ = Event::ShiftAlphaKey(Keyboard::Key::H4);
|
||||
|
||||
constexpr Event None = Event::Special(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,9 +83,7 @@ Event::Event(Keyboard::Key key, bool shift, bool alpha) {
|
||||
// alpha-X -> X
|
||||
// shift-alpha-X -> alpha-X -> X
|
||||
|
||||
constexpr uint8_t undefinedEventId = 4*k_eventPageSize;
|
||||
|
||||
m_id = undefinedEventId;
|
||||
m_id = Events::None.m_id;
|
||||
|
||||
int noFallbackOffsets[] = {0};
|
||||
int shiftFallbackOffsets[] = {k_eventPageSize, 0};
|
||||
@@ -102,7 +100,7 @@ Event::Event(Keyboard::Key key, bool shift, bool alpha) {
|
||||
m_id = offset + (int)key;
|
||||
} while (offset > 0 && s_dataForEvent[m_id].isUndefined());
|
||||
|
||||
assert(m_id != undefinedEventId);
|
||||
assert(m_id != Events::None.m_id);
|
||||
}
|
||||
|
||||
const char * Event::text() const {
|
||||
|
||||
Reference in New Issue
Block a user