[ion/simulator] Rename the events_platform file

This commit is contained in:
Romain Goyet
2020-09-04 13:57:36 -04:00
committed by Léa Saviot
parent cbc3951ab1
commit d4984722cf
5 changed files with 13 additions and 132 deletions

View File

@@ -0,0 +1,11 @@
#include <ion/events.h>
namespace Ion {
namespace Events {
Event getPlatformEvent() {
return None;
}
}
}

View File

@@ -14,14 +14,14 @@ ion_src += $(addprefix ion/src/shared/dummy/, \
)
ion_src += $(addprefix ion/src/simulator/shared/, \
dummy/events_platform.cpp:+headless \
dummy/keyboard.cpp:+headless \
clipboard.cpp \
console_stdio.cpp:-consoledisplay \
crc32.cpp \
display.cpp:-headless \
events.cpp \
events_keyboard.cpp:-headless \
events_stdin.cpp:+headless \
events_platform.cpp:-headless \
framebuffer_base.cpp \
framebuffer_png.cpp:+headless \
keyboard.cpp:-headless \

View File

@@ -5,15 +5,6 @@
#include <SDL.h>
namespace Ion {
namespace Simulator {
namespace Events {
void dumpEventCount(int i);
void logAfter(int numberOfEvents);
}
}
namespace Events {
static constexpr size_t sharedExternalTextBufferSize = sizeof(SDL_TextInputEvent::text);

View File

@@ -9,60 +9,6 @@
#include <SDL.h>
#include <string.h>
#if EPSILON_SDL_SCREEN_ONLY
template<typename T, int N>
class Queue {
public:
Queue() : m_first(&m_elements[0]), m_last(&m_elements[0]) {}
int size() {
if (m_last >= m_first) {
return m_last - m_first;
} else {
return m_last - (m_first - N);
}
}
void enqueue(T element) {
if (size() > N) {
// Queue is full
return;
}
*m_last = element;
m_last = next(m_last);
}
T dequeue() {
if (size() <= 0) {
// Dequeueing an empty queue
return T();
}
T e = *m_first;
m_first = next(m_first);
return e;
}
private:
T * next(T * p) {
if (p >= m_elements + N) {
return m_elements;
} else {
return p + 1;
}
}
T * m_first;
T * m_last;
T m_elements[N];
};
static Queue<Ion::Events::Event, 1024> sEventQueue;
void IonSimulatorEventsPushEvent(int eventNumber) {
sEventQueue.enqueue(Ion::Events::Event(eventNumber));
}
#endif
namespace Ion {
namespace Events {
@@ -172,12 +118,6 @@ static Event eventFromSDLTextInputEvent(SDL_TextInputEvent event) {
}
Event getPlatformEvent() {
#if EPSILON_SDL_SCREEN_ONLY
if (sEventQueue.size() > 0) {
Event event = sEventQueue.dequeue();
return event;
}
#endif
SDL_Event event;
Event result = None;
while (SDL_PollEvent(&event)) {

View File

@@ -1,61 +0,0 @@
#include "platform.h"
#include "framebuffer.h"
#include "events.h"
#include <ion/events.h>
#include <layout_events.h>
#include <string.h>
#include <stdio.h>
void IonSimulatorEventsPushEvent(int eventNumber) {
}
static int sLogAfterNumberOfEvents = -1;
static int sEventCount = 0;
namespace Ion {
namespace Events {
Event getPlatformEvent() {
Ion::Events::Event event = Ion::Events::None;
while (!(event.isDefined() && event.isKeyboardEvent())) {
int c = getchar();
if (c == EOF) {
printf("Finished processing %d events\n", sEventCount);
event = Ion::Events::Termination;
break;
}
event = Ion::Events::Event(c);
}
#if EPSILON_SIMULATOR_HAS_LIBPNG
if (sEventCount++ > sLogAfterNumberOfEvents && sLogAfterNumberOfEvents >= 0) {
char filename[32];
sprintf(filename, "event%d.png", sEventCount);
Ion::Simulator::Framebuffer::writeToFile(filename);
#ifndef NDEBUG
printf("Event %d is %s\n", sEventCount, event.name());
#endif
}
#endif
return event;
}
}
}
namespace Ion {
namespace Simulator {
namespace Events {
void dumpEventCount(int i) {
printf("Current event index: %d\n", sEventCount);
}
void logAfter(int numberOfEvents) {
sLogAfterNumberOfEvents = numberOfEvents;
}
}
}
}