Files
Upsilon/ion/src/simulator/shared/events.cpp
Gabriel Ozouf 96b8e1859a [ion/events] Create event ExternalText
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
2020-11-04 15:58:28 +01:00

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);
}
}
}
}