From e7e7fe75fe6c1b9ff5c79a4441a6500a8c390159 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 31 Mar 2022 20:38:55 +0200 Subject: [PATCH] Runtime: Initialize the hardware first at setup time Before doing anything else, initialize the device, so that whatever the rest of the hooks we'll call do, they'll be able to rely on an initialized device. Thanks to @obra for catching this, and proposing the patch! Signed-off-by: Gergely Nagy --- src/kaleidoscope/Runtime.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kaleidoscope/Runtime.cpp b/src/kaleidoscope/Runtime.cpp index 2a958cb4..0618a4f0 100644 --- a/src/kaleidoscope/Runtime.cpp +++ b/src/kaleidoscope/Runtime.cpp @@ -37,6 +37,11 @@ Runtime_::Runtime_(void) { // ---------------------------------------------------------------------------- void Runtime_::setup(void) { + // Before doing anything else, initialize the device, so that whatever the + // rest of the hooks we'll call do, they'll be able to rely on an initialized + // device. + device().setup(); + // We are explicitly initializing the Serial port as early as possible to // (temporarily, hopefully) work around an issue on OSX. If we initialize // Serial too late, no matter what we do, we'll end up reading garbage from @@ -50,8 +55,6 @@ void Runtime_::setup(void) { kaleidoscope::sketch_exploration::pluginsExploreSketch(); kaleidoscope::Hooks::onSetup(); - device().setup(); - // Clear the keyboard state array (all keys idle at start) live_keys.clear();