Compare commits

..

No commits in common. "bf6faeb94fa38f9e44b028474b5a413fe5d82942" and "7835772425a05116c68b6974653282ce9276c70e" have entirely different histories.

5 changed files with 43 additions and 116 deletions

View File

@ -4,13 +4,3 @@
extern const int8_t fft_array_to_col[4][14]; extern const int8_t fft_array_to_col[4][14];
extern const int8_t fft_col_to_array[10][5]; 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,
};

View File

@ -1,71 +1,11 @@
#ifdef BETA_ENABLE_SPELLCHECK #ifdef BETA_ENABLE_SPELLCHECK
#include "keymap_russian.h"
#include "keymap_us_international.h"
#include "features/spellcheck.h" #include "features/spellcheck.h"
#include "features/beta_rawhid.h" #include "features/beta_rawhid.h"
#include "extra_mappings.h"
uint8_t spellcheck_buffer[SPELLCHECK_BUFFER_MAX] = {0}; uint8_t spellcheck_buffer[SPELLCHECK_BUFFER_MAX] = {0};
uint8_t spellcheck_buffer_size = 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) { 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. return true; // Ignore these keys.
} }
if (keycode == KC_QUOT) {
if (keycode == KC_BSPC) { // Treat " (shifted ') as a word boundary.
// Remove last character from buffer if ((mods & MOD_MASK_SHIFT) != 0) { keycode = KC_SPC; }
if (spellcheck_buffer_size > 0) { --spellcheck_buffer_size; } } else if (!(KC_A <= keycode && keycode <= KC_Z)) {
return true; if (keycode == KC_BSPC) {
} // Remove last character from the buffer.
if (spellcheck_buffer_size > 0) { --spellcheck_buffer_size; }
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;
return true; return true;
} else if (KC_1 <= keycode && keycode <= KC_SLSH && keycode != KC_ESC) {
case SPELLCHECK_SPACE: // Set a word boundary if space, period, digit, etc. is pressed.
// If this is a word break, send word and reset buffer // Behave more conservatively for the enter key. Reset, so that enter
if (spellcheck_buffer_size > 0) { // can't be used on a word ending.
hid_send_word(); if (keycode == KC_ENT) { spellcheck_buffer_size = 0; }
spellcheck_buffer_size = 0; keycode = KC_SPC;
} } else {
return true; // Clear state if some other non-alpha key is pressed.
case SPELLCHECK_NEITHER:
spellcheck_buffer_size = 0; spellcheck_buffer_size = 0;
return true; 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; return true;

View File

@ -22,6 +22,14 @@ extern rgb_config_t rgb_matrix_config;
#define LC_RU_G LC_HSV(153, 255, 153) #define LC_RU_G LC_HSV(153, 255, 153)
#define LC_RU_K LC_HSV( 0, 255, 145) #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 // Define custom keys
// (Must be done before keymaps are loaded) // (Must be done before keymaps are loaded)
enum custom_keycodes { enum custom_keycodes {

View File

@ -14,7 +14,7 @@
// What OS keyboard layout this layer is designed for. // 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. // Every layer must have this section.
#ifdef BETA_LAYER_LAYOUTS #ifdef BETA_LAYER_LAYOUTS

View File

@ -1,5 +1,5 @@
#include "layers.h" #include "layers.h"
#include "extra_mappings.h"
// Create keymap array // Create keymap array
#define BETA_LAYER_KEYS #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) { if (keyboard_config.disable_layer_led) {
return; return;
} }