mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Added an event to represent the typing of text that is not on the device's keyboard. ExternalText event's text is read from a buffer, that will be filled when the event is generated. ExternalText only exists on the simulator. Change-Id: Ie78d2c7c2de91da986a1ce2130a5ecd123db48ee
39 lines
799 B
C++
39 lines
799 B
C++
#include "events.h"
|
|
#include "haptics.h"
|
|
#include <ion/events.h>
|
|
#include <layout_events.h>
|
|
#include <SDL.h>
|
|
|
|
namespace Ion {
|
|
namespace Events {
|
|
|
|
void didPressNewKey() {
|
|
Simulator::Haptics::rumble();
|
|
}
|
|
|
|
char * sharedExternalTextBuffer() {
|
|
static char buffer[32];
|
|
return buffer;
|
|
}
|
|
|
|
const char * Event::text() const {
|
|
if (m_id >= 4*PageSize) {
|
|
if (*this == ExternalText) {
|
|
return const_cast<const char *>(sharedExternalTextBuffer());
|
|
}
|
|
return nullptr;
|
|
}
|
|
return s_dataForEvent[m_id].text();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|