summaryrefslogtreecommitdiff
path: root/keyboard
diff options
context:
space:
mode:
authorErez Zukerman <bulk@ezuk.org>2016-05-15 00:27:32 -0400
committerJack Humbert <jack.humb@gmail.com>2016-05-15 00:27:32 -0400
commit1a8c0dd22d6a2255511d0db6a456315541b5815b (patch)
tree6c7d5e9dc66f9ce864cfe87a72dfb47e6f06d3a7 /keyboard
parent79d26f331a275c99f76a30d34752fbd65bb3f335 (diff)
Leader key implementation (#326)
* implements leader key for planck experimental * allows override of leader timeout * adds ability to use the leader key in seq * fixes leader keycode * adds chording prototype * fixes keycode detection * moves music mode to quantum.c * disables chording by default * updates process_action functions to return bool
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/atomic/atomic.c7
-rw-r--r--keyboard/atomic/atomic.h2
-rw-r--r--keyboard/gh60_rev_c/gh60.c7
-rw-r--r--keyboard/gh60_rev_c/gh60.h2
-rw-r--r--keyboard/planck/keymaps/experimental/keymap.c48
-rw-r--r--keyboard/planck/planck.c8
-rw-r--r--keyboard/planck/planck.h16
-rw-r--r--keyboard/preonic/preonic.c8
-rw-r--r--keyboard/preonic/preonic.h2
9 files changed, 52 insertions, 48 deletions
diff --git a/keyboard/atomic/atomic.c b/keyboard/atomic/atomic.c
index b4b2614572..fa218a48f3 100644
--- a/keyboard/atomic/atomic.c
+++ b/keyboard/atomic/atomic.c
@@ -11,8 +11,9 @@ void matrix_scan_user(void) {
}
__attribute__ ((weak))
-void process_action_user(keyrecord_t *record) {
+bool process_action_user(keyrecord_t *record) {
// leave this function blank - it can be defined in a keymap file
+ return true;
}
__attribute__ ((weak))
@@ -45,11 +46,11 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
-void process_action_kb(keyrecord_t *record) {
+bool process_action_kb(keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
- process_action_user(record);
+ return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/atomic/atomic.h b/keyboard/atomic/atomic.h
index 845a9043e2..2d6b4c6cb5 100644
--- a/keyboard/atomic/atomic.h
+++ b/keyboard/atomic/atomic.h
@@ -29,7 +29,7 @@
void matrix_init_user(void);
void matrix_scan_user(void);
-void process_action_user(keyrecord_t *record);
+bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
void backlight_init_ports(void);
diff --git a/keyboard/gh60_rev_c/gh60.c b/keyboard/gh60_rev_c/gh60.c
index 8e7219bfe8..6da4d8ee3e 100644
--- a/keyboard/gh60_rev_c/gh60.c
+++ b/keyboard/gh60_rev_c/gh60.c
@@ -12,8 +12,9 @@ void matrix_scan_user(void) {
}
__attribute__ ((weak))
-void process_action_user(keyrecord_t *record) {
+bool process_action_user(keyrecord_t *record) {
// leave this function blank - it can be defined in a keymap file
+ return true;
}
__attribute__ ((weak))
@@ -35,11 +36,11 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
-void process_action_kb(keyrecord_t *record) {
+bool process_action_kb(keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
- process_action_user(record);
+ return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/gh60_rev_c/gh60.h b/keyboard/gh60_rev_c/gh60.h
index 2373ad333c..95e5e1ebc7 100644
--- a/keyboard/gh60_rev_c/gh60.h
+++ b/keyboard/gh60_rev_c/gh60.h
@@ -75,7 +75,7 @@ inline void gh60_wasd_leds_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); }
void matrix_init_user(void);
void matrix_scan_user(void);
-void process_action_user(keyrecord_t *record);
+bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
#endif
diff --git a/keyboard/planck/keymaps/experimental/keymap.c b/keyboard/planck/keymaps/experimental/keymap.c
index fc3ac4a97e..8dc158c73f 100644
--- a/keyboard/planck/keymaps/experimental/keymap.c
+++ b/keyboard/planck/keymaps/experimental/keymap.c
@@ -6,6 +6,7 @@
#ifdef AUDIO_ENABLE
#include "audio.h"
#endif
+
#include "eeconfig.h"
extern keymap_config_t keymap_config;
@@ -78,7 +79,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
{KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
- {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+ {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
/* Dvorak
@@ -291,7 +292,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
case 8:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
- layer_off(_MUSIC);
+ music_activated = false;
stop_all_notes();
#endif
}
@@ -300,7 +301,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(music_scale, false, 0);
- layer_on(_MUSIC);
+ music_activated = true;
#endif
}
break;
@@ -360,24 +361,35 @@ void matrix_init_user(void) {
}
#ifdef AUDIO_ENABLE
-void play_goodbye_tone()
-{
- PLAY_NOTE_ARRAY(goodbye, false, 0);
- _delay_ms(150);
-}
+ void play_goodbye_tone(void)
+ {
+ PLAY_NOTE_ARRAY(goodbye, false, 0);
+ _delay_ms(150);
+ }
+#endif
-uint8_t starting_note = 0x0C;
-int offset = 0;
+LEADER_EXTERNS();
-void process_action_user(keyrecord_t *record) {
+#define LEADER_TIMEOUT 300
- if (IS_LAYER_ON(_MUSIC)) {
- if (record->event.pressed) {
- play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
- } else {
- stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
+void matrix_scan_user(void) {
+ LEADER_DICTIONARY() {
+ leading = false;
+ leader_end();
+
+ SEQ_ONE_KEY(KC_F) {
+ register_code(KC_S);
+ unregister_code(KC_S);
+ }
+ SEQ_TWO_KEYS(KC_A, KC_S) {
+ register_code(KC_H);
+ unregister_code(KC_H);
+ }
+ SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
+ register_code(KC_LGUI);
+ register_code(KC_S);
+ unregister_code(KC_S);
+ unregister_code(KC_LGUI);
}
}
-
}
-#endif
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c
index 446353dbf5..da7b3a1702 100644
--- a/keyboard/planck/planck.c
+++ b/keyboard/planck/planck.c
@@ -7,7 +7,9 @@ __attribute__ ((weak))
void matrix_scan_user(void) {}
__attribute__ ((weak))
-void process_action_user(keyrecord_t *record) {}
+bool process_action_user(keyrecord_t *record) {
+ return true;
+}
__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {}
@@ -32,8 +34,8 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
-void process_action_kb(keyrecord_t *record) {
- process_action_user(record);
+bool process_action_kb(keyrecord_t *record) {
+ return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h
index cfd4956bf1..8aec6b2627 100644
--- a/keyboard/planck/planck.h
+++ b/keyboard/planck/planck.h
@@ -1,19 +1,7 @@
#ifndef PLANCK_H
#define PLANCK_H
-#include "matrix.h"
-#include "keymap_common.h"
-#ifdef BACKLIGHT_ENABLE
- #include "backlight.h"
-#endif
-#ifdef RGBLIGHT_ENABLE
- #include "rgblight.h"
-#endif
-#include <stddef.h>
-#include <avr/io.h>
-#ifdef MIDI_ENABLE
- #include <keymap_midi.h>
-#endif
+#include "quantum.h"
#define PLANCK_MIT( \
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
@@ -43,7 +31,7 @@
void matrix_init_user(void);
void matrix_scan_user(void);
-void process_action_user(keyrecord_t *record);
+bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
void backlight_init_ports(void);
diff --git a/keyboard/preonic/preonic.c b/keyboard/preonic/preonic.c
index 211f8d0296..13e05c65a7 100644
--- a/keyboard/preonic/preonic.c
+++ b/keyboard/preonic/preonic.c
@@ -11,8 +11,8 @@ void matrix_scan_user(void) {
};
__attribute__ ((weak))
-void process_action_user(keyrecord_t *record) {
-
+bool process_action_user(keyrecord_t *record) {
+ return true;
};
void matrix_init_kb(void) {
@@ -36,8 +36,8 @@ void matrix_scan_kb(void) {
matrix_scan_user();
};
-void process_action_kb(keyrecord_t *record) {
- process_action_user(record);
+bool process_action_kb(keyrecord_t *record) {
+ return process_action_user(record);
}
#ifdef BACKLIGHT_ENABLE
diff --git a/keyboard/preonic/preonic.h b/keyboard/preonic/preonic.h
index 030acdadb4..2406a11d7e 100644
--- a/keyboard/preonic/preonic.h
+++ b/keyboard/preonic/preonic.h
@@ -47,6 +47,6 @@
void matrix_init_user(void);
void matrix_scan_user(void);
-void process_action_kb(keyrecord_t *record);
+bool process_action_kb(keyrecord_t *record);
#endif