at master 1.8 kB view raw
1/* Copyright 2020 Vladislav Kucheriavykh 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_dynamic_tapping_term.h" 18#include "quantum.h" 19#include "keycodes.h" 20#include "send_string.h" 21 22#ifndef DYNAMIC_TAPPING_TERM_INCREMENT 23# define DYNAMIC_TAPPING_TERM_INCREMENT 5 24#endif 25 26static void tapping_term_report(void) { 27#ifdef SEND_STRING_ENABLE 28 const char *tapping_term_str = get_u16_str(g_tapping_term, ' '); 29 // Skip padding spaces 30 while (*tapping_term_str == ' ') { 31 tapping_term_str++; 32 } 33 send_string(tapping_term_str); 34#endif 35} 36 37bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) { 38 if (record->event.pressed) { 39 switch (keycode) { 40 case QK_DYNAMIC_TAPPING_TERM_PRINT: 41 tapping_term_report(); 42 return false; 43 44 case QK_DYNAMIC_TAPPING_TERM_UP: 45 g_tapping_term += DYNAMIC_TAPPING_TERM_INCREMENT; 46 return false; 47 48 case QK_DYNAMIC_TAPPING_TERM_DOWN: 49 g_tapping_term -= DYNAMIC_TAPPING_TERM_INCREMENT; 50 return false; 51 } 52 } 53 return true; 54}