Updated to use the new plugin APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/389/head
Gergely Nagy 6 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,
@ -31,18 +32,19 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
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