From 2aa1cb02560e64ded4f33f29afef2eff090e1844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 16 Nov 2017 18:13:18 +0100 Subject: [PATCH] [emscripten] Fixed Python computation interruption. A dummy scan() was used, which stopped the computation with shouldInterrupt(). Change-Id: I661a630bd1a83c6036513fb9a086c58ba542f25b --- ion/src/emscripten/Makefile | 1 - ion/src/emscripten/events_keyboard.cpp | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ion/src/emscripten/Makefile b/ion/src/emscripten/Makefile index d73bc76fe..fd96cadd0 100644 --- a/ion/src/emscripten/Makefile +++ b/ion/src/emscripten/Makefile @@ -12,7 +12,6 @@ objs += $(addprefix ion/src/shared/, \ dummy/backlight.o \ dummy/battery.o \ dummy/fcc_id.o \ - dummy/keyboard.o \ dummy/led.o \ dummy/serial_number.o \ dummy/usb.o \ diff --git a/ion/src/emscripten/events_keyboard.cpp b/ion/src/emscripten/events_keyboard.cpp index 3cc7deaf2..d8fb4fa9d 100644 --- a/ion/src/emscripten/events_keyboard.cpp +++ b/ion/src/emscripten/events_keyboard.cpp @@ -11,6 +11,22 @@ void IonEventsEmscriptenPushEvent(int eventNumber) { sEvent = Ion::Events::Event((Ion::Keyboard::Key)eventNumber, Ion::Events::isShiftActive(), Ion::Events::isAlphaActive()); } +Ion::Keyboard::State Ion::Keyboard::scan() { + // FIXME + // On the Emscripten platform, scan() is used in : + // - shouldInterrupt(), from interruptHelper.h + // - apps_container.cpp + // - apps/hardware_test/keyboard_test_controller.cpp + // We would like to check if there is a Back event that would interrupt the + // Python or Poincare computation, but it is quite difficult to get because + // the runLoop is blocking in JavaScript and Events do not get pushed in + // sEvent. + // We still need to override the dummy/events_keyboard.cpp function, which + // returns that all keys are always pressed and thus interrupts Python + // computations after 20000 calls. + return 0; +} + namespace Ion { namespace Events { @@ -50,7 +66,7 @@ Event getEvent(int * timeout) { case SDLK_RIGHT: return Ion::Events::Right; case SDLK_RETURN: - return Ion::Events::OK; + return Ion::Events::EXE; case SDLK_ESCAPE: return Ion::Events::Back; case SDLK_BACKSPACE: