diff --git a/README.md b/README.md index fb1d1d90..f1238be4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ the `HostOS` library header. #include #include +#include void someFunction (void) { if (HostOS.os() == Kaleidoscope::HostOS::LINUX) { @@ -55,6 +56,9 @@ void setup (void) { } ``` +To be able to choose between the two variants, one must also include the +`Kaleidoscope/HostOS-select.h` header. + ## Extension methods The extension provides the following methods on the `HostOS` singleton: diff --git a/examples/HostOS/HostOS.ino b/examples/HostOS/HostOS.ino index f49471f0..40fa0530 100644 --- a/examples/HostOS/HostOS.ino +++ b/examples/HostOS/HostOS.ino @@ -17,6 +17,7 @@ */ #include +#include const Key keymaps[][ROWS][COLS] PROGMEM = { [0] = KEYMAP_STACKED diff --git a/src/Kaleidoscope-HostOS.h b/src/Kaleidoscope-HostOS.h index e7c8cb06..3c0126a1 100644 --- a/src/Kaleidoscope-HostOS.h +++ b/src/Kaleidoscope-HostOS.h @@ -18,12 +18,7 @@ #pragma once -#include -#include +#include #include -#ifdef KALEIDOSCOPE_HOSTOS_GUESSER -extern KaleidoscopePlugins::HostOS::Guesser HostOS; -#else -extern KaleidoscopePlugins::HostOS::Tracker HostOS; -#endif +extern KaleidoscopePlugins::HostOS::Base HostOS; diff --git a/src/Kaleidoscope/HostOS.cpp b/src/Kaleidoscope/HostOS-Base.cpp similarity index 97% rename from src/Kaleidoscope/HostOS.cpp rename to src/Kaleidoscope/HostOS-Base.cpp index eca19df1..67980733 100644 --- a/src/Kaleidoscope/HostOS.cpp +++ b/src/Kaleidoscope/HostOS-Base.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include +#include #include #include diff --git a/src/Kaleidoscope/HostOS.h b/src/Kaleidoscope/HostOS-Base.h similarity index 96% rename from src/Kaleidoscope/HostOS.h rename to src/Kaleidoscope/HostOS-Base.h index 1ac9e721..20de6012 100644 --- a/src/Kaleidoscope/HostOS.h +++ b/src/Kaleidoscope/HostOS-Base.h @@ -39,7 +39,7 @@ namespace KaleidoscopePlugins { void os (Type osType); protected: - virtual void autoDetect (void) = 0; + virtual void autoDetect (void) {}; Type osType; private: diff --git a/src/Kaleidoscope/HostOS-Guesser.cpp b/src/Kaleidoscope/HostOS-Guesser.cpp index dc2dd196..f9c01184 100644 --- a/src/Kaleidoscope/HostOS-Guesser.cpp +++ b/src/Kaleidoscope/HostOS-Guesser.cpp @@ -48,5 +48,3 @@ namespace KaleidoscopePlugins { } }; }; - -KaleidoscopePlugins::HostOS::Guesser HostOS; diff --git a/src/Kaleidoscope/HostOS-Guesser.h b/src/Kaleidoscope/HostOS-Guesser.h index 6b634bc0..c529024a 100644 --- a/src/Kaleidoscope/HostOS-Guesser.h +++ b/src/Kaleidoscope/HostOS-Guesser.h @@ -18,7 +18,7 @@ #pragma once -#include +#include namespace KaleidoscopePlugins { namespace HostOS { diff --git a/src/Kaleidoscope/HostOS-Tracker.cpp b/src/Kaleidoscope/HostOS-Tracker.cpp deleted file mode 100644 index 5c2007c1..00000000 --- a/src/Kaleidoscope/HostOS-Tracker.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- mode: c++ -*- - * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope - * Copyright (C) 2016, 2017 Gergely Nagy - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -KaleidoscopePlugins::HostOS::Tracker HostOS; diff --git a/src/Kaleidoscope/HostOS-Tracker.h b/src/Kaleidoscope/HostOS-select.h similarity index 76% rename from src/Kaleidoscope/HostOS-Tracker.h rename to src/Kaleidoscope/HostOS-select.h index 090908d3..a80de9c0 100644 --- a/src/Kaleidoscope/HostOS-Tracker.h +++ b/src/Kaleidoscope/HostOS-select.h @@ -18,16 +18,11 @@ #pragma once -#include +#include +#include -namespace KaleidoscopePlugins { - namespace HostOS { - class Tracker : public Base { - public: - Tracker (void) {}; - - protected: - virtual void autoDetect (void) final {}; - }; - }; -}; +#if KALEIDOSCOPE_HOSTOS_GUESSER +KaleidoscopePlugins::HostOS::Base HostOS = KaleidoscopePlugins::HostOS::Guesser(); +#else +KaleidoscopePlugins::HostOS::Base HostOS; +#endif