diff --git a/keyboards/clueboard/2x1800/2019/2019.c b/keyboards/clueboard/2x1800/2019/2019.c
index b37af334b2..02ae78ba33 100644
--- a/keyboards/clueboard/2x1800/2019/2019.c
+++ b/keyboards/clueboard/2x1800/2019/2019.c
@@ -17,46 +17,111 @@
#include "encoder.h"
void matrix_init_kb(void) {
- // Set our LED pins as output
- DDRB |= (1<<4); // Numlock
- DDRB |= (1<<5); // Capslock
- DDRB |= (1<<6); // Scroll Lock
+ // Set our LED pins as output
+ setPinOutput(B4);
+ setPinOutput(B5);
+ setPinOutput(B6);
- // Run the keymap level init
- matrix_init_user();
+ // Set our Tilt Sensor pins as input
+ setPinInputHigh(SHAKE_PIN_A);
+ setPinInputHigh(SHAKE_PIN_B);
+
+ // Run the keymap level init
+ matrix_init_user();
}
+#ifdef SHAKE_ENABLE
+uint8_t tilt_state[2] = {1,1};
+uint8_t detected_shakes = 0;
+static uint16_t shake_timer;
+#endif
+
void matrix_scan_kb(void) {
- matrix_scan_user();
+#ifdef SHAKE_ENABLE
+ // Read the current state of the tilt sensor. It is physically
+ // impossible for both pins to register a low state at the same time.
+ uint8_t tilt_read[2] = {readPin(SHAKE_PIN_A), readPin(SHAKE_PIN_B)};
+
+ // Check to see if the tilt sensor has changed state since our last read
+ for (uint8_t i = 0; i < 2; i++) {
+ if (tilt_state[i] != tilt_read[i]) {
+ shake_timer = timer_read();
+ detected_shakes++;
+ tilt_state[i] = tilt_read[i];
+ }
+ }
+
+ if ((detected_shakes > 0) && (timer_elapsed(shake_timer) > SHAKE_TIMEOUT)) {
+ if (detected_shakes > SHAKE_COUNT) {
+ dprintf("Shake detected! We had %d shakes detected.\n", detected_shakes);
+ tap_code16(SHAKE_KEY);
+ }
+ detected_shakes = 0;
+ }
+#endif
+
+ matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- return process_record_user(keycode, record);
+ return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
- // Toggle numlock as needed
- if (usb_led & (1<.
#define MATRIX_COL_PINS { D2, D3, D4, D5, D7, E0, E1, B0, E6, B3, B2 }
#define UNUSED_PINS { D0, D1, D6, C5, E7, F0, F1 }
-/*
#define NUMBER_OF_ENCODERS 4
-#define ENCODERS_PAD_A { A1, A0, A7, A5 }
-#define ENCODERS_PAD_B { A2, A3, A6, A4 }
-*/
-#define NUMBER_OF_ENCODERS 1
-#define ENCODERS_PAD_A { A1 }
-#define ENCODERS_PAD_B { A2 }
-#define ENCODER_RESOLUTION 2
+#define ENCODERS_PAD_A { A5, A4, A2, A1 }
+#define ENCODERS_PAD_B { A6, A7, A3, A0 }
+#define ENCODER_RESOLUTION 4
/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION ROW2COL
@@ -80,7 +75,7 @@ along with this program. If not, see .
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-#define RGB_DI_PIN C6
+#define RGB_DI_PIN C5
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 16
#define RGBLIGHT_HUE_STEP 8
@@ -203,3 +198,14 @@ along with this program. If not, see .
//#define MIDI_TONE_KEYCODE_OCTAVES 1
#endif
+
+/*
+ * Key to press when we do shake to undo.
+ */
+#define SHAKE_PIN_A E4
+#define SHAKE_PIN_B E5
+#define SHAKE_TIMEOUT 500 // How long after shaking stops before we register it
+#define SHAKE_COUNT 8 // How many shakes it takes to activate
+//#define SHAKE_KEY LGUI(KC_Z) // What key to send after a shake
+//#define SHAKE_KEY LCTL(KC_Z)
+#define SHAKE_KEY LGUI(KC_SLSH)
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default/keymap.c
index bbd834d4c3..7ebd14a35d 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default/keymap.c
@@ -17,7 +17,7 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_all( \
- KC_1, KC_2, KC_3, KC_4, \
+ KC_BTN1, KC_BTN2, KC_BTN3, KC_BTN4, \
KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS, KC_INS, \
\
KC_PMNS, KC_NLCK, KC_PSLS, KC_PAST, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, \
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_1u_ansi/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_1u_ansi/keymap.c
index d48bc729c1..80b2ef593c 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_1u_ansi/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_1u_ansi/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_1u_iso/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_1u_iso/keymap.c
index 310efd53f8..eb37b09fea 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_1u_iso/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_1u_iso/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_4u_ansi/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_4u_ansi/keymap.c
index 2504bdec49..f45d1e3540 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_4u_ansi/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_4u_ansi/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_4u_iso/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_4u_iso/keymap.c
index 45b459357d..ed3acccf05 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_4u_iso/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_4u_iso/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_7u_ansi/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_7u_ansi/keymap.c
index 3585247aaf..d866853afd 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_7u_ansi/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_7u_ansi/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LALT, KC_SPC, KC_LGUI, KC_APP, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/keymaps/default_7u_iso/keymap.c b/keyboards/clueboard/2x1800/2019/keymaps/default_7u_iso/keymap.c
index cda023bb1c..4b1120abd7 100644
--- a/keyboards/clueboard/2x1800/2019/keymaps/default_7u_iso/keymap.c
+++ b/keyboards/clueboard/2x1800/2019/keymaps/default_7u_iso/keymap.c
@@ -27,35 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_P0, KC_PDOT, KC_LEFT, KC_DOWN, KC_RGHT, KC_LCTL, KC_LALT, KC_SPC, KC_LGUI, KC_APP, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT \
)
};
-
-#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
- // Encoder 1, outside left
- if (index == 0 && clockwise) {
- tap_code(KC_MS_U); // turned right
- } else if (index == 0) {
- tap_code(KC_MS_D); // turned left
- }
-
- // Encoder 2, inside left
- else if (index == 1 && clockwise) {
- tap_code(KC_WH_D); // turned right
- } else if (index == 1) {
- tap_code(KC_WH_U); // turned left
- }
-
- // Encoder 3, inside right
- else if (index == 2 && clockwise) {
- tap_code(KC_VOLU); // turned right
- } else if (index == 2) {
- tap_code(KC_VOLD); // turned left
- }
-
- // Encoder 4, outside right
- else if (index == 3 && clockwise) {
- tap_code(KC_MS_R); // turned right
- } else if (index == 3) {
- tap_code(KC_MS_L); // turned left
- }
-}
-#endif
diff --git a/keyboards/clueboard/2x1800/2019/rules.mk b/keyboards/clueboard/2x1800/2019/rules.mk
index 06fe86f89e..0c1651af13 100644
--- a/keyboards/clueboard/2x1800/2019/rules.mk
+++ b/keyboards/clueboard/2x1800/2019/rules.mk
@@ -8,14 +8,15 @@ OPT_DEFS += -DBOOTLOADER_SIZE=1024
# Build Options
-BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = yes # Console for debug(+400)
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = yes # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
-ENCODER_ENABLE = yes
+ENCODER_ENABLE = yes # Rotary encoder (knob) support
NKRO_ENABLE = yes # USB Nkey Rollover
-MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
+MIDI_ENABLE = no # MIDI support
UNICODE_ENABLE = no # Unicode
-RGBLIGHT_ENABLE = yes # RGB on port C6
-AUDIO_ENABLE = yes # Audio output on port C4 and B7
+RGBLIGHT_ENABLE = yes # RGB on pin C5
+AUDIO_ENABLE = yes # Audio output on pin C4 and B7
+SHAKE_ENABLE = yes # Shake to undo
diff --git a/quantum/encoder.h b/quantum/encoder.h
index ae4762efb9..ec09a8cc47 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -22,10 +22,7 @@
void encoder_init(void);
void encoder_read(void);
-__attribute__((weak))
void encoder_update_kb(int8_t index, bool clockwise);
-
-__attribute__((weak))
void encoder_update_user(int8_t index, bool clockwise);
#ifdef SPLIT_KEYBOARD