Improve string sending (#376)
parent
cc3972e7d6
commit
794aed37a0
|
@ -287,14 +287,14 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||||
music_sequence_count = 0;
|
music_sequence_count = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing
|
if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing
|
||||||
stop_all_notes();
|
stop_all_notes();
|
||||||
music_sequence_recording = false;
|
music_sequence_recording = false;
|
||||||
music_sequence_playing = false;
|
music_sequence_playing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == KC_LGUI && record->event.pressed) { // Start playing
|
if (keycode == KC_LGUI && record->event.pressed) { // Start playing
|
||||||
stop_all_notes();
|
stop_all_notes();
|
||||||
music_sequence_recording = false;
|
music_sequence_recording = false;
|
||||||
|
@ -309,7 +309,7 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||||
music_sequence_interval-=10;
|
music_sequence_interval-=10;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == KC_DOWN) {
|
if (keycode == KC_DOWN) {
|
||||||
if (record->event.pressed)
|
if (record->event.pressed)
|
||||||
music_sequence_interval+=10;
|
music_sequence_interval+=10;
|
||||||
|
@ -473,57 +473,106 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||||
return process_action_kb(record);
|
return process_action_kb(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shift_us_qwerty[0x80] = {
|
const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 31
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, // 32 - 63
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 64 - 95
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 // 96 - 127
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 1, 1, 1, 1, 1, 1, 0,
|
||||||
|
1, 1, 1, 1, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 0, 0, 0, 1, 1,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 1, 1, 1, 1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t ascii_us_qwerty[0x80] = {
|
const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KC_ESC, 0, 0, 0, 0, // 0 - 31
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, // 32 - 46
|
KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
|
||||||
KC_SLSH, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, // 47 - 61
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
KC_DOT, KC_SLSH, KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, // 62 - 78
|
0, 0, 0, KC_ESC, 0, 0, 0, 0,
|
||||||
KC_O, KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, // 79 - 94
|
KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
|
||||||
KC_MINS, KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, // 95 - 111
|
KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
|
||||||
KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL // 112 - 127
|
KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
|
||||||
|
KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
|
||||||
|
KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
|
||||||
|
KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
|
||||||
|
KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
|
||||||
|
KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
|
||||||
|
KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
|
||||||
|
KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
|
||||||
|
KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
|
||||||
|
KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is how you'd add OS colemak support
|
/* for users whose OSes are set to Colemak */
|
||||||
|
#if 0
|
||||||
|
#include "keymap_colemak.h"
|
||||||
|
|
||||||
// bool shift_us_colemak[0x80] = {
|
const bool ascii_to_colemak_shift_lut[0x80] PROGMEM = {
|
||||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 31
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
// 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, // 32 - 63
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 64 - 95
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 // 96 - 127
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
// };
|
0, 1, 1, 1, 1, 1, 1, 0,
|
||||||
|
1, 1, 1, 1, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 0, 0, 0, 1, 1,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 1, 1, 1, 1, 0
|
||||||
|
};
|
||||||
|
|
||||||
// #include "keymap_colemak.h"
|
const uint8_t ascii_to_colemak_keycode_lut[0x80] PROGMEM = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, KC_ESC, 0, 0, 0, 0,
|
||||||
|
KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
|
||||||
|
KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
|
||||||
|
KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
|
||||||
|
KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
|
||||||
|
KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
|
||||||
|
CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
|
||||||
|
CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
|
||||||
|
CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
|
||||||
|
KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
|
||||||
|
CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
|
||||||
|
CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
|
||||||
|
CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
|
||||||
|
};
|
||||||
|
|
||||||
// uint8_t ascii_us_colemak[0x80] = {
|
#endif
|
||||||
// 0, 0, 0, 0, 0, 0, 0, 0, KC_BSPC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KC_ESC, 0, 0, 0, 0, // 0 - 31
|
|
||||||
// KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, // 32 - 46
|
|
||||||
// KC_SLSH, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, // 47 - 61
|
|
||||||
// KC_DOT, KC_SLSH, KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, // 62 - 78
|
|
||||||
// CM_O, CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, // 79 - 94
|
|
||||||
// KC_MINS, KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G, CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O, // 95 - 111
|
|
||||||
// CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W, CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL // 112 - 127
|
|
||||||
// };
|
|
||||||
|
|
||||||
void send_string(char str[]) {
|
void send_string(const char *str) {
|
||||||
for (int i = 0; str[i] != 0; i++) {
|
while (1) {
|
||||||
uint8_t keycode = ascii_us_qwerty[str[i]];
|
uint8_t keycode;
|
||||||
if (shift_us_qwerty[str[i]]) {
|
uint8_t ascii_code = pgm_read_byte(str);
|
||||||
register_code(KC_LSFT);
|
if (!ascii_code) break;
|
||||||
register_code(keycode);
|
keycode = pgm_read_byte(&ascii_to_qwerty_keycode_lut[ascii_code]);
|
||||||
unregister_code(keycode);
|
if (pgm_read_byte(&ascii_to_qwerty_shift_lut[ascii_code])) {
|
||||||
unregister_code(KC_LSFT);
|
register_code(KC_LSFT);
|
||||||
} else {
|
register_code(keycode);
|
||||||
register_code(keycode);
|
unregister_code(keycode);
|
||||||
unregister_code(keycode);
|
unregister_code(KC_LSFT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
register_code(keycode);
|
||||||
|
unregister_code(keycode);
|
||||||
|
}
|
||||||
|
++str;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,7 +621,7 @@ void matrix_scan_quantum() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Override these functions in your keymap file to play different tunes on
|
// Override these functions in your keymap file to play different tunes on
|
||||||
// different events such as startup and bootloader jump
|
// different events such as startup and bootloader jump
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef QUANTUM_H
|
#ifndef QUANTUM_H
|
||||||
#define QUANTUM_H
|
#define QUANTUM_H
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "keymap_common.h"
|
#include "keymap_common.h"
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
|
@ -25,6 +26,8 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
#define SEND_STRING(str) send_string(PSTR(str))
|
||||||
|
|
||||||
extern uint32_t default_layer_state;
|
extern uint32_t default_layer_state;
|
||||||
|
|
||||||
#ifndef NO_ACTION_LAYER
|
#ifndef NO_ACTION_LAYER
|
||||||
|
@ -59,7 +62,7 @@ extern uint32_t default_layer_state;
|
||||||
#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
|
#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void send_string(char str[]);
|
void send_string(const char *str);
|
||||||
|
|
||||||
void matrix_init_kb(void);
|
void matrix_init_kb(void);
|
||||||
void matrix_scan_kb(void);
|
void matrix_scan_kb(void);
|
||||||
|
@ -79,4 +82,4 @@ void audio_on_user(void);
|
||||||
void music_on_user(void);
|
void music_on_user(void);
|
||||||
void music_scale_user(void);
|
void music_scale_user(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue