diff options
Diffstat (limited to 'quantum/process_keycode/process_chording.c')
| -rw-r--r-- | quantum/process_keycode/process_chording.c | 76 |
1 files changed, 0 insertions, 76 deletions
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 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_chording.h" | ||
| 18 | |||
| 19 | bool keys_chord(uint8_t keys[]) { | ||
| 20 | uint8_t keys_size = sizeof(keys)/sizeof(keys[0]); | ||
| 21 | bool pass = true; | ||
| 22 | uint8_t in = 0; | ||
| 23 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 24 | bool found = false; | ||
| 25 | for (uint8_t j = 0; j < keys_size; j++) { | ||
| 26 | if (chord_keys[i] == (keys[j] & 0xFF)) { | ||
| 27 | in++; // detects key in chord | ||
| 28 | found = true; | ||
| 29 | break; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | if (found) | ||
| 33 | continue; | ||
| 34 | if (chord_keys[i] != 0) { | ||
| 35 | pass = false; // makes sure rest are blank | ||
| 36 | } | ||
| 37 | } | ||
| 38 | return (pass && (in == keys_size)); | ||
| 39 | } | ||
| 40 | |||
| 41 | bool process_chording(uint16_t keycode, keyrecord_t *record) { | ||
| 42 | if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) { | ||
| 43 | if (record->event.pressed) { | ||
| 44 | if (!chording) { | ||
| 45 | chording = true; | ||
| 46 | for (uint8_t i = 0; i < CHORDING_MAX; i++) | ||
| 47 | chord_keys[i] = 0; | ||
| 48 | chord_key_count = 0; | ||
| 49 | chord_key_down = 0; | ||
| 50 | } | ||
| 51 | chord_keys[chord_key_count] = (keycode & 0xFF); | ||
| 52 | chord_key_count++; | ||
| 53 | chord_key_down++; | ||
| 54 | return false; | ||
| 55 | } else { | ||
| 56 | if (chording) { | ||
| 57 | chord_key_down--; | ||
| 58 | if (chord_key_down == 0) { | ||
| 59 | chording = false; | ||
| 60 | // Chord Dictionary | ||
| 61 | if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { | ||
| 62 | register_code(KC_A); | ||
| 63 | unregister_code(KC_A); | ||
| 64 | return false; | ||
| 65 | } | ||
| 66 | for (uint8_t i = 0; i < chord_key_count; i++) { | ||
| 67 | register_code(chord_keys[i]); | ||
| 68 | unregister_code(chord_keys[i]); | ||
| 69 | return false; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | return true; | ||
| 76 | } | ||
