Compare commits
No commits in common. "bf6faeb94fa38f9e44b028474b5a413fe5d82942" and "7835772425a05116c68b6974653282ce9276c70e" have entirely different histories.
bf6faeb94f
...
7835772425
|
@ -4,13 +4,3 @@
|
|||
|
||||
extern const int8_t fft_array_to_col[4][14];
|
||||
extern const int8_t fft_col_to_array[10][5];
|
||||
|
||||
extern uint8_t layer_layouts[];
|
||||
|
||||
// Language keymap ids for layers.
|
||||
// See layers/definitions/symbols.h.
|
||||
enum layer_layout_ids {
|
||||
LAYOUT_NULL, // This layer doesn't care what keymap the OS is using
|
||||
LAYOUT_EN, // This layer is designed for the standard keymapping
|
||||
LAYOUT_RU,
|
||||
};
|
||||
|
|
|
@ -1,71 +1,11 @@
|
|||
#ifdef BETA_ENABLE_SPELLCHECK
|
||||
|
||||
#include "keymap_russian.h"
|
||||
#include "keymap_us_international.h"
|
||||
|
||||
#include "features/spellcheck.h"
|
||||
#include "features/beta_rawhid.h"
|
||||
#include "extra_mappings.h"
|
||||
|
||||
uint8_t spellcheck_buffer[SPELLCHECK_BUFFER_MAX] = {0};
|
||||
uint8_t spellcheck_buffer_size = 0;
|
||||
|
||||
// Return one of the following.
|
||||
#define SPELLCHECK_WORD 2
|
||||
#define SPELLCHECK_SPACE 1
|
||||
#define SPELLCHECK_NEITHER 0
|
||||
uint8_t keycode_type_en(uint8_t mods, uint16_t keycode) {
|
||||
if (
|
||||
KC_A <= keycode && keycode <= KC_Z // basic letters
|
||||
) {
|
||||
return SPELLCHECK_WORD;
|
||||
|
||||
} else if (
|
||||
( // Include these
|
||||
(KC_1 <= keycode && keycode <= KC_SLSH) || // Symbols
|
||||
// Treat " (shifted ') as a word boundary.
|
||||
((keycode == KC_QUOT) && ((mods & MOD_MASK_SHIFT) != 0))
|
||||
) && !( // Don't include these
|
||||
(keycode == KC_ESC) ||
|
||||
(keycode == KC_ENTER)
|
||||
)
|
||||
) {
|
||||
return SPELLCHECK_SPACE;
|
||||
|
||||
} else {
|
||||
return SPELLCHECK_NEITHER;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t keycode_type_ru(uint8_t mods, uint16_t keycode) {
|
||||
if (
|
||||
KC_A <= keycode && keycode <= KC_Z // basic letters
|
||||
) {
|
||||
return SPELLCHECK_WORD;
|
||||
} else if (
|
||||
KC_1 <= keycode && keycode <= KC_0
|
||||
) {
|
||||
return SPELLCHECK_SPACE;
|
||||
}
|
||||
|
||||
switch (keycode) {
|
||||
case RU_YO:
|
||||
case RU_HA:
|
||||
case RU_HARD:
|
||||
case RU_E:
|
||||
case RU_BE:
|
||||
case RU_YU:
|
||||
return SPELLCHECK_WORD;
|
||||
|
||||
case RU_MINS:
|
||||
case RU_EQL:
|
||||
case RU_DOT:
|
||||
case RU_BSLS:
|
||||
return SPELLCHECK_SPACE;
|
||||
}
|
||||
return SPELLCHECK_NEITHER;
|
||||
}
|
||||
|
||||
bool process_spellcheck(uint16_t keycode, keyrecord_t* record) {
|
||||
|
||||
|
||||
|
@ -131,52 +71,41 @@ bool process_spellcheck(uint16_t keycode, keyrecord_t* record) {
|
|||
return true; // Ignore these keys.
|
||||
}
|
||||
|
||||
|
||||
if (keycode == KC_BSPC) {
|
||||
// Remove last character from buffer
|
||||
if (spellcheck_buffer_size > 0) { --spellcheck_buffer_size; }
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t keycode_type;
|
||||
switch (layer_layouts[biton32(layer_state)]) {
|
||||
case LAYOUT_EN:
|
||||
keycode_type = keycode_type_en(mods, keycode);
|
||||
break;
|
||||
case LAYOUT_RU:
|
||||
keycode_type = keycode_type_ru(mods, keycode);
|
||||
break;
|
||||
default:
|
||||
keycode_type = SPELLCHECK_NEITHER;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch(keycode_type) {
|
||||
// No modifications are needed if this is a regular word character
|
||||
case SPELLCHECK_WORD:
|
||||
|
||||
// If the buffer is full, rotate it to discard the oldest character.
|
||||
if (spellcheck_buffer_size >= SPELLCHECK_BUFFER_MAX) {
|
||||
memmove(spellcheck_buffer, spellcheck_buffer + 1, SPELLCHECK_BUFFER_MAX - 1);
|
||||
spellcheck_buffer_size = SPELLCHECK_BUFFER_MAX - 1;
|
||||
}
|
||||
|
||||
spellcheck_buffer[spellcheck_buffer_size++] = (uint8_t) keycode;
|
||||
if (keycode == KC_QUOT) {
|
||||
// Treat " (shifted ') as a word boundary.
|
||||
if ((mods & MOD_MASK_SHIFT) != 0) { keycode = KC_SPC; }
|
||||
} else if (!(KC_A <= keycode && keycode <= KC_Z)) {
|
||||
if (keycode == KC_BSPC) {
|
||||
// Remove last character from the buffer.
|
||||
if (spellcheck_buffer_size > 0) { --spellcheck_buffer_size; }
|
||||
return true;
|
||||
|
||||
case SPELLCHECK_SPACE:
|
||||
// If this is a word break, send word and reset buffer
|
||||
if (spellcheck_buffer_size > 0) {
|
||||
hid_send_word();
|
||||
spellcheck_buffer_size = 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
case SPELLCHECK_NEITHER:
|
||||
} else if (KC_1 <= keycode && keycode <= KC_SLSH && keycode != KC_ESC) {
|
||||
// Set a word boundary if space, period, digit, etc. is pressed.
|
||||
// Behave more conservatively for the enter key. Reset, so that enter
|
||||
// can't be used on a word ending.
|
||||
if (keycode == KC_ENT) { spellcheck_buffer_size = 0; }
|
||||
keycode = KC_SPC;
|
||||
} else {
|
||||
// Clear state if some other non-alpha key is pressed.
|
||||
spellcheck_buffer_size = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the buffer is full, rotate it to discard the oldest character.
|
||||
if (spellcheck_buffer_size >= SPELLCHECK_BUFFER_MAX) {
|
||||
memmove(spellcheck_buffer, spellcheck_buffer + 1, SPELLCHECK_BUFFER_MAX - 1);
|
||||
spellcheck_buffer_size = SPELLCHECK_BUFFER_MAX - 1;
|
||||
}
|
||||
|
||||
// NOTE: `keycode` must be a basic keycode (0-255) by this point.
|
||||
|
||||
// A to Z keycodes
|
||||
if (keycode >= 0x04 && keycode <= 0x1D) {
|
||||
spellcheck_buffer[spellcheck_buffer_size++] = (uint8_t) keycode;
|
||||
} else if (spellcheck_buffer_size > 0) {
|
||||
hid_send_word();
|
||||
spellcheck_buffer_size = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -22,6 +22,14 @@ extern rgb_config_t rgb_matrix_config;
|
|||
#define LC_RU_G LC_HSV(153, 255, 153)
|
||||
#define LC_RU_K LC_HSV( 0, 255, 145)
|
||||
|
||||
// Language keymap ids for layers.
|
||||
// See layers/definitions/symbols.h.
|
||||
enum layer_layout_ids {
|
||||
LAYOUT_NULL, // This layer doesn't care what keymap the OS is using
|
||||
LAYOUT_EN, // This layer is designed for the standard keymapping
|
||||
LAYOUT_RU,
|
||||
};
|
||||
|
||||
// Define custom keys
|
||||
// (Must be done before keymaps are loaded)
|
||||
enum custom_keycodes {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
// What OS keyboard layout this layer is designed for.
|
||||
// See extra_mappings.h for possible values.
|
||||
// See keymap.h for possible values.
|
||||
//
|
||||
// Every layer must have this section.
|
||||
#ifdef BETA_LAYER_LAYOUTS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "layers.h"
|
||||
#include "extra_mappings.h"
|
||||
|
||||
|
||||
// Create keymap array
|
||||
#define BETA_LAYER_KEYS
|
||||
|
@ -49,7 +49,7 @@ void set_layer_color(int layer) {
|
|||
|
||||
|
||||
|
||||
void rgb_matrix_indicators_user(void) {
|
||||
void set_layer_matrix_indicator(void) {
|
||||
if (keyboard_config.disable_layer_led) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue