aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keymap_extras/keymap_steno.h71
-rw-r--r--quantum/process_keycode/process_steno.c82
-rw-r--r--quantum/process_keycode/process_steno.h12
-rw-r--r--quantum/quantum.c9
-rw-r--r--quantum/quantum.h4
-rw-r--r--quantum/quantum_keycodes.h4
6 files changed, 179 insertions, 3 deletions
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
new file mode 100644
index 000000000..4eb1c7477
--- /dev/null
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -0,0 +1,71 @@
1/* Copyright 2017 Joseph Wasson
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#ifndef KEYMAP_STENO_H
17#define KEYMAP_STENO_H
18
19#include "keymap.h"
20
21enum steno_keycodes {
22 STN_FN = QK_STENO,
23 STN_NUM,
24 STN_N1 = STN_NUM,
25 STN_N2,
26 STN_N3,
27 STN_N4,
28 STN_N5,
29 STN_N6,
30 STN_SL,
31 STN_S1 = STN_SL,
32 STN_S2,
33 STN_TL,
34 STN_KL,
35 STN_PL,
36 STN_WL,
37 STN_HL,
38 STN_RL,
39 STN_A,
40 STN_O,
41 STN_STR,
42 STN_ST1 = STN_STR,
43 STN_ST2,
44 STN_RES1,
45 STN_RE1 = STN_RES1,
46 STN_RES2,
47 STN_RE2 = STN_RES2,
48 STN_PWR,
49 STN_ST3,
50 STN_ST4,
51 STN_E,
52 STN_U,
53 STN_FR,
54 STN_RR,
55 STN_PR,
56 STN_BR,
57 STN_LR,
58 STN_GR,
59 STN_TR,
60 STN_SR,
61 STN_DR,
62 STN_N7,
63 STN_N8,
64 STN_N9,
65 STN_NA,
66 STN_NB,
67 STN_NC,
68 STN_ZR
69};
70
71#endif
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
new file mode 100644
index 000000000..211f00a5a
--- /dev/null
+++ b/quantum/process_keycode/process_steno.c
@@ -0,0 +1,82 @@
1#include "process_steno.h"
2#include "quantum_keycodes.h"
3#include "keymap_steno.h"
4#include "virtser.h"
5
6uint8_t state[4] = {0};
7uint8_t pressed = 0;
8
9
10// TxBolt Codes
11#define TXB_NUL 0
12#define TXB_S_L 0b00000001
13#define TXB_T_L 0b00000010
14#define TXB_K_L 0b00000100
15#define TXB_P_L 0b00001000
16#define TXB_W_L 0b00010000
17#define TXB_H_L 0b00100000
18#define TXB_R_L 0b01000001
19#define TXB_A_L 0b01000010
20#define TXB_O_L 0b01000100
21#define TXB_STR 0b01001000
22#define TXB_E_R 0b01010000
23#define TXB_U_R 0b01100000
24#define TXB_F_R 0b10000001
25#define TXB_R_R 0b10000010
26#define TXB_P_R 0b10000100
27#define TXB_B_R 0b10001000
28#define TXB_L_R 0b10010000
29#define TXB_G_R 0b10100000
30#define TXB_T_R 0b11000001
31#define TXB_S_R 0b11000010
32#define TXB_D_R 0b11000100
33#define TXB_Z_R 0b11001000
34#define TXB_NUM 0b11010000
35
36#define TXB_GRP0 0b00000000
37#define TXB_GRP1 0b01000000
38#define TXB_GRP2 0b10000000
39#define TXB_GRP3 0b11000000
40#define TXB_GRPMASK 0b11000000
41
42#define TXB_GET_GROUP(code) ((code & TXB_GRPMASK) >> 6)
43
44uint8_t boltmap[64] = {
45 TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM,
46 TXB_S_L, TXB_S_L, TXB_T_L, TXB_K_L, TXB_P_L, TXB_W_L, TXB_H_L,
47 TXB_R_L, TXB_A_L, TXB_O_L, TXB_STR, TXB_STR, TXB_NUL, TXB_NUL,
48 TXB_NUL, TXB_STR, TXB_STR, TXB_E_R, TXB_U_R, TXB_F_R, TXB_R_R,
49 TXB_P_R, TXB_B_R, TXB_L_R, TXB_G_R, TXB_T_R, TXB_S_R, TXB_D_R,
50 TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_Z_R
51};
52
53#define BOLTMAP_MASK (sizeof(boltmap) - 1)
54
55void send_steno_state(void) {
56 for (uint8_t i = 0; i < 4; ++i) {
57 if (state[i]) {
58 virtser_send(state[i]);
59 state[i] = 0;
60 }
61 }
62 virtser_send(0);
63}
64
65bool process_steno(uint16_t keycode, keyrecord_t *record) {
66 if(keycode >= QK_STENO && keycode <= QK_STENO_MAX) {
67 if(IS_PRESSED(record->event)) {
68 uint8_t boltcode = boltmap[keycode & BOLTMAP_MASK];
69 ++pressed;
70 state[TXB_GET_GROUP(boltcode)] |= boltcode;
71 } else {
72 --pressed;
73 if (pressed <= 0) {
74 pressed = 0; // protect against spurious up keys
75 send_steno_state();
76 }
77 }
78 return false;
79 }
80
81 return true;
82}
diff --git a/quantum/process_keycode/process_steno.h b/quantum/process_keycode/process_steno.h
new file mode 100644
index 000000000..fb9b8e8ad
--- /dev/null
+++ b/quantum/process_keycode/process_steno.h
@@ -0,0 +1,12 @@
1#ifndef PROCESS_STENO_H
2#define PROCESS_STENO_H
3
4#include "quantum.h"
5
6#if defined(STENO_ENABLE) && !defined(VIRTSER_ENABLE)
7 #error "must have virtser enabled to use steno"
8#endif
9
10bool process_steno(uint16_t keycode, keyrecord_t *record);
11
12#endif \ No newline at end of file
diff --git a/quantum/quantum.c b/quantum/quantum.c
index b76a11418..1f8ce6c46 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -200,6 +200,9 @@ bool process_record_quantum(keyrecord_t *record) {
200 #ifdef AUDIO_ENABLE 200 #ifdef AUDIO_ENABLE
201 process_audio(keycode, record) && 201 process_audio(keycode, record) &&
202 #endif 202 #endif
203 #ifdef STENO_ENABLE
204 process_steno(keycode, record) &&
205 #endif
203 #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) 206 #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
204 process_music(keycode, record) && 207 process_music(keycode, record) &&
205 #endif 208 #endif
@@ -722,14 +725,14 @@ void backlight_set(uint8_t level)
722 // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); 725 // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
723 // #endif 726 // #endif
724 #endif 727 #endif
725 } 728 }
726 #ifndef NO_BACKLIGHT_CLOCK 729 #ifndef NO_BACKLIGHT_CLOCK
727 else if ( level == BACKLIGHT_LEVELS ) { 730 else if ( level == BACKLIGHT_LEVELS ) {
728 // Turn on PWM control of backlight pin 731 // Turn on PWM control of backlight pin
729 TCCR1A |= _BV(COM1x1); 732 TCCR1A |= _BV(COM1x1);
730 // Set the brightness 733 // Set the brightness
731 OCR1x = 0xFFFF; 734 OCR1x = 0xFFFF;
732 } 735 }
733 else { 736 else {
734 // Turn on PWM control of backlight pin 737 // Turn on PWM control of backlight pin
735 TCCR1A |= _BV(COM1x1); 738 TCCR1A |= _BV(COM1x1);
@@ -747,7 +750,7 @@ uint8_t backlight_tick = 0;
747 750
748void backlight_task(void) { 751void backlight_task(void) {
749 #ifdef NO_BACKLIGHT_CLOCK 752 #ifdef NO_BACKLIGHT_CLOCK
750 if ((0xFFFF >> ((BACKLIGHT_LEVELS - backlight_config.level) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) { 753 if ((0xFFFF >> ((BACKLIGHT_LEVELS - backlight_config.level) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
751 #if BACKLIGHT_ON_STATE == 0 754 #if BACKLIGHT_ON_STATE == 0
752 // PORTx &= ~n 755 // PORTx &= ~n
753 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); 756 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 6c0e46573..453cb43f8 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -60,6 +60,10 @@ extern uint32_t default_layer_state;
60 #include "process_audio.h" 60 #include "process_audio.h"
61#endif 61#endif
62 62
63#ifdef STENO_ENABLE
64 #include "process_steno.h"
65#endif
66
63#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) 67#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
64 #include "process_music.h" 68 #include "process_music.h"
65#endif 69#endif
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 06ab6d18d..f0937628e 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -71,6 +71,10 @@ enum quantum_keycodes {
71 QK_TAP_DANCE_MAX = 0x57FF, 71 QK_TAP_DANCE_MAX = 0x57FF,
72 QK_LAYER_TAP_TOGGLE = 0x5800, 72 QK_LAYER_TAP_TOGGLE = 0x5800,
73 QK_LAYER_TAP_TOGGLE_MAX = 0x58FF, 73 QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
74#ifdef STENO_ENABLE
75 QK_STENO = 0x5900,
76 QK_STENO_MAX = 0x593F,
77#endif
74 QK_MOD_TAP = 0x6000, 78 QK_MOD_TAP = 0x6000,
75 QK_MOD_TAP_MAX = 0x7FFF, 79 QK_MOD_TAP_MAX = 0x7FFF,
76#if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) 80#if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE)