Compare commits
3 Commits
7835772425
...
bf6faeb94f
Author | SHA1 | Date |
---|---|---|
Mark | bf6faeb94f | |
Mark | c757a1686c | |
Mark | 7be80e97fd |
|
@ -3,4 +3,14 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
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,
|
||||||
|
};
|
||||||
|
|
|
@ -1,11 +1,71 @@
|
||||||
#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) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,41 +131,52 @@ bool process_spellcheck(uint16_t keycode, keyrecord_t* record) {
|
||||||
return true; // Ignore these keys.
|
return true; // Ignore these keys.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == KC_QUOT) {
|
|
||||||
// Treat " (shifted ') as a word boundary.
|
if (keycode == KC_BSPC) {
|
||||||
if ((mods & MOD_MASK_SHIFT) != 0) { keycode = KC_SPC; }
|
// Remove last character from buffer
|
||||||
} else if (!(KC_A <= keycode && keycode <= KC_Z)) {
|
if (spellcheck_buffer_size > 0) { --spellcheck_buffer_size; }
|
||||||
if (keycode == KC_BSPC) {
|
return true;
|
||||||
// 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) {
|
|
||||||
// Set a word boundary if space, period, digit, etc. is pressed.
|
case SPELLCHECK_SPACE:
|
||||||
// Behave more conservatively for the enter key. Reset, so that enter
|
// If this is a word break, send word and reset buffer
|
||||||
// can't be used on a word ending.
|
if (spellcheck_buffer_size > 0) {
|
||||||
if (keycode == KC_ENT) { spellcheck_buffer_size = 0; }
|
hid_send_word();
|
||||||
keycode = KC_SPC;
|
spellcheck_buffer_size = 0;
|
||||||
} else {
|
}
|
||||||
// Clear state if some other non-alpha key is pressed.
|
return true;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
|
@ -22,14 +22,6 @@ 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 {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
// What OS keyboard layout this layer is designed for.
|
// What OS keyboard layout this layer is designed for.
|
||||||
// See keymap.h for possible values.
|
// See extra_mappings.h for possible values.
|
||||||
//
|
//
|
||||||
// Every layer must have this section.
|
// Every layer must have this section.
|
||||||
#ifdef BETA_LAYER_LAYOUTS
|
#ifdef BETA_LAYER_LAYOUTS
|
||||||
|
|
|
@ -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 set_layer_matrix_indicator(void) {
|
void rgb_matrix_indicators_user(void) {
|
||||||
if (keyboard_config.disable_layer_led) {
|
if (keyboard_config.disable_layer_led) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue