From d4984722cf37c5606e5882219f8eb6eb925b2216 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 4 Sep 2020 13:57:36 -0400 Subject: [PATCH] [ion/simulator] Rename the events_platform file --- ion/src/shared/dummy/events_platform.cpp | 11 ++++ ion/src/simulator/Makefile | 4 +- ion/src/simulator/shared/events.h | 9 --- ...vents_keyboard.cpp => events_platform.cpp} | 60 ------------------ ion/src/simulator/shared/events_stdin.cpp | 61 ------------------- 5 files changed, 13 insertions(+), 132 deletions(-) create mode 100644 ion/src/shared/dummy/events_platform.cpp rename ion/src/simulator/shared/{events_keyboard.cpp => events_platform.cpp} (83%) delete mode 100644 ion/src/simulator/shared/events_stdin.cpp diff --git a/ion/src/shared/dummy/events_platform.cpp b/ion/src/shared/dummy/events_platform.cpp new file mode 100644 index 000000000..a0b1c6cd8 --- /dev/null +++ b/ion/src/shared/dummy/events_platform.cpp @@ -0,0 +1,11 @@ +#include + +namespace Ion { +namespace Events { + +Event getPlatformEvent() { + return None; +} + +} +} diff --git a/ion/src/simulator/Makefile b/ion/src/simulator/Makefile index af814cf74..dff72a250 100644 --- a/ion/src/simulator/Makefile +++ b/ion/src/simulator/Makefile @@ -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 \ diff --git a/ion/src/simulator/shared/events.h b/ion/src/simulator/shared/events.h index 1770c40ba..131df3807 100644 --- a/ion/src/simulator/shared/events.h +++ b/ion/src/simulator/shared/events.h @@ -5,15 +5,6 @@ #include 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); diff --git a/ion/src/simulator/shared/events_keyboard.cpp b/ion/src/simulator/shared/events_platform.cpp similarity index 83% rename from ion/src/simulator/shared/events_keyboard.cpp rename to ion/src/simulator/shared/events_platform.cpp index 026394050..072b3bc2b 100644 --- a/ion/src/simulator/shared/events_keyboard.cpp +++ b/ion/src/simulator/shared/events_platform.cpp @@ -9,60 +9,6 @@ #include #include -#if EPSILON_SDL_SCREEN_ONLY - -template -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 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)) { diff --git a/ion/src/simulator/shared/events_stdin.cpp b/ion/src/simulator/shared/events_stdin.cpp deleted file mode 100644 index ed6ed79b1..000000000 --- a/ion/src/simulator/shared/events_stdin.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "platform.h" -#include "framebuffer.h" -#include "events.h" - -#include -#include - -#include -#include - -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; -} - -} -} -}