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++ -*-
* 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
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#include <Kaleidoscope-HostOS.h>
#include <Kaleidoscope/HostOS-select.h>
// *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(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_skip),
};
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(HostOS);
void setup() {
Serial.begin(9600);
Kaleidoscope.use(&HostOS);
Kaleidoscope.setup();
Serial.print("Host OS id is: ");

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* 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
* it under the terms of the GNU General Public License as published by
@ -24,22 +24,24 @@
namespace kaleidoscope {
namespace hostos {
void Base::begin(void) {
EventHandlerResult Base::onSetup(void) {
if (is_configured_)
return;
return EventHandlerResult::OK;
eeprom_slice_ = ::EEPROMSettings.requestSlice(sizeof(os_));
is_configured_ = true;
if (os_ != AUTO) {
return;
return EventHandlerResult::OK;
}
if ((os_ = (Type)EEPROM.read(eeprom_slice_)) != AUTO)
return;
return EventHandlerResult::OK;
autoDetect();
return EventHandlerResult::OK;
}
Type Base::os(void) {
@ -69,5 +71,12 @@ bool Base::focusHook(const char *command) {
return true;
}
// Legacy V1 API
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void Base::begin() {
::HostOS.onSetup();
}
#endif
}
}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* 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
* it under the terms of the GNU General Public License as published by
@ -32,9 +32,9 @@ typedef enum {
AUTO = 0xff,
} Type;
class Base : public KaleidoscopePlugin {
class Base : public kaleidoscope::Plugin {
public:
void begin(void) final;
EventHandlerResult onSetup();
Type os(void);
void os(Type new_os);
@ -45,6 +45,10 @@ class Base : public KaleidoscopePlugin {
virtual void autoDetect(void) {}
Type os_;
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void begin();
#endif
private:
uint16_t eeprom_slice_;
bool is_configured_ = false;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* 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
* it under the terms of the GNU General Public License as published by
@ -23,9 +23,6 @@
namespace kaleidoscope {
namespace hostos {
Guesser::Guesser(void) {
}
void Guesser::autoDetect(void) {
Serial.begin(9600);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* 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
* it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ namespace hostos {
class Guesser : public Base {
public:
Guesser(void);
Guesser(void) {}
protected:
void autoDetect(void) final;

Loading…
Cancel
Save