mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion/events] Factor includes of layout_events.h
Change-Id: Id7f68f4dfb4727453a02437a0b824492a8c94730
This commit is contained in:
committed by
Émilie Feral
parent
4ea8263185
commit
b0b6fe33c9
@@ -36,6 +36,9 @@ public:
|
||||
bool isDefined() const;
|
||||
static constexpr int PageSize = Keyboard::NumberOfKeys;
|
||||
private:
|
||||
bool defaultIsDefined() const;
|
||||
const char * defaultText() const;
|
||||
|
||||
uint8_t m_id;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <ion/events.h>
|
||||
#include <layout_events.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Events {
|
||||
@@ -8,18 +7,11 @@ void didPressNewKey() {
|
||||
}
|
||||
|
||||
bool Event::isDefined() const {
|
||||
if (isKeyboardEvent()) {
|
||||
return s_dataForEvent[m_id].isDefined();
|
||||
} else {
|
||||
return (*this == None || *this == Termination || *this == USBEnumeration || *this == USBPlug || *this == BatteryCharging);
|
||||
}
|
||||
return defaultIsDefined();
|
||||
}
|
||||
|
||||
const char * Event::text() const {
|
||||
if (m_id >= 4*PageSize) {
|
||||
return nullptr;
|
||||
}
|
||||
return s_dataForEvent[m_id].text();
|
||||
return defaultText();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,5 +52,20 @@ bool Event::hasText() const {
|
||||
return text() != nullptr;
|
||||
}
|
||||
|
||||
bool Event::defaultIsDefined() const {
|
||||
if (isKeyboardEvent()) {
|
||||
return s_dataForEvent[m_id].isDefined();
|
||||
} else {
|
||||
return (*this == None || *this == Termination || *this == USBEnumeration || *this == USBPlug || *this == BatteryCharging);
|
||||
}
|
||||
}
|
||||
|
||||
const char * Event::defaultText() const {
|
||||
if (m_id >= 4*PageSize) {
|
||||
return nullptr;
|
||||
}
|
||||
return s_dataForEvent[m_id].text();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "events.h"
|
||||
#include "haptics.h"
|
||||
#include <ion/events.h>
|
||||
#include <layout_events.h>
|
||||
#include <SDL.h>
|
||||
|
||||
namespace Ion {
|
||||
@@ -17,21 +16,17 @@ char * sharedExternalTextBuffer() {
|
||||
}
|
||||
|
||||
const char * Event::text() const {
|
||||
if (m_id >= 4*PageSize) {
|
||||
if (*this == ExternalText) {
|
||||
return const_cast<const char *>(sharedExternalTextBuffer());
|
||||
}
|
||||
return nullptr;
|
||||
if (*this == ExternalText) {
|
||||
return const_cast<const char *>(sharedExternalTextBuffer());
|
||||
}
|
||||
return s_dataForEvent[m_id].text();
|
||||
return defaultText();
|
||||
}
|
||||
|
||||
bool Event::isDefined() const {
|
||||
if (isKeyboardEvent()) {
|
||||
return s_dataForEvent[m_id].isDefined();
|
||||
} else {
|
||||
return (*this == None || *this == Termination || *this == USBEnumeration || *this == USBPlug || *this == BatteryCharging || *this == ExternalText);
|
||||
if (*this == ExternalText) {
|
||||
return true;
|
||||
}
|
||||
return defaultIsDefined();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user