mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[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
This commit is contained in:
committed by
Émilie Feral
parent
65156c8e5a
commit
96b8e1859a
@@ -229,6 +229,9 @@ constexpr Event TimerFire = Event::Special(2);
|
||||
constexpr Event USBEnumeration = Event::Special(3);
|
||||
constexpr Event USBPlug = Event::Special(4);
|
||||
constexpr Event BatteryCharging = Event::Special(5);
|
||||
/* This event is only used in the simulator, to handle text that cannot be
|
||||
* associated with a key. */
|
||||
// constexpr Event ExternalText = Event::Special(6);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <ion/events.h>
|
||||
#include <layout_events.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Events {
|
||||
@@ -6,5 +7,20 @@ namespace Events {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
const char * Event::text() const {
|
||||
if (m_id >= 4*PageSize) {
|
||||
return nullptr;
|
||||
}
|
||||
return s_dataForEvent[m_id].text();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,24 +48,9 @@ Event::Event(Keyboard::Key key, bool shift, bool alpha, bool lock) {
|
||||
assert(m_id != Events::None.m_id);
|
||||
}
|
||||
|
||||
const char * Event::text() const {
|
||||
if (m_id >= 4*PageSize) {
|
||||
return nullptr;
|
||||
}
|
||||
return s_dataForEvent[m_id].text();
|
||||
}
|
||||
|
||||
bool Event::hasText() const {
|
||||
return text() != nullptr;
|
||||
}
|
||||
|
||||
bool Event::isDefined() const {
|
||||
if (isKeyboardEvent()) {
|
||||
return s_dataForEvent[m_id].isDefined();
|
||||
} else {
|
||||
return (*this == None || *this == Termination || *this == USBEnumeration || *this == USBPlug || *this == BatteryCharging);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <ion/events.h>
|
||||
#include "events.h"
|
||||
#include "haptics.h"
|
||||
#include <ion/events.h>
|
||||
#include <layout_events.h>
|
||||
#include <SDL.h>
|
||||
|
||||
namespace Ion {
|
||||
@@ -9,5 +11,28 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef ION_SIMULATOR_EVENTS_H
|
||||
#define ION_SIMULATOR_EVENTS_H
|
||||
|
||||
#include <ion/events.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Simulator {
|
||||
namespace Events {
|
||||
@@ -9,6 +11,13 @@ void dumpEventCount(int i);
|
||||
void logAfter(int numberOfEvents);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace Events {
|
||||
|
||||
char * sharedExternalTextBuffer();
|
||||
constexpr Event ExternalText = Event::Special(6);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user