Updated to use the new plugin APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 6 years ago
parent c56c7791ba
commit 19cffca5c4

@ -22,10 +22,11 @@ configuration is necessary, unless one wants to perform custom actions.
#include <Kaleidoscope.h>
#include <Kaleidoscope-HostPowerManagement.h>
KALEIDOSCOPE_INIT_PLUGINS(HostPowerManagement);
void setup () {
Kaleidoscope.setup ();
Kaleidoscope.use(&HostPowerManagement);
HostPowerManagement.enableWakeup();
}
```

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 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
@ -20,6 +20,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-HostPowerManagement.h>
// *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
@ -33,14 +34,14 @@ 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_NoKey
),
};
// *INDENT-ON*
void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) {
switch (event) {
@ -58,11 +59,12 @@ void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event ev
}
}
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
HostPowerManagement);
void setup() {
Kaleidoscope.setup();
Kaleidoscope.use(&HostPowerManagement);
HostPowerManagement.enableWakeup();
}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 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
@ -29,14 +29,7 @@ namespace kaleidoscope {
bool HostPowerManagement::was_suspended_ = false;
bool HostPowerManagement::initial_suspend_ = true;
void HostPowerManagement::begin(void) {
Kaleidoscope.useLoopHook(loopHook);
}
void HostPowerManagement::loopHook(bool post_clear) {
if (post_clear)
return;
EventHandlerResult HostPowerManagement::beforeEachCycle() {
if ((_usbSuspendState & (1 << SUSPI))) {
if (!initial_suspend_) {
if (!was_suspended_) {
@ -54,7 +47,23 @@ void HostPowerManagement::loopHook(bool post_clear) {
hostPowerManagementEventHandler(Resume);
}
}
return EventHandlerResult::OK;
}
// Legacy V1 API
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void HostPowerManagement::begin() {
Kaleidoscope.useLoopHook(legacyLoopHook);
}
void HostPowerManagement::legacyLoopHook(bool is_post_clear) {
if (is_post_clear)
return;
::HostPowerManagement.beforeEachCycle();
}
#endif
}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 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
@ -22,7 +22,7 @@
#include "WakeupKeyboard.h"
namespace kaleidoscope {
class HostPowerManagement : public KaleidoscopePlugin {
class HostPowerManagement : public kaleidoscope::Plugin {
public:
typedef enum {
Suspend,
@ -30,18 +30,23 @@ class HostPowerManagement : public KaleidoscopePlugin {
Resume,
} Event;
HostPowerManagement(void) {};
HostPowerManagement(void) {}
void begin(void) final;
void enableWakeup(void) {
WakeupKeyboard.begin();
};
WakeupKeyboard.init();
}
EventHandlerResult beforeEachCycle();
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
protected:
void begin();
static void legacyLoopHook(bool is_post_clear);
#endif
private:
static bool was_suspended_;
static bool initial_suspend_;
static void loopHook(bool post_clear);
};
}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy
* Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 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
@ -85,7 +85,7 @@ bool WakeupKeyboard_::setup(USBSetup& setup) {
return false;
}
void WakeupKeyboard_::begin() {
void WakeupKeyboard_::init() {
}
WakeupKeyboard_ WakeupKeyboard;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy
* Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 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
@ -22,10 +22,10 @@
#include "PluggableUSB.h"
#include "HID.h"
class WakeupKeyboard_ : public PluggableUSBModule, public KaleidoscopePlugin {
class WakeupKeyboard_ : public PluggableUSBModule, public kaleidoscope::Plugin {
public:
WakeupKeyboard_(void);
void begin() final;
void init();
protected:
int getInterface(uint8_t* interfaceCount);

Loading…
Cancel
Save