aboutsummaryrefslogtreecommitdiff
path: root/Model01-Firmware.ino
blob: fdb512f361c380d0864c73f4c540b424a3cbed11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// -*- mode: c++ -*- 
 
#ifndef BUILD_INFORMATION
#define BUILD_INFORMATION "locally built"
#endif
 
#include "Kaleidoscope.h"
#include "Kaleidoscope-EEPROM-Settings.h"
#include "Kaleidoscope-FocusSerial.h"
#include "Kaleidoscope-MouseKeys.h"
#include "Kaleidoscope-Macros.h"
#include "Kaleidoscope-LEDControl.h"
#include "Kaleidoscope-LEDEffect-BootGreeting.h"
#include "Kaleidoscope-Model01-TestMode.h"
#include "Kaleidoscope-HostPowerManagement.h"
#include "Kaleidoscope-MagicCombo.h"
#include "Kaleidoscope-USB-Quirks.h"
 
enum { MACRO_VERSION_INFO,
       MACRO_ANY
     };
 
#include "keymap-wrapper.h"
 
#include "color-themes.h"
 
static DakkarColor DakkarColorDark(color_keymaps,dark_colors);
static DakkarColor DakkarColorBright(color_keymaps,bright_colors);
 
static void versionInfoMacro(uint8_t keyState) {
  if (keyToggledOn(keyState)) {
    Macros.type(PSTR("Keyboardio Model 01 - Kaleidoscope "));
    Macros.type(PSTR(BUILD_INFORMATION));
  }
}
 
static void anyKeyMacro(uint8_t keyState) {
  static Key lastKey;
  bool toggledOn = false;
  if (keyToggledOn(keyState)) {
    lastKey.keyCode = Key_A.keyCode + (uint8_t)(millis() % 36);
    toggledOn = true;
  }
 
  if (keyIsPressed(keyState))
    kaleidoscope::hid::pressKey(lastKey, toggledOn);
}
 
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
  switch (macroIndex) {
 
  case MACRO_VERSION_INFO:
    versionInfoMacro(keyState);
    break;
 
  case MACRO_ANY:
    anyKeyMacro(keyState);
    break;
  }
  return MACRO_NONE;
}
 
 
void toggleLedsOnSuspendResume(kaleidoscope::plugin::HostPowerManagement::Event event) {
  switch (event) {
  case kaleidoscope::plugin::HostPowerManagement::Suspend:
    LEDControl.set_all_leds_to({000});
    LEDControl.syncLeds();
    LEDControl.paused = true;
    break;
  case kaleidoscope::plugin::HostPowerManagement::Resume:
    LEDControl.paused = false;
    LEDControl.refreshAll();
    break;
  case kaleidoscope::plugin::HostPowerManagement::Sleep:
    break;
  }
}
 
void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) {
  toggleLedsOnSuspendResume(event);
}
 
enum {
  // Toggle between Boot (6-key rollover; for BIOSes and early boot) and NKRO 
  // mode. 
  COMBO_TOGGLE_NKRO_MODE
};
 
static void toggleKeyboardProtocol(uint8_t combo_index) {
  USBQuirks.toggleKeyboardProtocol();
}
 
USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
                  // Left Fn + Esc + Shift 
                  .keys = { R3C6, R2C6, R3C7 }
                 });
 
KALEIDOSCOPE_INIT_PLUGINS(
  EEPROMSettings,
 
  Focus,
  FocusSettingsCommand,
  FocusEEPROMCommand,
 
  BootGreetingEffect,
 
  TestMode,
 
  LEDControl,
  DakkarColorDark, DakkarColorBright,
 
  Macros,
  MouseKeys,
  HostPowerManagement,
  MagicCombo,
  USBQuirks
);
 
void setup() {
  Kaleidoscope.setup();
  DakkarColorDark.activate();
}
 
void loop() {
  Kaleidoscope.loop();
}