From eac8fa799909817bfc7cb4043448f85551154c6b Mon Sep 17 00:00:00 2001 From: Ofer Plesser Date: Sat, 10 Dec 2016 00:49:11 +0200 Subject: Implemented basic key combination feature --- quantum/quantum.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index f653564a6..eabeacff8 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -113,6 +113,9 @@ bool process_record_quantum(keyrecord_t *record) { if (!( process_record_kb(keycode, record) && + #ifdef COMBO_ENABLE + process_combo(keycode, record) && + #endif #ifdef MIDI_ENABLE process_midi(keycode, record) && #endif -- cgit v1.2.3 From b6bf4e0dce062a535685c4e772f613252d401ed3 Mon Sep 17 00:00:00 2001 From: Ofer Plesser Date: Sat, 10 Dec 2016 16:11:59 +0200 Subject: Added support for timing out combos if a key as been pressed for longer than COMBO_TERM --- quantum/quantum.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index eabeacff8..7767b6301 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -509,6 +509,11 @@ void matrix_scan_quantum() { #ifdef TAP_DANCE_ENABLE matrix_scan_tap_dance(); #endif + + #ifdef COMBO_ENABLE + matrix_scan_combo(); + #endif + matrix_scan_kb(); } -- cgit v1.2.3 From 40abf8bc9ce22cab472f79e3a97c413ac5648986 Mon Sep 17 00:00:00 2001 From: Ofer Plesser Date: Fri, 16 Dec 2016 22:00:29 +0200 Subject: Moved combo processing lower down in process logic --- quantum/quantum.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 7767b6301..e5385bc21 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -113,9 +113,6 @@ bool process_record_quantum(keyrecord_t *record) { if (!( process_record_kb(keycode, record) && - #ifdef COMBO_ENABLE - process_combo(keycode, record) && - #endif #ifdef MIDI_ENABLE process_midi(keycode, record) && #endif @@ -131,6 +128,9 @@ bool process_record_quantum(keyrecord_t *record) { #ifndef DISABLE_CHORDING process_chording(keycode, record) && #endif + #ifdef COMBO_ENABLE + process_combo(keycode, record) && + #endif #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif -- cgit v1.2.3 From 01038ab54ca6c2858ea9e856c717a1129ffe4156 Mon Sep 17 00:00:00 2001 From: Ofer Plesser Date: Fri, 23 Dec 2016 21:51:11 +0200 Subject: Added check that makes sure a code is a right modifier before considering it as one --- quantum/quantum.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index f653564a6..63ffe2074 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -21,6 +21,8 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { if (code & QK_LGUI) f(KC_LGUI); + if (code < QK_RMODS_MIN) return; + if (code & QK_RCTL) f(KC_RCTL); if (code & QK_RSFT) -- cgit v1.2.3 From 2b3859937b1e7f96b684408d31ff12a4e682f7ee Mon Sep 17 00:00:00 2001 From: SjB Date: Sat, 21 Jan 2017 02:01:55 -0500 Subject: speeding up (un)register_code16 In register_code16 and unregister_code16 we call register_code and unregister_code twice, once for the mods and once for the keycode. The (un)register_code have many check to see that keycode we have sent however because we know that we are sending it a mods key, why not just skip all of it and call (un)register_mods instead. This will skip alot of checks and should speedup the loop a little. --- quantum/quantum.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 63ffe2074..1767faed4 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -33,14 +33,22 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { f(KC_RGUI); } +static inline void qk_register_mods(uint8_t kc) { + register_mods(MOD_BIT(kc)); +} + +static inline void qk_unregister_mods(uint8_t kc) { + unregister_mods(MOD_BIT(kc)); +} + void register_code16 (uint16_t code) { - do_code16 (code, register_code); + do_code16 (code, qk_register_mods); register_code (code); } void unregister_code16 (uint16_t code) { unregister_code (code); - do_code16 (code, unregister_code); + do_code16 (code, qk_unregister_mods); } __attribute__ ((weak)) -- cgit v1.2.3 From f644b9a07a34ae19a6014b08db656a4eeca1dcda Mon Sep 17 00:00:00 2001 From: SjB Date: Sun, 29 Jan 2017 12:06:24 -0500 Subject: registering a weak_mods when using register_code16 Scenario: Locking the KC_LSHIFT, and then using a tap dance key that registers a S(KC_9) will unregister the KC_LSHIFT. The tap dance or any keycode that is registered should not have the side effect of cancelling a locked moditifier. We should be using a similar logic as the TMK codes in tmk_core/comman/action.c:158. --- quantum/quantum.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 1767faed4..0aecd238e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -33,22 +33,42 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { f(KC_RGUI); } +static inline void qk_register_weak_mods(uint8_t kc) { + add_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); +} + +static inline void qk_unregister_weak_mods(uint8_t kc) { + del_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); +} + static inline void qk_register_mods(uint8_t kc) { - register_mods(MOD_BIT(kc)); + add_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); } static inline void qk_unregister_mods(uint8_t kc) { - unregister_mods(MOD_BIT(kc)); + del_weak_mods(MOD_BIT(kc)); + send_keyboard_report(); } void register_code16 (uint16_t code) { - do_code16 (code, qk_register_mods); + if (IS_MOD(code) || code == KC_NO) { + do_code16 (code, qk_register_mods); + } else { + do_code16 (code, qk_register_weak_mods); + } register_code (code); } void unregister_code16 (uint16_t code) { unregister_code (code); - do_code16 (code, qk_unregister_mods); + if (IS_MOD(code) || code == KC_NO) { + do_code16 (code, qk_unregister_mods); + } else { + do_code16 (code, qk_unregister_weak_mods); + } } __attribute__ ((weak)) -- cgit v1.2.3 From c17070eca545f654f91cf3dcba6c6c611e0f8d03 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Wed, 1 Feb 2017 15:35:21 +0700 Subject: Add layer switcher keycodes: OUT_AUTO, OUT_USB, OUT_BT, OUT_BLE --- quantum/quantum.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 63ffe2074..1d1a691e2 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1,4 +1,5 @@ #include "quantum.h" +#include "outputselect.h" #ifndef TAPPING_TERM #define TAPPING_TERM 200 @@ -212,6 +213,34 @@ bool process_record_quantum(keyrecord_t *record) { return false; break; #endif + case OUT_AUTO: + if (record->event.pressed) { + set_output(OUTPUT_AUTO); + } + return false; + break; + case OUT_USB: + if (record->event.pressed) { + set_output(OUTPUT_USB); + } + return false; + break; + #ifdef BLUETOOTH_ENABLE + case OUT_BT: + if (record->event.pressed) { + set_output(OUTPUT_BLUETOOTH); + } + return false; + break; + #endif + #ifdef ADAFRUIT_BLE_ENABLE + case OUT_BLE: + if (record->event.pressed) { + set_output(OUTPUT_ADAFRUIT_BLE); + } + return false; + break; + #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) -- cgit v1.2.3 From 2bef8b5b88547ce28fb056559b058e35109278b3 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Wed, 1 Feb 2017 19:37:52 +0700 Subject: Limit outputselect to AVR only for now --- quantum/quantum.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 1d1a691e2..585692d4a 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1,5 +1,7 @@ #include "quantum.h" +#if defined(__AVR__) #include "outputselect.h" +#endif #ifndef TAPPING_TERM #define TAPPING_TERM 200 @@ -213,6 +215,7 @@ bool process_record_quantum(keyrecord_t *record) { return false; break; #endif + #if defined(__AVR__) case OUT_AUTO: if (record->event.pressed) { set_output(OUTPUT_AUTO); @@ -241,6 +244,7 @@ bool process_record_quantum(keyrecord_t *record) { return false; break; #endif + #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) -- cgit v1.2.3 From e7c4f621f14b60bde68c01ae076cac49cac9927e Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Wed, 1 Feb 2017 22:30:06 +0700 Subject: Restrict outputselect to LUFA only for now --- quantum/quantum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 585692d4a..ad957a1b1 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1,5 +1,5 @@ #include "quantum.h" -#if defined(__AVR__) +#ifdef PROTOCOL_LUFA #include "outputselect.h" #endif @@ -215,7 +215,7 @@ bool process_record_quantum(keyrecord_t *record) { return false; break; #endif - #if defined(__AVR__) + #ifdef PROTOCOL_LUFA case OUT_AUTO: if (record->event.pressed) { set_output(OUTPUT_AUTO); -- cgit v1.2.3 From b4e30d392969b000eb9a87065fc1caaf33d670e1 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 7 Feb 2017 15:23:56 -0500 Subject: added functionality for just a port --- quantum/quantum.c | 94 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 32 deletions(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index d3905decf..45ea8cb73 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -594,34 +594,45 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN; # define COM1x1 COM1A1 # define OCR1x OCR1A #else -# error "Backlight pin not supported - use B5, B6, or B7" +# define NO_BACKLIGHT_CLOCK +#endif + +#ifndef BACKLIGHT_ON_STATE +#define BACKLIGHT_ON_STATE 0 #endif __attribute__ ((weak)) void backlight_init_ports(void) { - // Setup backlight pin as output and output low. + // Setup backlight pin as output and output to on state. // DDRx |= n _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); + #if BACKLIGHT_ON_STATE == 0 + // PORTx &= ~n + _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); + #else + // PORTx |= n + _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); + #endif - // Use full 16-bit resolution. - ICR1 = 0xFFFF; + #ifndef NO_BACKLIGHT_CLOCK + // Use full 16-bit resolution. + ICR1 = 0xFFFF; - // I could write a wall of text here to explain... but TL;DW - // Go read the ATmega32u4 datasheet. - // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on + // I could write a wall of text here to explain... but TL;DW + // Go read the ATmega32u4 datasheet. + // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on - // Pin PB7 = OCR1C (Timer 1, Channel C) - // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 - // (i.e. start high, go low when counter matches.) - // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 - // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 + // Pin PB7 = OCR1C (Timer 1, Channel C) + // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 + // (i.e. start high, go low when counter matches.) + // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 + // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 - TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; - TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; + TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + #endif backlight_init(); #ifdef BACKLIGHT_BREATHING @@ -633,24 +644,43 @@ __attribute__ ((weak)) void backlight_set(uint8_t level) { // Prevent backlight blink on lowest level - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); + #if BACKLIGHT_ON_STATE == 0 + // PORTx &= ~n + _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); + #else + // PORTx |= n + _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); + #endif if ( level == 0 ) { - // Turn off PWM control on backlight pin, revert to output low. - TCCR1A &= ~(_BV(COM1x1)); - OCR1x = 0x0; - } else if ( level == BACKLIGHT_LEVELS ) { - // Turn on PWM control of backlight pin - TCCR1A |= _BV(COM1x1); - // Set the brightness - OCR1x = 0xFFFF; - } else { - // Turn on PWM control of backlight pin - TCCR1A |= _BV(COM1x1); - // Set the brightness - OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); - } + #ifndef NO_BACKLIGHT_CLOCK + // Turn off PWM control on backlight pin, revert to output low. + TCCR1A &= ~(_BV(COM1x1)); + OCR1x = 0x0; + #else + #if BACKLIGHT_ON_STATE == 0 + // PORTx |= n + _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); + #else + // PORTx &= ~n + _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); + #endif + #endif + } + #ifndef NO_BACKLIGHT_CLOCK + else if ( level == BACKLIGHT_LEVELS ) { + // Turn on PWM control of backlight pin + TCCR1A |= _BV(COM1x1); + // Set the brightness + OCR1x = 0xFFFF; + } + else { + // Turn on PWM control of backlight pin + TCCR1A |= _BV(COM1x1); + // Set the brightness + OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); + } + #endif #ifdef BACKLIGHT_BREATHING breathing_intensity_default(); -- cgit v1.2.3 From 8c93c5d9ab8a0a69d84f707db71f417b66402693 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 13 Feb 2017 14:55:35 +0700 Subject: Add keycodes to turn on, turn off and toggle faux clicky --- quantum/quantum.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 45ea8cb73..2088c10c9 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -7,6 +7,10 @@ #define TAPPING_TERM 200 #endif +#ifdef FAUXCLICKY_ENABLE +#include "fauxclicky.h" +#endif + static void do_code16 (uint16_t code, void (*f) (uint8_t)) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -196,6 +200,26 @@ bool process_record_quantum(keyrecord_t *record) { } return false; break; + #ifdef FAUXCLICKY_ENABLE + case FC_TOG: + if (record->event.pressed) { + FAUXCLICKY_TOGGLE; + } + return false; + break; + case FC_ON: + if (record->event.pressed) { + FAUXCLICKY_ON; + } + return false; + break; + case FC_OFF: + if (record->event.pressed) { + FAUXCLICKY_OFF; + } + return false; + break; + #endif #ifdef RGBLIGHT_ENABLE case RGB_TOG: if (record->event.pressed) { -- cgit v1.2.3