Updated to use the new plugin APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/389/head
Gergely Nagy 7 years ago
parent 052cef8488
commit 6b1745f339

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
* Copyright (C) 2016, 2017 Gergely Nagy * Copyright (C) 2016, 2017, 2018 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#include <Kaleidoscope-HostOS.h> #include <Kaleidoscope-HostOS.h>
#include <Kaleidoscope/HostOS-select.h> #include <Kaleidoscope/HostOS-select.h>
// *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,12 +38,13 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip), Key_skip),
}; };
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(HostOS);
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
Kaleidoscope.use(&HostOS);
Kaleidoscope.setup(); Kaleidoscope.setup();
Serial.print("Host OS id is: "); Serial.print("Host OS id is: ");

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
* Copyright (C) 2016, 2017 Gergely Nagy * Copyright (C) 2016, 2017, 2018 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,22 +24,24 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace hostos { namespace hostos {
void Base::begin(void) { EventHandlerResult Base::onSetup(void) {
if (is_configured_) if (is_configured_)
return; return EventHandlerResult::OK;
eeprom_slice_ = ::EEPROMSettings.requestSlice(sizeof(os_)); eeprom_slice_ = ::EEPROMSettings.requestSlice(sizeof(os_));
is_configured_ = true; is_configured_ = true;
if (os_ != AUTO) { if (os_ != AUTO) {
return; return EventHandlerResult::OK;
} }
if ((os_ = (Type)EEPROM.read(eeprom_slice_)) != AUTO) if ((os_ = (Type)EEPROM.read(eeprom_slice_)) != AUTO)
return; return EventHandlerResult::OK;
autoDetect(); autoDetect();
return EventHandlerResult::OK;
} }
Type Base::os(void) { Type Base::os(void) {
@ -69,5 +71,12 @@ bool Base::focusHook(const char *command) {
return true; return true;
} }
// Legacy V1 API
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void Base::begin() {
::HostOS.onSetup();
}
#endif
} }
} }

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
* Copyright (C) 2016, 2017 Gergely Nagy * Copyright (C) 2016, 2017, 2018 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,9 +32,9 @@ typedef enum {
AUTO = 0xff, AUTO = 0xff,
} Type; } Type;
class Base : public KaleidoscopePlugin { class Base : public kaleidoscope::Plugin {
public: public:
void begin(void) final; EventHandlerResult onSetup();
Type os(void); Type os(void);
void os(Type new_os); void os(Type new_os);
@ -45,6 +45,10 @@ class Base : public KaleidoscopePlugin {
virtual void autoDetect(void) {} virtual void autoDetect(void) {}
Type os_; Type os_;
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void begin();
#endif
private: private:
uint16_t eeprom_slice_; uint16_t eeprom_slice_;
bool is_configured_ = false; bool is_configured_ = false;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
* Copyright (C) 2016, 2017 Gergely Nagy * Copyright (C) 2016, 2017, 2018 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,9 +23,6 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace hostos { namespace hostos {
Guesser::Guesser(void) {
}
void Guesser::autoDetect(void) { void Guesser::autoDetect(void) {
Serial.begin(9600); Serial.begin(9600);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope * Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
* Copyright (C) 2016, 2017 Gergely Nagy * Copyright (C) 2016, 2017, 2018 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ namespace hostos {
class Guesser : public Base { class Guesser : public Base {
public: public:
Guesser(void); Guesser(void) {}
protected: protected:
void autoDetect(void) final; void autoDetect(void) final;

Loading…
Cancel
Save