diff options
Diffstat (limited to 'users')
51 files changed, 173 insertions, 1145 deletions
diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index da85d4f6d4..00abbf2ae3 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -190,7 +190,7 @@ void set_os (uint8_t os, bool update) { } switch (os) { case OS_MAC: - set_unicode_input_mode(UC_OSX); + set_unicode_input_mode(UC_MAC); underglow = (Color){ 213, 255, 255 }; break; case OS_WIN: diff --git a/users/bbaserdem/bb-rgb.c b/users/bbaserdem/bb-rgb.c index bdb7f12bbd..49b91129ba 100644 --- a/users/bbaserdem/bb-rgb.c +++ b/users/bbaserdem/bb-rgb.c @@ -23,7 +23,7 @@ // Allow hooking into the RGB matrix indications using keymap code -// Modulates the brightness of indicator +// Modulates the brightness of indicator RGB helper_dimmer(uint8_t r, uint8_t g, uint8_t b) { RGB output; output.r = r / 2; @@ -63,12 +63,12 @@ __attribute__ ((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_mi return false; } // Set RGB state depending on layer -void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { uint8_t thisInd = 3; RGB thisCol; // Load keymap hooks if(rgb_matrix_indicators_advanced_keymap(led_min, led_max)) { - return; + return false; } // Grab color info switch (get_highest_layer(layer_state)) { @@ -110,6 +110,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { break; } helper_painter(led_min, led_max, thisCol, thisInd); + return false; } // Hook into shutdown code to make all perkey LED's red on hitting reset @@ -120,11 +121,3 @@ void shutdown_rgb(void) { // Delay until this registers while(timer_elapsed(timer_start) < 250) {wait_ms(1);} } - -// Hook into suspend code -void suspend_power_down_rgb(void) { - rgb_matrix_set_suspend_state(true); -} -void suspend_wakeup_init_rgb(void) { - rgb_matrix_set_suspend_state(false); -} diff --git a/users/bbaserdem/bb-rgb.h b/users/bbaserdem/bb-rgb.h index 62b6da9f2f..3e96b997fe 100644 --- a/users/bbaserdem/bb-rgb.h +++ b/users/bbaserdem/bb-rgb.h @@ -21,7 +21,7 @@ */ // For custom indicators -void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); // Hook into shutdown code void shutdown_rgb(void); void suspend_wakeup_init_rgb(void); diff --git a/users/bbaserdem/config.h b/users/bbaserdem/config.h index 477378102b..3c467d5e7d 100644 --- a/users/bbaserdem/config.h +++ b/users/bbaserdem/config.h @@ -121,7 +121,7 @@ // For perkey leds #ifdef RGB_MATRIX_ENABLE // This is not working -//# define RGB_DISABLE_TIMEOUT 1800000 +//# define RGB_MATRIX_TIMEOUT 1800000 # define RGB_DISABLE_WHEN_USB_SUSPENDED true // Start using this mode # define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_RAINBOW_BEACON diff --git a/users/brandonschlack/rgb_bs.c b/users/brandonschlack/rgb_bs.c index 1abf785b49..6b88503f41 100644 --- a/users/brandonschlack/rgb_bs.c +++ b/users/brandonschlack/rgb_bs.c @@ -75,7 +75,7 @@ void rgb_theme_step_reverse(void) { rgb_theme_color_t get_rgb_theme_color(uint8_t index) { rgb_theme_t theme = get_rgb_theme(); - size_t rgb_theme_color_max = sizeof theme.colors / sizeof *theme.colors; + size_t rgb_theme_color_max = ARRAY_SIZE(theme.colors); if (index == _ADJUST) { return default_adjust; @@ -98,7 +98,7 @@ void rgb_theme_layer(layer_state_t state) { #ifdef RGB_MATRIX_ENABLE void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, uint8_t led_type) { - for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { if (!HAS_ANY_FLAGS(g_led_config.flags[i], led_type)) { rgb_matrix_set_color( i, red, green, blue ); } diff --git a/users/byungyoonc/saturated_solid_multisplash.h b/users/byungyoonc/saturated_solid_multisplash.h index f302348524..c6850a7873 100644 --- a/users/byungyoonc/saturated_solid_multisplash.h +++ b/users/byungyoonc/saturated_solid_multisplash.h @@ -43,7 +43,7 @@ static bool saturated_solid_multisplash(effect_params_t* params) { RGB rgb = rgb_matrix_hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } - return led_max < DRIVER_LED_TOTAL; + return led_max < RGB_MATRIX_LED_COUNT; } # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/users/curry/oled.c b/users/curry/oled.c index 5a8f0de61d..89112af121 100644 --- a/users/curry/oled.c +++ b/users/curry/oled.c @@ -41,7 +41,7 @@ void add_keylog(uint16_t keycode) { keylog_str[i] = keylog_str[i - 1]; } - if (keycode < (sizeof(code_to_name) / sizeof(char))) { + if (keycode < ARRAY_SIZE(code_to_name)) { keylog_str[0] = pgm_read_byte(&code_to_name[keycode]); } diff --git a/users/curry/rgb_matrix_user.c b/users/curry/rgb_matrix_user.c index 96f1f1d4f3..3c2008aa01 100644 --- a/users/curry/rgb_matrix_user.c +++ b/users/curry/rgb_matrix_user.c @@ -36,7 +36,7 @@ void check_default_layer(uint8_t mode, uint8_t type) { } } -void rgb_matrix_indicators_user(void) { +bool rgb_matrix_indicators_user(void) { if (userspace_config.rgb_layer_change && rgb_matrix_config.enable) { switch (get_highest_layer(layer_state)) { case _RAISE: @@ -55,6 +55,7 @@ void rgb_matrix_indicators_user(void) { } check_default_layer(0, LED_FLAG_MODIFIER); } + return false; } bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { @@ -131,7 +132,7 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode uint16_t time = scale16by8(RGBLED_NUM, speed / 8); hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); RGB rgb = hsv_to_rgb(hsv); - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { + for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { if (HAS_FLAGS(g_led_config.flags[i], led_type)) { rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } @@ -141,7 +142,7 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode default: // Solid Color { RGB rgb = hsv_to_rgb(hsv); - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { + for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { if (HAS_FLAGS(g_led_config.flags[i], led_type)) { rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/users/davidkristoffersen/util/functions.c b/users/davidkristoffersen/util/functions.c index 781d8f214d..3ab4ace2d6 100644 --- a/users/davidkristoffersen/util/functions.c +++ b/users/davidkristoffersen/util/functions.c @@ -33,14 +33,14 @@ code_set_t EN_SHIFT_CODES [] = { const shift_code_t SHIFT_CODES [] = { #ifdef LAYER_NO {.lang = LAYER_NO, - .size = ARR_LEN(NO_SHIFT_CODES), + .size = ARRAY_SIZE(NO_SHIFT_CODES), .codes = NO_SHIFT_CODES}, #endif {.lang = LAYER_EN, - .size = ARR_LEN(EN_SHIFT_CODES), + .size = ARRAY_SIZE(EN_SHIFT_CODES), .codes = EN_SHIFT_CODES}, }; -const int SHIFT_CODES_SIZE = ARR_LEN(SHIFT_CODES); +const int SHIFT_CODES_SIZE = ARRAY_SIZE(SHIFT_CODES); #endif #ifdef LAYER_NO @@ -72,7 +72,7 @@ const code_set_t EN2NO_CODES [] = { {KC_DLR, NO_DLR}, {KC_GRV, NO_GRV} }; -const int EN2NO_CODES_SIZE = ARR_LEN(EN2NO_CODES); +const int EN2NO_CODES_SIZE = ARRAY_SIZE(EN2NO_CODES); #endif // Check if layer is an active default layer diff --git a/users/davidkristoffersen/util/functions.h b/users/davidkristoffersen/util/functions.h index eee1dadc57..5fef010694 100644 --- a/users/davidkristoffersen/util/functions.h +++ b/users/davidkristoffersen/util/functions.h @@ -15,8 +15,6 @@ // Return false if test equal false #define HANDLE_FALSE(bool) if (!bool) return false; -// Generic array lenght define -#define ARR_LEN(arr) (sizeof(arr) / sizeof(arr)[0]) // Printf-like functionality for send_string #define SEND_VAR(str, ...) \ do { \ diff --git a/users/drashna/callbacks.c b/users/drashna/callbacks.c index 111b5f79d7..40383f124f 100644 --- a/users/drashna/callbacks.c +++ b/users/drashna/callbacks.c @@ -49,7 +49,7 @@ void keyboard_post_init_user(void) { keyboard_post_init_transport_sync(); #endif #ifdef I2C_SCANNER_ENABLE - matrix_scan_i2c(); + keyboard_post_init_i2c(); #endif keyboard_post_init_keymap(); diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 91f3a06b7c..d63f05b590 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -129,3 +129,15 @@ void keyboard_post_init_i2c(void) { scan_timer = timer_read(); } #endif + +#if defined(AUTOCORRECT_ENABLE) && defined(AUDIO_ENABLE) +# ifdef USER_SONG_LIST +float autocorrect_song[][2] = SONG(MARIO_GAMEOVER); +# else +float autocorrect_song[][2] = SONG(PLOVER_GOODBYE_SOUND); +# endif +bool apply_autocorrect(uint8_t backspaces, const char *str) { + PLAY_SONG(autocorrect_song); + return true; +} +#endif diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c deleted file mode 100644 index 90fdba8f5e..0000000000 --- a/users/drashna/keyrecords/autocorrection/autocorrection.c +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright 2021 Google LLC -// Copyright 2021 @filterpaper -// SPDX-License-Identifier: Apache-2.0 -// Original source: https://getreuer.info/posts/keyboards/autocorrection - -#include "autocorrection.h" -#include <string.h> - -#if __has_include("autocorrection_data.h") -# pragma GCC push_options -# pragma GCC optimize("O0") -# include "autocorrection_data.h" -# ifndef AUTOCORRECTION_MIN_LENGTH -# define AUTOCORRECTION_MIN_LENGTH AUTOCORRECT_MIN_LENGTH -# endif -# ifndef AUTOCORRECTION_MAX_LENGTH -# define AUTOCORRECTION_MAX_LENGTH AUTOCORRECT_MAX_LENGTH -# endif -# define autocorrection_data autocorrect_data -# if AUTOCORRECTION_MIN_LENGTH < 4 -# error Minimum Length is too short and may cause overflows -# endif -# if DICTIONARY_SIZE > SIZE_MAX -# error Dictionary size excees maximum size permitted -# endif - -static uint8_t typo_buffer[AUTOCORRECT_MAX_LENGTH] = {KC_SPC}; -static uint8_t typo_buffer_size = 1; - -/** - * @brief function for querying the enabled state of autocorrect - * - * @return true if enabled - * @return false if disabled - */ -bool autocorrect_is_enabled(void) { - return userspace_config.autocorrection; -} - -/** - * @brief Enables autocorrect and saves state to eeprom - * - */ -void autocorrect_enable(void) { - userspace_config.autocorrection = true; - eeconfig_update_user(userspace_config.raw); -} - -/** - * @brief Disables autocorrect and saves state to eeprom - * - */ -void autocorrect_disable(void) { - userspace_config.autocorrection = false; - typo_buffer_size = 0; - eeconfig_update_user(userspace_config.raw); -} - -/** - * @brief Toggles autocorrect's status and save state to eeprom - * - */ -void autocorrect_toggle(void) { - userspace_config.autocorrection = !userspace_config.autocorrection; - typo_buffer_size = 0; - eeconfig_update_user(userspace_config.raw); -} - -/** - * @brief handler for determining if autocorrect should process keypress - * - * @param keycode Keycode registered by matrix press, per keymap - * @param record keyrecord_t structure - * @param typo_buffer_size passed along to allow resetting of autocorrect buffer - * @param mods allow processing of mod status - * @return true Allow autocorection - * @return false Stop processing and escape from autocorrect. - */ -__attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) { - // See quantum_keycodes.h for reference on these matched ranges. - switch (*keycode) { - // Exclude these keycodes from processing. - case KC_LSFT: - case KC_RSFT: - case KC_CAPS: - case QK_TO ... QK_ONE_SHOT_LAYER_MAX: - case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX: - case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: - return false; - - // Mask for base keycode from shifted keys. - case QK_LSFT ... QK_LSFT + 255: - case QK_RSFT ... QK_RSFT + 255: - if (*keycode >= QK_LSFT && *keycode <= (QK_LSFT + 255)) { - *mods |= MOD_LSFT; - } else { - *mods |= MOD_RSFT; - } - *keycode &= 0xFF; // Get the basic keycode. - return true; -# ifndef NO_ACTION_TAPPING - // Exclude tap-hold keys when they are held down - // and mask for base keycode when they are tapped. - case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: -# ifdef NO_ACTION_LAYER - // Exclude Layer Tap, if layers are disabled - // but action tapping is still enabled. - return false; -# endif - case QK_MOD_TAP ... QK_MOD_TAP_MAX: - // Exclude hold keycode - if (!record->tap.count) { - return false; - } - *keycode &= 0xFF; - break; -# else - case QK_MOD_TAP ... QK_MOD_TAP_MAX: - case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: - // Exclude if disabled - return false; -# endif - // Exclude swap hands keys when they are held down - // and mask for base keycode when they are tapped. - case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: -# ifdef SWAP_HANDS_ENABLE - if (*keycode >= 0x56F0 || !record->tap.count) { - return false; - } - *keycode &= 0xFF; - break; -# else - // Exclude if disabled - return false; -# endif - } - - // Disable autocorrect while a mod other than shift is active. - if ((*mods & ~MOD_MASK_SHIFT) != 0) { - *typo_buffer_size = 0; - return false; - } - - return true; -} - -/** - * @brief handling for when autocorrection has been triggered - * - * @param backspaces number of characters to remove - * @param str pointer to PROGMEM string to replace mistyped seletion with - * @return true apply correction - * @return false user handled replacement - */ -__attribute__((weak)) bool apply_autocorrect(uint8_t backspaces, const char *str) { - return true; -} - -/** - * @brief Process handler for autocorrect feature - * - * @param keycode Keycode registered by matrix press, per keymap - * @param record keyrecord_t structure - * @return true Continue processing keycodes, and send to host - * @return false Stop processing keycodes, and don't send to host - */ -bool process_autocorrection(uint16_t keycode, keyrecord_t *record) { - uint8_t mods = get_mods(); -# ifndef NO_ACTION_ONESHOT - mods |= get_oneshot_mods(); -# endif - - if ((keycode >= AUTOCORRECT_ON && keycode <= AUTOCORRECT_TOGGLE) && record->event.pressed) { - if (keycode == AUTOCORRECT_ON) { - autocorrect_enable(); - } else if (keycode == AUTOCORRECT_OFF) { - autocorrect_disable(); - } else if (keycode == AUTOCORRECT_TOGGLE) { - autocorrect_toggle(); - } else { - return true; - } - - return false; - } - - if (!autocorrect_is_enabled()) { - typo_buffer_size = 0; - return true; - } - - if (!record->event.pressed) { - return true; - } - - // autocorrect keycode verification and extraction - if (!process_autocorrect_user(&keycode, record, &typo_buffer_size, &mods)) { - return true; - } - - // keycode buffer check - switch (keycode) { - case KC_A ... KC_Z: - // process normally - break; - case KC_1 ... KC_0: - case KC_TAB ... KC_SEMICOLON: - case KC_GRAVE ... KC_SLASH: - // Set a word boundary if space, period, digit, etc. is pressed. - keycode = KC_SPC; - break; - case KC_ENTER: - // Behave more conservatively for the enter key. Reset, so that enter - // can't be used on a word ending. - typo_buffer_size = 0; - keycode = KC_SPC; - break; - case KC_BSPC: - // Remove last character from the buffer. - if (typo_buffer_size > 0) { - --typo_buffer_size; - } - return true; - case KC_QUOTE: - // Treat " (shifted ') as a word boundary. - if ((mods & MOD_MASK_SHIFT) != 0) { - keycode = KC_SPC; - } - break; - default: - // Clear state if some other non-alpha key is pressed. - typo_buffer_size = 0; - return true; - } - - // Rotate oldest character if buffer is full. - if (typo_buffer_size >= AUTOCORRECT_MAX_LENGTH) { - memmove(typo_buffer, typo_buffer + 1, AUTOCORRECT_MAX_LENGTH - 1); - typo_buffer_size = AUTOCORRECT_MAX_LENGTH - 1; - } - - // Append `keycode` to buffer. - typo_buffer[typo_buffer_size++] = keycode; - // Return if buffer is smaller than the shortest word. - if (typo_buffer_size < AUTOCORRECT_MIN_LENGTH) { - return true; - } - - // Check for typo in buffer using a trie stored in `autocorrect_data`. - uint16_t state = 0; - uint8_t code = pgm_read_byte(autocorrect_data + state); - for (int8_t i = typo_buffer_size - 1; i >= 0; --i) { - uint8_t const key_i = typo_buffer[i]; - - if (code & 64) { // Check for match in node with multiple children. - code &= 63; - for (; code != key_i; code = pgm_read_byte(autocorrect_data + (state += 3))) { - if (!code) return true; - } - // Follow link to child node. - state = (pgm_read_byte(autocorrect_data + state + 1) | pgm_read_byte(autocorrect_data + state + 2) << 8); - // Check for match in node with single child. - } else if (code != key_i) { - return true; - } else if (!(code = pgm_read_byte(autocorrect_data + (++state)))) { - ++state; - } - - // Stop if `state` becomes an invalid index. This should not normally - // happen, it is a safeguard in case of a bug, data corruption, etc. - if (state >= DICTIONARY_SIZE) { - return true; - } - - code = pgm_read_byte(autocorrect_data + state); - - if (code & 128) { // A typo was found! Apply autocorrect. - const uint8_t backspaces = (code & 63) + !record->event.pressed; - if (apply_autocorrect(backspaces, (char const *)(autocorrect_data + state + 1))) { - for (uint8_t i = 0; i < backspaces; ++i) { - tap_code(KC_BSPC); - } - send_string_P((char const *)(autocorrect_data + state + 1)); - } - - if (keycode == KC_SPC) { - typo_buffer[0] = KC_SPC; - typo_buffer_size = 1; - return true; - } else { - typo_buffer_size = 0; - return false; - } - } - } - return true; -} -# pragma GCC pop_options -#else -# pragma message "Warning!!! Autocorrect is not corretly setup!" -bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { - return true; -} -#endif diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.h b/users/drashna/keyrecords/autocorrection/autocorrection.h deleted file mode 100644 index 8946b91f1f..0000000000 --- a/users/drashna/keyrecords/autocorrection/autocorrection.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 Google LLC -// Copyright 2021 @filterpaper -// SPDX-License-Identifier: Apache-2.0 -// Original source: https://getreuer.info/posts/keyboards/autocorrection - -#pragma once - -#include "drashna.h" - -bool process_autocorrection(uint16_t keycode, keyrecord_t *record); -bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); -bool apply_autocorrect(uint8_t backspaces, const char *str); - -bool autocorrect_is_enabled(void); -void autocorrect_enable(void); -void autocorrect_disable(void); -void autocorrect_toggle(void); diff --git a/users/drashna/keyrecords/autocorrection/autocorrection_data.h b/users/drashna/keyrecords/autocorrection/autocorrection_data.h deleted file mode 100644 index 90484d3b12..0000000000 --- a/users/drashna/keyrecords/autocorrection/autocorrection_data.h +++ /dev/null @@ -1 +0,0 @@ -#include "autocorrect_data.h" diff --git a/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py b/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py deleted file mode 100755 index 0dd9b78b9c..0000000000 |