diff --git a/escher/src/container.cpp b/escher/src/container.cpp index e2f19247d..9c33c6b10 100644 --- a/escher/src/container.cpp +++ b/escher/src/container.cpp @@ -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; } diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index 8f0723b4d..9dc27eb25 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -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); + } } diff --git a/ion/src/shared/events.cpp b/ion/src/shared/events.cpp index 1e7babc20..51cbb733d 100644 --- a/ion/src/shared/events.cpp +++ b/ion/src/shared/events.cpp @@ -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 {