From 743449472e58651ec8111e6f70811103fb0a28bd Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Mon, 17 Sep 2018 10:48:02 -0700 Subject: Make `PREVENT_STUCK_MODIFIERS` the default (#3107) * Remove chording as it is not documented, not used, and needs work. * Make Leader Key an optional feature. * Switch from `PREVENT_STUCK_MODIFIERS` to `STRICT_LAYER_RELEASE` * Remove `#define PREVENT_STUCK_MODIFIERS` from keymaps. --- quantum/process_keycode/process_chording.c | 76 ------------------------------ quantum/process_keycode/process_chording.h | 32 ------------- quantum/process_keycode/process_leader.c | 2 +- quantum/quantum.c | 7 +-- quantum/quantum.h | 7 +-- quantum/quantum_keycodes.h | 6 +-- 6 files changed, 5 insertions(+), 125 deletions(-) delete mode 100644 quantum/process_keycode/process_chording.c delete mode 100644 quantum/process_keycode/process_chording.h (limited to 'quantum') diff --git a/quantum/process_keycode/process_chording.c b/quantum/process_keycode/process_chording.c deleted file mode 100644 index 6c6ebe300..000000000 --- a/quantum/process_keycode/process_chording.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2016 Jack Humbert - * - * 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 - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "process_chording.h" - -bool keys_chord(uint8_t keys[]) { - uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); - bool pass = true; - uint8_t in = 0; - for (uint8_t i = 0; i < chord_key_count; i++) { - bool found = false; - for (uint8_t j = 0; j < keys_size; j++) { - if (chord_keys[i] == (keys[j] & 0xFF)) { - in++; // detects key in chord - found = true; - break; - } - } - if (found) - continue; - if (chord_keys[i] != 0) { - pass = false; // makes sure rest are blank - } - } - return (pass && (in == keys_size)); -} - -bool process_chording(uint16_t keycode, keyrecord_t *record) { - if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) { - if (record->event.pressed) { - if (!chording) { - chording = true; - for (uint8_t i = 0; i < CHORDING_MAX; i++) - chord_keys[i] = 0; - chord_key_count = 0; - chord_key_down = 0; - } - chord_keys[chord_key_count] = (keycode & 0xFF); - chord_key_count++; - chord_key_down++; - return false; - } else { - if (chording) { - chord_key_down--; - if (chord_key_down == 0) { - chording = false; - // Chord Dictionary - if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { - register_code(KC_A); - unregister_code(KC_A); - return false; - } - for (uint8_t i = 0; i < chord_key_count; i++) { - register_code(chord_keys[i]); - unregister_code(chord_keys[i]); - return false; - } - } - } - } - } - return true; -} diff --git a/quantum/process_keycode/process_chording.h b/quantum/process_keycode/process_chording.h deleted file mode 100644 index 8c0f4862a..000000000 --- a/quantum/process_keycode/process_chording.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2016 Jack Humbert - * - * 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 - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef PROCESS_CHORDING_H -#define PROCESS_CHORDING_H - -#include "quantum.h" - -// Chording stuff -#define CHORDING_MAX 4 -bool chording = false; - -uint8_t chord_keys[CHORDING_MAX] = {0}; -uint8_t chord_key_count = 0; -uint8_t chord_key_down = 0; - -bool process_chording(uint16_t keycode, keyrecord_t *record); - -#endif diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index c87ef115a..eddbf71f7 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#ifndef DISABLE_LEADER +#ifdef LEADER_ENABLE #include "process_leader.h" diff --git a/quantum/quantum.c b/quantum/quantum.c index 9d352a94c..9bf91eb86 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -196,7 +196,7 @@ bool process_record_quantum(keyrecord_t *record) { keypos_t key = record->event.key; uint16_t keycode; - #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) + #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; @@ -251,12 +251,9 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif - #ifndef DISABLE_LEADER + #ifdef LEADER_ENABLE process_leader(keycode, record) && #endif - #ifndef DISABLE_CHORDING - process_chording(keycode, record) && - #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif diff --git a/quantum/quantum.h b/quantum/quantum.h index d1f761f17..7cf16d81e 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -89,15 +89,10 @@ extern uint32_t default_layer_state; #include "process_music.h" #endif -#ifndef DISABLE_LEADER +#ifdef LEADER_ENABLE #include "process_leader.h" #endif -#define DISABLE_CHORDING -#ifndef DISABLE_CHORDING - #include "process_chording.h" -#endif - #ifdef UNICODE_ENABLE #include "process_unicode.h" #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 0ecc293a8..3b8795496 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -63,10 +63,6 @@ enum quantum_keycodes { QK_ONE_SHOT_LAYER_MAX = 0x54FF, QK_ONE_SHOT_MOD = 0x5500, QK_ONE_SHOT_MOD_MAX = 0x55FF, -#ifndef DISABLE_CHORDING - QK_CHORDING = 0x5600, - QK_CHORDING_MAX = 0x56FF, -#endif QK_TAP_DANCE = 0x5700, QK_TAP_DANCE_MAX = 0x57FF, QK_LAYER_TAP_TOGGLE = 0x5800, @@ -123,7 +119,7 @@ enum quantum_keycodes { GRAVE_ESC, // Leader key -#ifndef DISABLE_LEADER +#ifdef LEADER_ENABLE KC_LEAD, #endif -- cgit v1.2.3-24-g4f1b