wip: Executor -> Simulator

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/851/head
Gergely Nagy 4 years ago
parent 8bd2efb9c7
commit 59aa18aca8
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -19,6 +19,6 @@
#pragma once #pragma once
#include "kaleidoscope/simulator/Executor.h" #include "kaleidoscope/simulator/Simulator.h"
#include "kaleidoscope/simulator/macros.h" #include "kaleidoscope/simulator/macros.h"
#include "kaleidoscope/simulator/LogProtocolInterface.h" #include "kaleidoscope/simulator/LogProtocolInterface.h"

@ -18,7 +18,7 @@
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#include "kaleidoscope/simulator/Executor.h" #include "kaleidoscope/simulator/Simulator.h"
#include "kaleidoscope/simulator/SimulatorCore.h" #include "kaleidoscope/simulator/SimulatorCore.h"
#include "kaleidoscope/simulator/reports/KeyboardReport.h" #include "kaleidoscope/simulator/reports/KeyboardReport.h"
#include "kaleidoscope/simulator/reports/BootKeyboardReport.h" #include "kaleidoscope/simulator/reports/BootKeyboardReport.h"
@ -33,26 +33,26 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
Executor::Executor(std::ostream &out) : interface::Simulator_{out} { Simulator::Simulator(std::ostream &out) : interface::Simulator_{out} {
this->setCore( this->setCore(
std::shared_ptr<SimulatorCore> { std::shared_ptr<SimulatorCore> {
new SimulatorCore{} new SimulatorCore{}
} }
); );
HIDReportObserver::resetHook(&Executor::processHIDReport); HIDReportObserver::resetHook(&Simulator::processHIDReport);
Kaleidoscope.device().keyScanner().setEnableReadMatrix(false); Kaleidoscope.device().keyScanner().setEnableReadMatrix(false);
} }
Executor &Executor::getInstance() { Simulator &Simulator::getInstance() {
static Executor sim{std::cout}; static Simulator sim{std::cout};
return sim; return sim;
} }
void Executor::processHIDReport(uint8_t id, const void* data, void Simulator::processHIDReport(uint8_t id, const void* data,
int len, int result) { int len, int result) {
auto &simulator = Executor::getInstance(); auto &simulator = Simulator::getInstance();
switch (id) { switch (id) {
// TODO: React appropriately on the following // TODO: React appropriately on the following

@ -32,16 +32,16 @@ namespace simulator {
/// @brief A Kaleidoscope specific simulator class. /// @brief A Kaleidoscope specific simulator class.
/// ///
class Executor : public interface::Simulator_ { class Simulator: public interface::Simulator_ {
public: public:
/// @brief Access the global simulator singleton. /// @brief Access the global simulator singleton.
/// ///
static Executor &getInstance(); static Simulator &getInstance();
private: private:
Executor(std::ostream &out); Simulator(std::ostream &out);
static void processHIDReport(uint8_t id, const void* data, static void processHIDReport(uint8_t id, const void* data,
int len, int result); int len, int result);

@ -40,7 +40,7 @@ uint8_t toKeycode(Key key) {
} // namespace kaleidoscope } // namespace kaleidoscope
#include "kaleidoscope/simulator/Interface.h" #include "kaleidoscope/simulator/Interface.h"
#include "kaleidoscope/simulator/Executor.h" #include "kaleidoscope/simulator/Simulator.h"
#include "kaleidoscope/simulator/LogProtocolInterface.h" #include "kaleidoscope/simulator/LogProtocolInterface.h"
#include "kaleidoscope/simulator/interface/Visualization.h" #include "kaleidoscope/simulator/interface/Visualization.h"
@ -61,7 +61,7 @@ extern void executeTestFunction();
namespace kaleidoscope { \ namespace kaleidoscope { \
namespace simulator { \ namespace simulator { \
/* Forward declare the actual test function */ \ /* Forward declare the actual test function */ \
void runSimulator(Executor &simulator); \ void runSimulator(Simulator &simulator); \
} /* namespace simulator */ \ } /* namespace simulator */ \
} /* namespace kaleidoscope */ \ } /* namespace kaleidoscope */ \
\ \
@ -71,5 +71,5 @@ extern void executeTestFunction();
void executeTestFunction() { \ void executeTestFunction() { \
setup(); /* setup Kaleidoscope */ \ setup(); /* setup Kaleidoscope */ \
using namespace kaleidoscope::simulator; \ using namespace kaleidoscope::simulator; \
runSimulator(Executor::getInstance()); \ runSimulator(Simulator::getInstance()); \
} }

@ -23,7 +23,7 @@ KALEIDOSCOPE_SIMULATOR_INIT
namespace kaleidoscope { namespace kaleidoscope {
namespace simulator { namespace simulator {
void runSimulator(Executor &simulator) { void runSimulator(Simulator &simulator) {
using namespace actions; using namespace actions;
using namespace interface; using namespace interface;

@ -28,7 +28,7 @@ namespace simulator {
extern const char aglais_test_recording[]; extern const char aglais_test_recording[];
void runSimulator(Executor &simulator) { void runSimulator(Simulator &simulator) {
using namespace actions; using namespace actions;

Loading…
Cancel
Save