diff options
Diffstat (limited to 'quantum')
32 files changed, 1099 insertions, 508 deletions
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 2bcc27b4a1..805cb4f7ab 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -99,9 +99,6 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); // length. This works around the limitation of C's sizeof operation on pointers. // The global float array for the song must be used here. #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) -#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) \ - play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ - _Pragma("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") #define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false) #define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true) diff --git a/quantum/audio/audio_avr.c b/quantum/audio/audio_avr.c index 781378788c..5a96bf6439 100644 --- a/quantum/audio/audio_avr.c +++ b/quantum/audio/audio_avr.c @@ -110,6 +110,11 @@ # define TIMER_1_DUTY_CYCLE OCR1C # define TIMER1_AUDIO_vect TIMER1_COMPC_vect #endif + +#if !defined(BPIN_AUDIO) && !defined(CPIN_AUDIO) +# error "Audio feature enabled, but no suitable pin selected - see docs/feature_audio.md under the AVR settings for available options." +#endif + // ----------------------------------------------------------------------------- int voices = 0; diff --git a/quantum/keymap_extras/keymap_belgian.h b/quantum/keymap_extras/keymap_belgian.h index c6363a4377..b65db0532b 100644 --- a/quantum/keymap_extras/keymap_belgian.h +++ b/quantum/keymap_extras/keymap_belgian.h @@ -67,7 +67,7 @@ #define BE_F KC_F // F #define BE_G KC_G // G #define BE_H KC_H // H -#define BE_J KC_K // J +#define BE_J KC_J // J #define BE_K KC_K // K #define BE_L KC_L // L #define BE_M KC_SCLN // M diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h index 4fc174e735..d980dc2e41 100644 --- a/quantum/keymap_extras/keymap_canadian_multilingual.h +++ b/quantum/keymap_extras/keymap_canadian_multilingual.h @@ -1,4 +1,4 @@ -/* Copyright 2016 Didier Loiseau +/* Copyright 2020 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,247 +13,421 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef KEYMAP_CANADIAN_MULTILINGUAL_H -#define KEYMAP_CANADIAN_MULTILINGUAL_H -#include "keymap.h" - -#ifndef GR2A -# define GR2A(kc) RCTL(kc) -#endif - -// Normal characters -// First row -#define CSA_SLASH KC_GRV // / -#define CSA_SLSH CSA_SLASH - -// Second row -#define CSA_DEAD_CIRCUMFLEX KC_LBRACKET // dead ^ -#define CSA_DCRC CSA_DEAD_CIRCUMFLEX -#define CSA_C_CEDILLA KC_RBRACKET // Ç -#define CSA_CCED CSA_C_CEDILLA - -// Third row -#define CSA_E_GRAVE KC_QUOT // è -#define CSA_EGRV CSA_E_GRAVE -#define CSA_A_GRAVE KC_BSLASH // à -#define CSA_AGRV CSA_A_GRAVE - -// Fourth row -#define CSA_U_GRAVE KC_NONUS_BSLASH // ù -#define CSA_UGRV CSA_U_GRAVE -#define CSA_E_ACUTE KC_SLSH // é -#define CSA_ECUT CSA_E_ACUTE - -// Shifted characters -// First row -#define CSA_BACKSLASH LSFT(CSA_SLASH) /* \ */ -#define CSA_BSLS CSA_BACKSLASH -#define CSA_QUESTION LSFT(KC_6) // ? -#define CSA_QEST CSA_QUESTION - -// Second row -#define CSA_DEAD_TREMA LSFT(CSA_DEAD_CIRCUMFLEX) // dead trema/umlaut/diaresis for ä ë ï ö ü -#define CSA_DTRM CSA_DEAD_TREMA - -// Third row -// all same as US-QWERTY, or capitalised character of the non-shifted key - -// Fourth row -#define CSA_APOSTROPHE LSFT(KC_COMMA) // ' -#define CSA_APOS CSA_APOSTROPHE -#define CSA_DOUBLE_QUOTE LSFT(KC_DOT) // " -#define CSA_DQOT CSA_DOUBLE_QUOTE - -// Alt Gr-ed characters -// First row -#define CSA_PIPE ALGR(CSA_SLASH) // | -#define CSA_CURRENCY ALGR(KC_4) // ¤ -#define CSA_CURR CSA_CURRENCY -#define CSA_LEFT_CURLY_BRACE ALGR(KC_7) // { -#define CSA_LCBR CSA_LEFT_CURLY_BRACE -#define CSA_RIGHT_CURLY_BRACE ALGR(KC_8) // } -#define CSA_RCBR CSA_RIGHT_CURLY_BRACE -#define CSA_LBRACKET ALGR(KC_9) // [ -#define CSA_LBRC CSA_LBRACKET -#define CSA_RBRACKET ALGR(KC_0) // ] -#define CSA_RBRC CSA_RBRACKET -#define CSA_NEGATION ALGR(KC_EQUAL) // ¬ -#define CSA_NEGT CSA_NEGATION +#pragma once -// Second row -// euro symbol not available on Linux? (X.org) -#define CSA_EURO ALGR(KC_E) // € -#define CSA_DEAD_GRAVE ALGR(CSA_DEAD_CIRCUMFLEX) -#define CSA_DGRV CSA_DEAD_GRAVE // dead ` -#define CSA_DEAD_TILDE ALGR(CSA_C_CEDILLA) // ~ -#define CSA_DTLD CSA_DEAD_TILDE - -// Third row -#define CSA_DEGREE ALGR(KC_SCOLON) // ° -#define CSA_DEGR CSA_DEGREE - -// Fourth row -#define CSA_LEFT_GUILLEMET ALGR(KC_Z) // « -#define CSA_LGIL CSA_LEFT_GUILLEMET -#define CSA_RIGHT_GUILLEMET ALGR(KC_X) // » -#define CSA_RGIL CSA_RIGHT_GUILLEMET -#define CSA_LESS ALGR(KC_COMMA) // < -#define CSA_GREATER ALGR(KC_DOT) // > -#define CSA_GRTR CSA_GREATER - -// Space bar -#define CSA_NON_BREAKING_SPACE ALGR(KC_SPACE) -#define CSA_NBSP CSA_NON_BREAKING_SPACE - -// GR2A-ed characters -// First row -#define CSA_SUPERSCRIPT_ONE GR2A(KC_1) // ¹ -#define CSA_SUP1 CSA_SUPERSCRIPT_ONE -#define CSA_SUPERSCRIPT_TWO GR2A(KC_2) // ² -#define CSA_SUP2 CSA_SUPERSCRIPT_TWO -#define CSA_SUPERSCRIPT_THREE GR2A(KC_3) // ³ -#define CSA_SUP3 CSA_SUPERSCRIPT_THREE -#define CSA_ONE_QUARTER GR2A(KC_4) // ¼ -#define CSA_1QRT CSA_ONE_QUARTER -#define CSA_ONE_HALF GR2A(KC_5) // ½ -#define CSA_1HLF CSA_ONE_HALF -#define CSA_THREE_QUARTERS GR2A(KC_6) // ¾ -#define CSA_3QRT CSA_THREE_QUARTERS -// nothing on 7-0 and - -#define CSA_DEAD_CEDILLA GR2A(KC_EQUAL) // dead ¸ -#define CSA_DCED CSA_DEAD_CEDILLA - -// Second row -#define CSA_OMEGA GR2A(KC_Q) // ω -#define CSA_OMEG CSA_OMEGA -#define CSA_L_STROKE GR2A(KC_W) // ł -#define CSA_LSTK CSA_L_STROKE -#define CSA_OE_LIGATURE GR2A(KC_E) // œ -#define CSA_OE CSA_OE_LIGATURE -#define CSA_PARAGRAPH GR2A(KC_R) // ¶ -#define CSA_PARG CSA_PARAGRAPH -#define CSA_T_STROKE GR2A(KC_T) // ŧ -#define CSA_LEFT_ARROW GR2A(KC_Y) // ← -#define CSA_LARW CSA_LEFT_ARROW -#define CSA_DOWN_ARROW GR2A(KC_U) // ↓ -#define CSA_DARW CSA_DOWN_ARROW -#define CSA_RIGHT_ARROW GR2A(KC_I) // → -#define CSA_RARW CSA_RIGHT_ARROW -#define CSA_O_STROKE GR2A(KC_O) // ø -#define CSA_OSTK CSA_O_STROKE -#define CSA_THORN GR2A(KC_P) // þ -#define CSA_THRN CSA_THORN -// nothing on ^ -#define CSA_TILDE GR2A(CSA_C_CEDILLA) // dead ~ -#define CSA_TILD CSA_TILDE +#include "keymap.h" -// Third row -#define CSA_AE_LIGATURE GR2A(KC_A) // æ -#define CSA_AE CSA_AE_LIGATURE -#define CSA_SHARP_S GR2A(KC_S) // ß -#define CSA_SRPS CSA_SHARP_S -#define CSA_ETH GR2A(KC_D) // ð -// nothing on F -#define CSA_ENG GR2A(KC_G) // ŋ -#define CSA_H_SRTOKE GR2A(KC_H) // ħ -#define CSA_HSTK CSA_H_SRTOKE -#define CSA_IJ_LIGATURE GR2A(KC_J) // ij -#define CSA_IJ CSA_IJ_LIGATURE -#define CSA_KRA GR2A(KC_K) // ĸ -#define CSA_L_FLOWN_DOT GR2A(KC_L) // ŀ -#define CSA_LFLD CSA_L_FLOWN_DOT -#define CSA_DEAD_ACUTE GR2A(KC_SCLN) // dead acute accent -#define CSA_DACT CSA_DEAD_ACUTE -// nothing on È & À +// clang-format off -// Fourth row -#define CSA_CENT GR2A(KC_C) // ¢ -#define CSA_LEFT_DOUBLE_QUOTE GR2A(KC_V) // “ -#define CSA_LDQT CSA_LEFT_DOUBLE_QUOTE -#define CSA_RIGHT_DOUBLE_QUOTE GR2A(KC_B) // ” -#define CSA_RDQT CSA_RIGHT_DOUBLE_QUOTE -#define CSA_N_APOSTROPHE GR2A(KC_N) // ʼn (deprecated unicode codepoint) -#define CSA_NAPO CSA_N_APOSTROPHE -#define CSA_MU GR2A(KC_M) // μ -#define CSA_HORIZONTAL_BAR GR2A(KC_COMMA) // ― -#define CSA_HZBR CSA_HORIZONTAL_BAR -#define CSA_DEAD_DOT_ABOVE GR2A(KC_DOT) // dead ˙ -#define CSA_DDTA CSA_DEAD_DOT_ABOVE +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ / │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ^ │ Ç │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ È │ À │ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │ Ù │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ É │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define CA_SLSH KC_GRV // / +#define CA_1 KC_1 // 1 +#define CA_2 KC_2 // 2 +#define CA_3 KC_3 // 3 +#define CA_4 KC_4 // 4 +#define CA_5 KC_5 // 5 +#define CA_6 KC_6 // 6 +#define CA_7 KC_7 // 7 +#define CA_8 KC_8 // 8 +#define CA_9 KC_9 // 9 +#define CA_0 KC_0 // 0 +#define CA_MINS KC_MINS // - +#define CA_EQL KC_EQL // = +// Row 2 +#define CA_Q KC_Q // Q +#define CA_W KC_W // W +#define CA_E KC_E // E +#define CA_R KC_R // R +#define CA_T KC_T // T +#define CA_Y KC_Y // Y +#define CA_U KC_U // U +#define CA_I KC_I // I +#define CA_O KC_O // O +#define CA_P KC_P // P +#define CA_CIRC KC_LBRC // ^ (dead) +#define CA_CCED KC_RBRC // Ç +// Row 3 +#define CA_A KC_A // A +#define CA_S KC_S // S +#define CA_D KC_D // D +#define CA_F KC_F // F +#define CA_G KC_G // G +#define CA_H KC_H // H +#define CA_J KC_J // J +#define CA_K KC_K // K +#define CA_L KC_L // L +#define CA_SCLN KC_SCLN // ; +#define CA_EGRV KC_QUOT // É +#define CA_AGRV KC_NUHS // À +// Row 4 +#define CA_UGRV KC_NUBS // Ù +#define CA_Z KC_Z // Z +#define CA_X KC_X // X +#define CA_C KC_C // C +#define CA_V KC_V // V +#define CA_B KC_B // B +#define CA_N KC_N // N +#define CA_M KC_M // M +#define CA_COMM KC_COMM // , +#define CA_DOT KC_DOT // . +#define CA_EACU KC_SLSH // É -// GR2A-shifted characters (different from capitalised GR2A-ed characters) -// First row -#define CSA_SOFT_HYPHEN GR2A(LSFT(CSA_SLASH)) // soft-hyphen, appears as a hyphen in wrapped word -#define CSA_SHYP CSA_SOFT_HYPHEN -#define CSA_INVERTED_EXCLAIM GR2A(KC_EXCLAIM) // ¡ -#define CSA_IXLM CSA_INVERTED_EXCLAIM -// nothing on 2 -#define CSA_POUND GR2A(LSFT(KC_3)) // £ -#define CSA_GBP CSA_POUND_SIGN -// already on ALGR(KC_E) -#define CSA_EURO_BIS GR2A(LSFT(KC_4)) // € -#define CSA_EURB CSA_EURO_BIS -#define CSA_THREE_EIGHTHS GR2A(LSFT(KC_5)) // ⅜ -#define CSA_3ON8 CSA_THREE_EIGHTHS -#define CSA_FIVE_EIGHTHS GR2A(LSFT(KC_6)) // ⅝ -#define CSA_5ON8 CSA_FIVE_EIGHTHS -#define CSA_SEVEN_EIGHTHS GR2A(LSFT(KC_7)) // ⅞ -#define CSA_7ON8 CSA_SEVEN_EIGHTHS -#define CSA_TRADEMARK GR2A(LSFT(KC_8)) // ™ -#define CSA_TM CSA_TRADEMARK -#define CSA_PLUS_MINUS GR2A(LSFT(KC_9)) // ± -#define CSA_PSMS CSA_PLUS_MINUS -// nothing on 0 -#define CSA_INVERTED_QUESTION GR2A(LSFT(KC_MINUS)) // ¿ -#define CSA_IQST CSA_INVERTED_QUESTION -#define CSA_DEAD_OGONEK GR2A(LSFT(KC_EQUAL)) // dead ˛ -#define CSA_DOGO CSA_DEAD_OGONEK +/* Shifted symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ \ │ ! │ @ │ # │ $ │ % │ ? │ & │ * │ ( │ ) │ _ │ + │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ ¨ │ │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ │ │ │ │ │ │ │ │ │ │ : │ │ │ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │ │ │ │ │ │ │ │ │ ' │ " │ │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define CA_BSLS S(CA_SLSH) // (backslash) +#define CA_EXLM S(CA_1) // ! +#define CA_AT S(CA_2) // @ +#define CA_HASH S(CA_3) // # +#define CA_DLR S(CA_4) // $ +#define CA_PERC S(CA_5) // % +#define CA_QUES S(CA_6) // ? +#define CA_AMPR S(CA_7) // & +#define CA_ASTR S(CA_8) // * +#define CA_LPRN S(CA_9) // ( +#define CA_RPRN S(CA_0) // ) +#define CA_UNDS S(CA_MINS) // _ +#define CA_PLUS S(CA_EQL) // + +// Row 2 +#define CA_DIAE S(CA_CIRC) // ¨ (dead) +// Row 3 +#define CA_COLN S(CA_SCLN) // : +// Row 4 +#define CA_QUOT S(CA_COMM) // ' +#define CA_DQUO S(CA_DOT) // " -// Second row -#define CSA_REGISTERED_TRADEMARK GR2A(LSFT(KC_R)) // ® -#define CSA_RTM CSA_REGISTERED_TRADEMARK -#define CSA_YEN GR2A(LSFT(KC_Y)) // ¥ -#define CSA_YUAN CSA_YEN -#define CSA_UP_ARROW LSFT(CSA_DOWN_ARROW) // ↑ -#define CSA_DOTLESS_I GR2A(LSFT(KC_I)) // ı -#define CSA_DLSI CSA_DOTLESS_I -#define CSA_DEAD_RING GR2A(LSFT(CSA_DCRC)) // dead ° -#define CSA_DRNG CSA_DEAD_RING -#define CSA_DEAD_MACRON GR2A(LSFT(CSA_C_CEDILLA)) // dead ¯ -#define CSA_DMCR CSA_DEAD_MACRON +/* AltGr symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ | │ │ │ │ ¤ │ │ │ { │ } │ [ │ ] │ │ ¬ │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ € │ │ │ │ │ │ │ │ ` │ ~ │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ │ │ │ │ │ │ │ │ │ │ ° │ │ │ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │ │ « │ » │ │ │ │ │ │ < │ > │ │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define CA_PIPE ALGR(CA_SLSH) // | +#define CA_CURR ALGR(CA_4) // ¤ +#define CA_LCBR ALGR(CA_7) // { +#define CA_RCBR ALGR(CA_8) // } +#define CA_LBRC ALGR(CA_9) // [ +#define CA_RBRC ALGR(CA_0) // ] +#define CA_NOT ALGR(CA_EQL) // ¬ +// Row 2 +#define CA_EURO ALGR(CA_E) // € +#define CA_GRV ALGR(CA_CIRC) // ` (dead) +#define CA_DTIL ALGR(CA_CCED) // ~ (dead) +// Row 3 +#define CA_DEG ALGR(CA_SCLN) // ° +// Row 4 +#define CA_LDAQ ALGR(CA_X) // « +#define CA_RDAQ ALGR(CA_C) // » +#define CA_LABK ALGR(CA_DOT) // < +#define CA_RABK ALGR(CA_COMM) // > -// Third row -#define CSA_SECTION GR2A(LSFT(KC_S)) // § -#define CSA_SECT CSA_SECTION -#define CSA_ORDINAL_INDICATOR_A GR2A(LSFT(KC_F)) // ª -#define CSA_ORDA CSA_ORDINAL_INDICATOR_A -#define CSA_DEAD_DOUBLE_ACUTE LSFT(CSA_DEAD_ACUTE) // ˝ -#define CSA_DDCT CSA_DEAD_DOUBLE_ACUTE -#define CSA_DEAD_CARON GR2A(LSFT(CSA_E_GRAVE)) // dead ˇ -#define CSA_DCAR CSA_DEAD_CARON -#define CSA_DEAD_BREVE GR2A(LSFT(CSA_A_GRAVE)) // dead ˘ -#define CSA_DBRV CSA_DEAD_BREVE +/* Right Ctrl symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ │ ¹ │ ² │ ³ │ ¼ │ ½ │ ¾ │ │ │ │ │ │ ¸ │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ Ω │ Ł │ Œ │ ¶ │ Ŧ │ ← │ ↓ │ → │ Ø │ Þ │ │ ~ │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ │ Æ │ ß │ Ð │ │ Ŋ │ Ħ │ IJ │ ĸ │ Ŀ │ ´ │ │ │ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │ │ │ │ ¢ │ “ │ ” │ ʼn │ μ │ ― │ ˙ │ │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define CA_SUP1 RCTL(CA_1) // ¹ +#define CA_SUP2 RCTL(CA_2) // ² +#define CA_SUP3 RCTL(CA_3) // ³ +#define CA_QRTR RCTL(CA_4) // ¼ +#define CA_HALF RCTL(CA_5) // ½ +#define CA_TQTR RCTL(CA_6) // ¾ +#define CA_CEDL RCTL(CA_EQL) // ¸ (dead) +// Row 2 +#define CA_OMEG RCTL(CA_Q) // Ω +#define CA_LSTR RCTL(CA_W) // Ł +#define CA_OE RCTL(CA_E) // Œ +#define CA_PARA RCTL(CA_R) // ¶ +#define CA_TSTR RCTL(CA_T) // Ŧ +#define CA_LARR RCTL(CA_Y) // ← +#define CA_DARR RCTL(CA_U) // ↓ +#define CA_RARR RCTL(CA_I) // → +#define CA_OSTR RCTL(CA_O) // Ø +#define CA_THRN RCTL(CA_P) // Þ +#define CA_TILD RCTL(CA_CCED) // ~ +// Row 3 +#define CA_AE RCTL(CA_A) // Æ +#define CA_SS RCTL(CA_S) // ß +#define CA_ETH RCTL(CA_D) // Ð +#define CA_ENG RCTL(CA_G) // Ŋ +#define CA_HSTR RCTL(CA_H) // Ħ +#define CA_IJ RCTL(CA_J) // IJ +#define CA_KRA RCTL(CA_K) // ĸ +#define CA_LMDT RCTL(CA_L) // Ŀ +#define CA_ACUT RCTL(CA_SCLN) // ´ (dead) +// Row 4 +#define CA_CENT RCTL(CA_C) // ¢ +#define CA_LDQU RCTL(CA_V) // “ +#define CA_RDQU RCTL(CA_B) // ” +#define CA_APSN RCTL(CA_N) // ʼn +#define CA_MICR RCTL(CA_M) // μ +#define CA_HRZB RCTL(CA_COMM) // ― +#define CA_DOTA ALGR(CA_DOT) // ˙ (dead) -// Fourth row -#define CSA_BROKEN_PIPE GR2A(LSFT(CSA_U_GRAVE)) // ¦ -#define CSA_BPIP CSA_BROKEN_PIPE -#define CSA_COPYRIGHT GR2A(LSFT(KC_C)) // © -#define CSA_CPRT CSA_COPYRIGHT -#define CSA_LEFT_QUOTE GR2A(LSFT(KC_V)) // ‘ -#define CSA_LQOT CSA_LEFT_QUOTE -#define CSA_RIGHT_QUOTE GR2A(LSFT(KC_B)) // ’ -#define CSA_RQOT CSA_RIGHT_QUOTE -#define CSA_EIGHTH_NOTE GR2A(LSFT(KC_N)) // ♪ -#define CSA_8NOT CSA_EIGHTH_NOTE -#define CSA_ORDINAL_INDICATOR_O GR2A(LSFT(KC_M)) // º -#define CSA_ORDO CSA_ORDINAL_INDICATOR_O -#define CSA_TIMES GR2A(LSFT(KC_COMMA)) // × -#define CSA_TIMS CSA_TIMES -#define CSA_OBELUS GR2A(LSFT(KC_DOT)) // ÷ -#define CSA_OBEL CSA_OBELUS -// more conventional name of the symbol -#define CSA_DIVISION_SIGN CSA_OBELUS -#define CSA_DVSN CSA_DIVISION_SIGN -// TODO GR2A(LSFT(CSA_E_ACUTE)) +/* Shift+Right Ctrl symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ - │ ¡ │ │ £ │ │ ⅜ │ ⅝ │ ⅞ │ ™ │ ± │ │ ¿ │ ˛ │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ ® │ │ ¥ │ ↑ │ ı │ │ │ ° │ ¯ │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ │ │ § │ │ ª │ │ │ │ │ │ ˝ │ ˇ │ ˘ │ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │ ¦ │ │ │ © │ ‘ │ ’ │ ♪ │ º │ × │ ÷ │ │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define CA_SHYP RCTL(S(CA_SLSH)) // (soft hyphen) +#define CA_IEXL RCTL(S(CA_1)) // ¡ +#define CA_PND RCTL(S(CA_3)) // £ +#define CA_TEIG RCTL(S(CA_5)) // ⅜ +#define CA_FEIG RCTL(S(CA_6)) // ⅝ +#define CA_SEIG RCTL(S(CA_7)) // ⅞ +#define CA_TM RCTL(S(CA_8)) // ™ +#define CA_PLMN RCTL(S(CA_9)) // ± +#define CA_IQUE RCTL(S(CA_MINS)) // ¿ +#define CA_OGON RCTL(S(CA_EQL)) // ˛ (dead) +// Row 2 +#define CA_REGD RCTL(S(CA_R)) // ® +#define CA_YEN RCTL(S(CA_Y)) // ¥ +#define CA_UARR RCTL(S(CA_U)) // ↑ +#define CA_DLSI RCTL(S(CA_I)) // ı +#define CA_RNGA RCTL(S(CA_CIRC)) // ° (dead) +#define CA_MACR RCTL(S(CA_CCED)) // ¯ (dead) +// Row 3 +#define CA_SECT RCTL(S(CA_S)) // § +#define CA_FORD RCTL(S(CA_F)) // ª +#define CA_DACU RCTL(S(CA_SCLN)) // ˝ (dead) +#define CA_CARN RCTL(S(CA_EGRV)) // ˇ (dead) +#define CA_BREV RCTL(S(CA_AGRV)) // ˘ (dead) +// Row 4 +#define CA_BRKP RCTL(S(CA_UGRV)) // ¦ +#define CA_COPY RCTL(S(CA_C)) // © +#define CA_LSQU RCTL(S(CA_V)) // ‘ +#define CA_RSQU RCTL(S(CA_B)) // ’ +#define CA_ENOT RCTL(S(CA_N)) // ♪ +#define CA_MORD RCTL(S(CA_M)) // º +#define CA_MUL RCTL(S(CA_COMM)) // × +#define CA_DIV RCTL(S(CA_DOT)) // ÷ -#endif +// DEPRECATED +#define GR2A(kc) RCTL(kc) +#define CSA_SLASH CA_SLSH +#define CSA_SLSH CA_SLSH +#define CSA_DEAD_CIRCUMFLEX CA_CIRC +#define CSA_DCRC CA_CIRC +#define CSA_C_CEDILLA CA_CCED +#define CSA_CCED CA_CCED +#define CSA_E_GRAVE CA_EGRV +#define CSA_EGRV CA_EGRV +#define CSA_A_GRAVE CA_AGRV +#define CSA_AGRV CA_AGRV +#define CSA_U_GRAVE CA_UGRV +#define CSA_UGRV CA_UGRV +#define CSA_E_ACUTE CA_EACU +#define CSA_ECUT CA_EACU +#define CSA_BACKSLASH CA_BSLS +#define CSA_BSLS CA_BSLS +#define CSA_QUESTION CA_QUES +#define CSA_QEST CA_QUES +#define CSA_DEAD_TREMA CA_DIAE +#define CSA_DTRM CA_DIAE +#define CSA_APOSTROPHE CA_QUOT +#define CSA_APOS CA_QUOT +#define CSA_DOUBLE_QUOTE CA_DQUO +#define CSA_DQOT CA_DQUO +#define CSA_PIPE CA_PIPE +#define CSA_CURRENCY CA_CURR +#define CSA_CURR CA_CURR +#define CSA_LEFT_CURLY_BRACE CA_LCBR +#define CSA_LCBR CA_LCBR +#define CSA_RIGHT_CURLY_BRACE CA_RCBR +#define CSA_RCBR CA_RCBR +#define CSA_LBRACKET CA_LBRC +#define CSA_LBRC CA_LBRC +#define CSA_RBRACKET CA_RBRC +#define CSA_RBRC CA_RBRC +#define CSA_NEGATION CA_NOT +#define CSA_NEGT CA_NOT +#define CSA_EURO CA_EURO +#define CSA_DEAD_GRAVE CA_GRV +#define CSA_DGRV CA_GRV +#define CSA_DEAD_TILDE CA_DTIL +#define CSA_DTLD CA_DTIL +#define CSA_DEGREE CA_DEG +#define CSA_DEGR CA_DEG +#define CSA_LEFT_GUILLEMET CA_LDAQ +#define CSA_LGIL CA_LDAQ +#define CSA_RIGHT_GUILLEMET CA_RDAQ +#define CSA_RGIL CA_RDAQ +#define CSA_LESS CA_LABK +#define CSA_GREATER CA_RABK +#define CSA_GRTR CA_RABK +#define CSA_NON_BREAKING_SPACE ALGR(KC_SPC) +#define CSA_NBSP ALGR(KC_SPC) +#define CSA_SUPERSCRIPT_ONE CA_SUP1 +#define CSA_SUP1 CA_SUP1 +#define CSA_SUPERSCRIPT_TWO CA_SUP2 +#define CSA_SUP2 CA_SUP2 +#define CSA_SUPERSCRIPT_THREE CA_SUP3 +#define CSA_SUP3 CA_SUP3 +#define CSA_ONE_QUARTER CA_QRTR +#define CSA_1QRT CA_QRTR +#define CSA_ONE_HALF CA_HALF +#define CSA_1HLF CA_HALF +#define CSA_THREE_QUARTERS CA_TQTR +#define CSA_3QRT CA_TQTR +#define CSA_DEAD_CEDILLA CA_CEDL +#define CSA_DCED CA_CEDL +#define CSA_OMEGA CA_OMEG +#define CSA_OMEG CA_OMEG +#define CSA_L_STROKE CA_LSTR +#define CSA_LSTK CA_LSTR +#define CSA_OE_LIGATURE CA_OE +#define CSA_OE CA_OE +#define CSA_PARAGRAPH CA_PARA +#define CSA_PARG CA_PARA +#define CSA_T_STROKE CA_TSTR +#define CSA_LEFT_ARROW CA_LARR +#define CSA_LARW CA_LARR +#define CSA_DOWN_ARROW CA_DARR +#define CSA_DARW CA_DARR +#define CSA_RIGHT_ARROW CA_RARR +#define CSA_RARW CA_RARR +#define CSA_O_STROKE CA_OSTR +#define CSA_OSTK CA_OSTR +#define CSA_THORN CA_THRN +#define CSA_THRN CA_THRN +#define CSA_TILDE CA_TILD +#define CSA_TILD CA_TILD +#define CSA_AE_LIGATURE CA_AE +#define CSA_AE CA_AE +#define CSA_SHARP_S CA_SS +#define CSA_SRPS CA_SS +#define CSA_ETH CA_ETH +#define CSA_ENG CA_ENG +#define CSA_H_SRTOKE CA_HSTR +#define CSA_HSTK CA_HSTR +#define CSA_IJ_LIGATURE CA_IJ +#define CSA_IJ CA_IJ +#define CSA_KRA CA_KRA +#define CSA_L_FLOWN_DOT CA_LMDT +#define CSA_LFLD CA_LMDT +#define CSA_DEAD_ACUTE CA_ACUT +#define CSA_DACT CA_ACUT +#define CSA_CENT CA_CENT +#define CSA_LEFT_DOUBLE_QUOTE CA_LDQU +#define CSA_LDQT CA_LDQU +#define CSA_RIGHT_DOUBLE_QUOTE CA_RDQU +#define CSA_RDQT CA_RDQU +#define CSA_N_APOSTROPHE CA_APSN +#define CSA_NAPO CA_APSN +#define CSA_MU CA_MICR +#define CSA_HORIZONTAL_BAR CA_HRZB +#define CSA_HZBR CA_HRZB +#define CSA_DEAD_DOT_ABOVE CA_DOTA +#define CSA_DDTA CA_DOTA +#define CSA_SOFT_HYPHEN CA_SHYP +#define CSA_SHYP CA_SHYP +#define CSA_INVERTED_EXCLAIM CA_IEXL +#define CSA_IXLM CA_IEXL +#define CSA_POUND CA_PND +#define CSA_GBP CA_PND +#define CSA_EURO_BIS CA_EURO +#define CSA_EURB CA_EURO +#define CSA_THREE_EIGHTHS CA_TEIG +#define CSA_3ON8 CA_TEIG +#define CSA_FIVE_EIGHTHS CA_FEIG +#define CSA_5ON8 CA_FEIG +#define CSA_SEVEN_EIGHTHS CA_SEIG +#define CSA_7ON8 CA_SEIG +#define CSA_TRADEMARK CA_TM +#define CSA_TM CA_TM +#define CSA_PLUS_MINUS CA_PLMN +#define CSA_PSMS CA_PLMN +#define CSA_INVERTED_QUESTION CA_IQUE +#define CSA_IQST CA_IQUE +#define CSA_DEAD_OGONEK CA_OGON +#define CSA_DOGO CA_OGON +#define CSA_REGISTERED_TRADEMARK CA_REGD +#define CSA_RTM CA_REGD +#define CSA_YEN CA_YEN +#define CSA_YUAN CA_YEN +#define CSA_UP_ARROW CA_UARR +#define CSA_DOTLESS_I CA_DLSI +#define CSA_DLSI CA_DLSI +#define CSA_DEAD_RING CA_RNGA +#define CSA_DRNG CA_RNGA +#define CSA_DEAD_MACRON CA_MACR +#define CSA_DMCR CA_MACR +#define CSA_SECTION CA_SECT +#define CSA_SECT CA_SECT +#define CSA_ORDINAL_INDICATOR_A CA_FORD +#define CSA_ORDA CA_FORD +#define CSA_DEAD_DOUBLE_ACUTE CA_DACU +#define CSA_DDCT CA_DACU +#define CSA_DEAD_CARON CA_CARN +#define CSA_DCAR CA_CARN +#define CSA_DEAD_BREVE CA_BREV +#define CSA_DBRV CA_BREV +#define CSA_BROKEN_PIPE CA_BRKP +#define CSA_BPIP CA_BRKP +#define CSA_COPYRIGHT CA_COPY +#define CSA_CPRT CA_COPY +#define CSA_LEFT_QUOTE CA_LSQU +#define CSA_LQOT CA_LSQU +#define CSA_RIGHT_QUOTE CA_RSQU +#define CSA_RQOT CA_RSQU +#define CSA_EIGHTH_NOTE CA_ENOT +#define CSA_8NOT CA_ENOT +#define CSA_ORDINAL_INDICATOR_O CA_MORD +#define CSA_ORDO CA_MORD +#define CSA_TIMES CA_MUL +#define CSA_TIMS CA_MUL +#define CSA_OBELUS CA_DIV +#define CSA_OBEL CA_DIV +#define CSA_DIVISION_SIGN CA_DIV +#define CSA_DVSN CA_DIV diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h index 818a739c76..8e6e2b77a2 100644 --- a/quantum/keymap_extras/keymap_neo2.h +++ b/quantum/keymap_extras/keymap_neo2.h @@ -13,66 +13,130 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef KEYMAP_NEO2 -#define KEYMAP_NEO2 -#include "keymap.h" -#include "keymap_german.h" - -#define NEO_A KC_D -#define NEO_B KC_N -#define NEO_C KC_R -#define NEO_D DE_OE -#define NEO_E KC_F -#define NEO_F KC_O -#define NEO_G KC_I -#define NEO_H KC_U -#define NEO_I KC_S -#define NEO_J DE_MINS -#define NEO_K DE_Z -#define NEO_L KC_E -#define NEO_M KC_M -#define NEO_N KC_J -#define NEO_O KC_G -#define NEO_P KC_V -#define NEO_Q KC_P -#define NEO_R KC_K -#define NEO_S KC_H -#define NEO_T KC_L -#define NEO_U KC_A -#define NEO_V KC_W -#define NEO_W KC_T -#define NEO_X KC_Q -#define NEO_Y DE_AE -#define NEO_Z KC_B -#define NEO_AE KC_C -#define NEO_OE KC_X -#define NEO_UE DE_Y -#define NEO_SS DE_UE - -#define NEO_DOT DE_DOT -#define NEO_COMM DE_COMM +#pragma once -#define NEO_1 DE_1 -#define NEO_2 DE_2 -#define NEO_3 DE_3 -#define NEO_4 DE_4 -#define NEO_5 DE_5 -#define NEO_6 DE_6 -#define NEO_7 DE_7 -#define NEO_8 DE_8 -#define NEO_9 DE_9 -#define NEO_0 DE_0 -#define NEO_MINS DE_SS - -#define NEO_ACUT DE_PLUS -#define NEO_GRV DE_ACUT -#define NEO_CIRC DE_CIRC +#include "keymap.h" -#define NEO_L1_L KC_CAPS -#define NEO_L1_R DE_HASH +// clang-format off -#define NEO_L2_L DE_LESS -#define NEO_L2_R KC_ALGR +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ^ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ ` │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ X │ V │ L │ C │ W │ K │ H │ G │ F │ Q │ ß │ ´ │ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │ + * │ L3 │ U │ I │ A │ E │ O │ S │ N │ R │ T │ D │ Y │ L3│ │ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤ + * │ │L4 │ Ü │ Ö │ Ä │ P │ Z │ B │ M │ , │ . │ J │ │ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ L4 │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define NE_CIRC KC_GRV // ^ (dead) +#define NE_1 KC_1 // 1 +#define NE_2 KC_2 // 2 +#define NE_3 KC_3 // 3 +#define NE_4 KC_4 // 4 +#define NE_5 KC_5 // 5 +#define NE_6 KC_6 // 6 +#define NE_7 KC_7 // 7 +#define NE_8 KC_8 // 8 +#define NE_9 KC_9 // 9 +#define NE_0 KC_0 // 0 +#define NE_MINS KC_MINS // - +#define NE_GRV KC_EQL // ` (dead) +// Row 2 +#define NE_X KC_Q // X +#define NE_V KC_W // V +#define NE_L KC_E // L +#define NE_C KC_R // C +#define NE_W KC_T // W +#define NE_K KC_Y // K +#define NE_H KC_U // H +#define NE_H KC_I // G +#define NE_F KC_O // F +#define NE_Q KC_P // Q +#define NE_SS KC_LBRC // ß +#define NE_ACUT KC_RBRC // ´ (dead) +// Row 3 +#define NE_L3L KC_CAPS // (layer 3) +#define NE_U KC_A // U +#define NE_I KC_S // I +#define NE_A KC_D // A +#define NE_E KC_F // E +#define NE_O KC_G // O +#define NE_S KC_H // S +#define NE_N KC_J // N +#define NE_R KC_K // R +#define NE_T KC_L // T +#define NE_D KC_SCLN // D +#define NE_Y KC_QUOT // Y +#define NE_L3R KC_NUHS // (layer 3) +// Row 4 +#define NE_L4L KC_NUBS // (layer 4) +#define NE_UDIA KC_Z // Ü +#define NE_ODIA KC_X // Ö +#define NE_ADIA KC_C // Ä +#define NE_P KC_V // P +#define NE_Z KC_B // Z +#define NE_B KC_N // B +#define NE_M KC_M // M +#define NE_COMM KC_COMM // , +#define NE_DOT KC_DOT // . +#define NE_J KC_SLSH // J +// Row 5 +#define NE_L4R KC_ALGR // (layer 4) -#endif +// DEPRECATED +#define NEO_A NE_A +#define NEO_B NE_B +#define NEO_C NE_C +#define NEO_D NE_D +#define NEO_E NE_E +#define NEO_F NE_F +#define NEO_G NE_G +#define NEO_H NE_H +#define NEO_I NE_I +#define NEO_J NE_J +#define NEO_K NE_K +#define NEO_L NE_L +#define NEO_M NE_M +#define NEO_N NE_N +#define NEO_O NE_O +#define NEO_P NE_P +#define NEO_Q NE_Q +#define NEO_R NE_R +#define NEO_S NE_S +#define NEO_T NE_T +#define NEO_U NE_U +#define NEO_V NE_V +#define NEO_W NE_W +#define NEO_X NE_X +#define NEO_Y NE_Y +#define NEO_Z NE_Z +#define NEO_AE NE_ADIA +#define NEO_OE NE_ODIA +#define NEO_UE NE_UDIA +#define NEO_SS NE_SS +#define NEO_DOT NE_DOT +#define NEO_COMM NE_COMM +#define NEO_1 NE_1 +#define NEO_2 NE_2 +#define NEO_3 NE_3 +#define NEO_4 NE_4 +#define NEO_5 NE_5 +#define NEO_6 NE_6 +#define NEO_7 NE_7 +#define NEO_8 NE_8 +#define NEO_9 NE_9 +#define NEO_0 NE_0 +#define NEO_MINS NE_MINS +#define NEO_ACUT NE_ACUT +#define NEO_GRV NE_GRV +#define NEO_CIRC NE_CIRC +#define NEO_L1_L NE_L3L +#define NEO_L1_R NE_L3R +#define NEO_L2_L NE_L4L +#define NEO_L2_R NE_L4R diff --git a/quantum/keymap_extras/sendstring_canadian_multilingual.h b/quantum/keymap_extras/sendstring_canadian_multilingual.h new file mode 100644 index 0000000000..c3fcc62c37 --- /dev/null +++ b/quantum/keymap_extras/sendstring_canadian_multilingual.h @@ -0,0 +1,100 @@ +/* Copyright 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Sendstring lookup tables for Canadian Multilingual layouts + +#pragma once + +#include "keymap_canadian_multilingual.h" +#include "quantum.h" + +// clang-format off + +const uint8_t ascii_to_shift_lut[16] PROGMEM = { + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + + KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 1), + KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 1, 0, 0, 0, 0, 1), + KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1), + KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1), + KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1), + KCLUT_ENTRY(1, 1, 1, 0, 1, 0, 0, 1), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0) +}; + +const uint8_t ascii_to_altgr_lut[16] PROGMEM = { + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 1, 0, 1, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 1, 0, 1, 0, 0), + KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0) +}; + +const uint8_t ascii_to_keycode_lut[128] PROGMEM = { + // NUL SOH STX ETX EOT ENQ ACK BEL + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + // BS TAB LF VT FF CR SO SI + KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + // DLE DC1 DC2 DC3 DC4 NAK SYN ETB + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + // CAN EM SUB ESC FS GS RS US + XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + + // ! " # $ % & ' + KC_SPC, CA_1, CA_DOT, CA_3, CA_4, CA_5, CA_7, CA_COMM, + // ( ) * + , - . / + CA_9, CA_0, CA_8, CA_EQL, CA_COMM, CA_MINS, CA_DOT, CA_SLSH, + // 0 1 2 3 4 5 6 7 + CA_0, CA_1, CA_2, CA_3, CA_4, CA_5, CA_6, CA_7, + // 8 9 : ; < = > ? + CA_8, CA_9, CA_SCLN, CA_SCLN, CA_DOT, CA_EQL, CA_COMM, CA_6, + // @ A B C D E F G + CA_2, CA_A, CA_B, CA_C, CA_D, CA_E, CA_F, CA_G, + // H I J K L M N O + CA_H, CA_I, CA_J, CA_K, CA_L, CA_M, CA_N, CA_O, + // P Q R S T U V W + CA_P, CA_Q, CA_R, CA_S, CA_T, CA_U, CA_V, CA_W, + // X Y Z [ \ ] ^ _ + CA_X, CA_Y, CA_Z, CA_9, CA_SLSH, CA_0, CA_CIRC, CA_MINS, + // ` a b c d e f g + CA_CIRC, CA_A, CA_B, CA_C, CA_D, CA_E, CA_F, CA_G, + // h i j k l m n o + CA_H, CA_I, CA_J, CA_K, CA_L, CA_M, CA_N, CA_O, + // p q r s t u v w + CA_P, CA_Q, CA_R, CA_S, CA_T, CA_U, CA_V, CA_W, + // x y z { | } ~ DEL + CA_X, CA_Y, CA_Z, CA_7, CA_SLSH, CA_8, CA_CCED, KC_DEL +}; diff --git a/quantum/matrix.c b/quantum/matrix.c index 67d8af6ee8..c68c56cac2 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -48,17 +48,22 @@ static void init_pins(void) { } static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { - matrix_row_t last_row_value = current_matrix[current_row]; - current_matrix[current_row] = 0; + // Start with a clear matrix row + matrix_row_t current_row_value = 0; for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { pin_t pin = direct_pins[current_row][col_index]; if (pin != NO_PIN) { - current_matrix[current_row] |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index); + current_row_value |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index); } } - return (last_row_value != current_matrix[current_row]); + // If the row has changed, store the row and return the changed flag. + if (current_matrix[current_row] != current_row_value) { + current_matrix[current_row] = current_row_value; + return true; + } + return false; } #elif defined(DIODE_DIRECTION) @@ -85,11 +90,8 @@ static void init_pins(void) { } static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { - // Store last value of row prior to reading - matrix_row_t last_row_value = current_matrix[current_row]; - - // Clear data in matrix row - current_matrix[current_row] = 0; + // Start with a clear matrix row + matrix_row_t current_row_value = 0; // Select row and wait for row selecton to stabilize select_row(current_row); @@ -101,13 +103,18 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) uint8_t pin_state = readPin(col_pins[col_index]); // Populate the matrix row with the state of the col pin - current_matrix[current_row] |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); + current_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); } // Unselect row unselect_row(current_row); - return (last_row_value != current_matrix[current_row]); + // If the row has changed, store the row and return the changed flag. + if (current_matrix[current_row] != current_row_value) { + current_matrix[current_row] = current_row_value; + return true; + } + return false; } # elif (DIODE_DIRECTION == ROW2COL) @@ -142,20 +149,22 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) // For each row... for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) { // Store last value of row prior to reading - matrix_row_t last_row_value = current_matrix[row_index]; + matrix_row_t last_row_value = current_matrix[row_index]; + matrix_row_t current_row_value = last_row_value; // Check row pin state if (readPin(row_pins[row_index]) == 0) { // Pin LO, set col bit - current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); + current_row_value |= (MATRIX_ROW_SHIFTER << current_col); } else { // Pin HI, clear col bit - current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); + current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col); } // Determine if the matrix changed state - if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) { - matrix_changed = true; + if ((last_row_value != current_row_value)) { + matrix_changed |= true; + current_matrix[row_index] = current_row_value; } } diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c index 627e5986fb..21164b8f9f 100644 --- a/quantum/process_keycode/process_rgb.c +++ b/quantum/process_keycode/process_rgb.c @@ -56,7 +56,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { // Split keyboards need to trigger on key-up for edge-case issue if (!record->event.pressed) { #endif - uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); + uint8_t shifted = get_mods() & MOD_MASK_SHIFT; switch (keycode) { case RGB_TOG: rgblight_toggle(); diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 48ce3961ad..fb50215012 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -24,8 +24,8 @@ uint8_t unicode_saved_mods; #if UNICODE_SELECTED_MODES != -1 static uint8_t selected[] = {UNICODE_SELECTED_MODES}; -static uint8_t selected_count = sizeof selected / sizeof *selected; -static uint8_t selected_index; +static int8_t selected_count = sizeof selected / sizeof *selected; +static int8_t selected_index; #endif void unicode_input_mode_init(void) { @@ -33,7 +33,7 @@ void unicode_input_mode_init(void) { #if UNICODE_SELECTED_MODES != -1 # if UNICODE_CYCLE_PERSIST // Find input_mode in selected modes - uint8_t i; + int8_t i; for (i = 0; i < selected_count; i++) { if (selected[i] == unicode_config.input_mode) { selected_index = i; @@ -60,9 +60,12 @@ void set_unicode_input_mode(uint8_t mode) { dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode); } -void cycle_unicode_input_mode(uint8_t offset) { +void cycle_unicode_input_mode(int8_t offset) { #if UNICODE_SELECTED_MODES != -1 - selected_index = (selected_index + offset) % selected_count; + selected_index = (selected_index + offset) % selected_count; + if (selected_index < 0) { + selected_index += selected_count; + } unicode_config.input_mode = selected[selected_index]; # if UNICODE_CYCLE_PERSIST persist_unicode_input_mode(); @@ -168,6 +171,8 @@ void register_hex32(uint32_t hex) { } } +// clang-format off + void send_unicode_hex_string(const char *str) { if (!str) { return; @@ -175,12 +180,11 @@ void send_unicode_hex_string(const char *str) { while (*str) { // Find the next code point (token) in the string - for (; *str == ' '; str++) - ; + for (; *str == ' '; str++); // Skip leading spaces size_t n = strcspn(str, " "); // Length of the current token - char code_point[n + 1]; - strncpy(code_point, str, n); - code_point[n] = '\0'; // Make sure it's null-terminated + char code_point[n+1]; + strncpy(code_point, str, n); // Copy token into buffer + code_point[n] = '\0'; // Make sure it's null-terminated // Normalize the code point: make all hex digits lowercase for (char *p = code_point; *p; p++) { @@ -196,8 +200,10 @@ void send_unicode_hex_string(const char *str) { } } +// clang-format on + // Borrowed from https://nullprogram.com/blog/2017/10/06/ -const char *decode_utf8(const char *str, int32_t *code_point) { +static const char *decode_utf8(const char *str, int32_t *code_point) { const char *next; if (str[0] < 0x80) { // U+0000-007F @@ -231,7 +237,6 @@ void send_unicode_string(const char *str) { } int32_t code_point = 0; - while (*str) { str = decode_utf8(str, &code_point); @@ -243,53 +248,70 @@ void send_unicode_string(const char *str) { } } +// clang-format off + +static void audio_helper(void) { +#ifdef AUDIO_ENABLE + switch (get_unicode_input_mode()) { +# ifdef UNICODE_SONG_MAC + static float song_mac[][2] = UNICODE_SONG_MAC; + case UC_MAC: + PLAY_SONG(song_mac); + break; +# endif +# ifdef UNICODE_SONG_LNX + static float song_lnx[][2] = UNICODE_SONG_LNX; + case UC_LNX: + PLAY_SONG(song_lnx); + break; +# endif +# ifdef UNICODE_SONG_WIN + static float song_win[][2] = UNICODE_SONG_WIN; + case UC_WIN: + PLAY_SONG(song_win); + break; +# endif +# ifdef UNICODE_SONG_BSD + static float song_bsd[][2] = UNICODE_SONG_BSD; + case UC_BSD: + PLAY_SONG(song_bsd); + break; +# endif +# ifdef UNICODE_SONG_WINC + static float song_winc[][2] = UNICODE_SONG_WINC; + case UC_WINC: + PLAY_SONG(song_winc); + break; +# endif + } +#endif +} + +// clang-format on + bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { + bool shifted = get_mods() & MOD_MASK_SHIFT; switch (keycode) { case UNICODE_MODE_FORWARD: - cycle_unicode_input_mode(+1); + cycle_unicode_input_mode(shifted ? -1 : +1); + audio_helper(); break; case UNICODE_MODE_REVERSE: - cycle_unicode_input_mode(-1); + cycle_unicode_input_mode(shifted ? +1 : -1); + audio_helper(); break; - case UNICODE_MODE_MAC: - set_unicode_input_mode(UC_MAC); -#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_MAC) - static float song_mac[][2] = UNICODE_SONG_MAC; - PLAY_SONG(song_mac); -#endif - break; - case UNICODE_MODE_LNX: - set_unicode_input_mode(UC_LNX); -#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) - static float song_lnx[][2] = UNICODE_SONG_LNX; - PLAY_SONG(song_lnx); -#endif - break; - case UNICODE_MODE_WIN: - set_unicode_input_mode(UC_WIN); -#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) - static float song_win[][2] = UNICODE_SONG_WIN; - PLAY_SONG(song_win); -#endif - break; - case UNICODE_MODE_BSD: - set_unicode_input_mode(UC_BSD); -#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) - static float song_bsd[][2] = UNICODE_SONG_BSD; - PLAY_SONG(song_bsd); -#endif - break; - case UNICODE_MODE_WINC: - set_unicode_input_mode(UC_WINC); -#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) - static float song_winc[][2] = UNICODE_SONG_WINC; - PLAY_SONG(song_winc); -#endif + case UNICODE_MODE_MAC ... UNICODE_MODE_WINC: { + // Keycodes and input modes follow the same ordering + uint8_t delta = keycode - UNICODE_MODE_MAC; + set_unicode_input_mode(UC_MAC + delta); + audio_helper(); break; + } } } + #if defined(UNICODE_ENABLE) return process_unicode(keycode, record); #elif defined(UNICODEMAP_ENABLE) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 5421c28c7f..4579fde8d5 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -80,7 +80,7 @@ extern uint8_t unicode_saved_mods; void unicode_input_mode_init(void); uint8_t get_unicode_input_mode(void); void set_unicode_input_mode(uint8_t mode); -void cycle_unicode_input_mode(uint8_t offset); +void cycle_unicode_input_mode(int8_t offset); void persist_unicode_input_mode(void); void unicode_input_start(void); diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 5445cde129..2f402a2fd2 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -21,7 +21,8 @@ __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { // Keycode is a pair: extract index based on Shift / Caps Lock state uint16_t index = keycode - QK_UNICODEMAP_PAIR; - bool shift = unicode_saved_mods & MOD_MASK_SHIFT, caps = IS_HOST_LED_ON(USB_LED_CAPS_LOCK); + bool shift = unicode_saved_mods & MOD_MASK_SHIFT; + bool caps = IS_HOST_LED_ON(USB_LED_CAPS_LOCK); if (shift ^ caps) { index >>= 7; } diff --git a/quantum/quantum.c b/quantum/quantum.c index a780ed43d0..75df357d33 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -623,9 +623,6 @@ void matrix_init_quantum() { #ifdef OUTPUT_AUTO_ENABLE set_output(OUTPUT_AUTO); #endif -#ifdef DIP_SWITCH_ENABLE - dip_switch_init(); -#endif matrix_init_kb(); } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 0958c4f4eb..d8f1fa4bbb 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -794,6 +794,7 @@ enum quantum_keycodes { # define SH_T(kc) (QK_SWAP_HANDS | (kc)) # define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) # define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE) +# define SH_OS (QK_SWAP_HANDS | OP_SH_ONESHOT) # define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF) # define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON) # define SH_ON (QK_SWAP_HANDS | OP_SH_ON) diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 3fae9d7378..f3da0ab0f7 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -57,8 +57,12 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; // -----End rgb effect includes macros------- // ------------------------------------------ -#ifndef RGB_DISABLE_AFTER_TIMEOUT -# define RGB_DISABLE_AFTER_TIMEOUT 0 +#if defined(RGB_DISABLE_AFTER_TIMEOUT) && !defined(RGB_DISABLE_TIMEOUT) +# define RGB_DISABLE_TIMEOUT (RGB_DISABLE_AFTER_TIMEOUT * 1200) +#endif + +#ifndef RGB_DISABLE_TIMEOUT +# define RGB_DISABLE_TIMEOUT 0 #endif #ifndef RGB_DISABLE_WHEN_USB_SUSPENDED @@ -111,19 +115,29 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; # define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2 #endif -bool g_suspend_state = false; - -rgb_config_t rgb_matrix_config; - -rgb_counters_t g_rgb_counters; -static uint32_t rgb_counters_buffer; - +// globals +bool g_suspend_state = false; +rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr +uint32_t g_rgb_timer; #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS -uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; -#endif +uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; +#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED +last_hit_t g_last_hit_tracker; +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +// internals +static uint8_t rgb_last_enable = UINT8_MAX; +static uint8_t rgb_last_effect = UINT8_MAX; +static effect_params_t rgb_effect_params = {0, 0xFF}; +static rgb_task_states rgb_task_state = SYNCING; +#if RGB_DISABLE_TIMEOUT > 0 +static uint32_t rgb_anykey_timer; +#endif // RGB_DISABLE_TIMEOUT > 0 + +// double buffers +static uint32_t rgb_timer_buffer; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -last_hit_t g_last_hit_tracker; static last_hit_t last_hit_buffer; #endif // RGB_MATRIX_KEYREACTIVE_ENABLED @@ -169,21 +183,24 @@ void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); } bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { +#if RGB_DISABLE_TIMEOUT > 0 + if (record->event.pressed) { + rgb_anykey_timer = 0; + } +#endif // RGB_DISABLE_TIMEOUT > 0 + #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; uint8_t led_count = 0; # if defined(RGB_MATRIX_KEYRELEASES) - if (!record->event.pressed) { - led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led); - g_rgb_counters.any_key_hit = 0; - } + if (!record->event.pressed) # elif defined(RGB_MATRIX_KEYPRESSES) - if (record->event.pressed) { - led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led); - g_rgb_counters.any_key_hit = 0; - } + if (record->event.pressed) # endif // defined(RGB_MATRIX_KEYRELEASES) + { + led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led); + } if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); @@ -216,7 +233,7 @@ void rgb_matrix_test(void) { // Mask out bits 4 and 5 // Increase the factor to make the test animation slower (and reduce to make it faster) uint8_t factor = 10; - switch ((g_rgb_counters.tick & (0b11 << factor)) >> factor) { + switch ((g_rgb_timer & (0b11 << factor)) >> factor) { case 0: { rgb_matrix_set_color_all(20, 0, 0); break; @@ -241,29 +258,26 @@ static bool rgb_matrix_none(effect_params_t *params) { return false; } - RGB_MATRIX_USE_LIMITS(led_min, led_max); - for (uint8_t i = led_min; i < led_max; i++) { - rgb_matrix_set_color(i, 0, 0, 0); - } - return led_max < DRIVER_LED_TOTAL; + rgb_matrix_set_color_all(0, 0, 0); + return false; } -static uint8_t rgb_last_enable = UINT8_MAX; -static uint8_t rgb_last_effect = UINT8_MAX; -static effect_params_t rgb_effect_params = {0, 0xFF}; -static rgb_task_states rgb_task_state = SYNCING; - static void rgb_task_timers(void) { +#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 + uint32_t deltaTime = timer_elapsed32(rgb_timer_buffer); +#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 + rgb_timer_buffer = timer_read32(); + // Update double buffer timers - uint16_t deltaTime = timer_elapsed32(rgb_counters_buffer); - rgb_counters_buffer = timer_read32(); - if (g_rgb_counters.any_key_hit < UINT32_MAX) { - if (UINT32_MAX - deltaTime < g_rgb_counters.any_key_hit) { - g_rgb_counters.any_key_hit = UINT32_MAX; +#if RGB_DISABLE_TIMEOUT > 0 + if (rgb_anykey_timer < UINT32_MAX) { + if (UINT32_MAX - deltaTime < rgb_anykey_timer) { + rgb_anykey_timer = UINT32_MAX; } else { - g_rgb_counters.any_key_hit += deltaTime; + rgb_anykey_timer += deltaTime; } } +#endif // RGB_DISABLE_TIMEOUT > 0 // Update double buffer last hit timers #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED @@ -280,7 +294,7 @@ static void rgb_task_timers(void) { static void rgb_task_sync(void) { // next task - if (timer_elapsed32(g_rgb_counters.tick) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; + if (timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; } static void rgb_task_start(void) { @@ -288,7 +302,7 @@ static void rgb_task_start(void) { rgb_effect_params.iter = 0; // update double buffers - g_rgb_counters.tick = rgb_counters_buffer; + g_rgb_timer = rgb_timer_buffer; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker = last_hit_buffer; #endif // RGB_MATRIX_KEYREACTIVE_ENABLED @@ -370,8 +384,16 @@ void rgb_matrix_task(void) { // Ideally we would also stop sending zeros to the LED driver PWM buffers // while suspended and just do a software shutdown. This is a cheap hack for now. - bool suspend_backlight = ((g_suspend_state && RGB_DISABLE_WHEN_USB_SUSPENDED) || (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_rgb_counters.any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20)); - uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; + bool suspend_backlight = +#if RGB_DISABLE_WHEN_USB_SUSPENDED == true + g_suspend_state || +#endif // RGB_DISABLE_WHEN_USB_SUSPENDED == true +#if RGB_DISABLE_TIMEOUT > 0 + (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || +#endif // RGB_DISABLE_TIMEOUT > 0 + false; + + uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; switch (rgb_task_state) { case STARTING: @@ -405,8 +427,6 @@ __attribute__((weak)) void rgb_matrix_indicators_user(void) {} void rgb_matrix_init(void) { rgb_matrix_driver.init(); - // TODO: put the 1 second startup delay here? - #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker.count = 0; for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { @@ -440,6 +460,8 @@ void rgb_matrix_set_suspend_state(bool state) { g_suspend_state = state; } +bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; } + void rgb_matrix_toggle(void) { rgb_matrix_config.enable ^= 1; rgb_task_state = STARTING; @@ -466,6 +488,8 @@ void rgb_matrix_disable_noeeprom(void) { rgb_matrix_config.enable = 0; } +uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } + void rgb_matrix_step(void) { rgb_matrix_config.mode++; if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1; @@ -521,6 +545,8 @@ void rgb_matrix_decrease_speed(void) { eeconfig_update_rgb_matrix(); } +uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } + led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } @@ -546,3 +572,8 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_config.hsv.v = val; if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; } + +HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } +uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } +uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } +uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 96494836ee..d9ce391068 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -104,11 +104,13 @@ void rgb_matrix_indicators_user(void); void rgb_matrix_init(void); void rgb_matrix_set_suspend_state(bool state); +bool rgb_matrix_get_suspend_state(void); void rgb_matrix_toggle(void); void rgb_matrix_enable(void); void rgb_matrix_enable_noeeprom(void); void rgb_matrix_disable(void); void rgb_matrix_disable_noeeprom(void); +uint8_t rgb_matrix_is_enabled(void); void rgb_matrix_step(void); void rgb_matrix_step_reverse(void); void rgb_matrix_increase_hue(void); @@ -119,6 +121,7 @@ void rgb_matrix_increase_val(void); void rgb_matrix_decrease_val(void); void rgb_matrix_increase_speed(void); void rgb_matrix_decrease_speed(void); +uint8_t rgb_matrix_get_speed(void); led_flags_t rgb_matrix_get_flags(void); void rgb_matrix_set_flags(led_flags_t flags); void rgb_matrix_mode(uint8_t mode); @@ -126,6 +129,10 @@ void rgb_matrix_mode_noeeprom(uint8_t mode); uint8_t rgb_matrix_get_mode(void); void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); +HSV rgb_matrix_get_hsv(void); +uint8_t rgb_matrix_get_hue(void); +uint8_t rgb_matrix_get_sat(void); +uint8_t rgb_matrix_get_val(void); #ifndef RGBLIGHT_ENABLE # define rgblight_toggle rgb_matrix_toggle @@ -133,6 +140,7 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); # define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom # define rgblight_disable rgb_matrix_disable # define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom +# define rgblight_is_enabled rgb_matrix_is_enabled # define rgblight_step rgb_matrix_step # define rgblight_sethsv rgb_matrix_sethsv # define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom @@ -145,9 +153,14 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); # define rgblight_decrease_val rgb_matrix_decrease_val # define rgblight_increase_speed rgb_matrix_increase_speed # define rgblight_decrease_speed rgb_matrix_decrease_speed +# define rgblight_get_speed rgb_matrix_get_speed # define rgblight_mode rgb_matrix_mode # define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom # define rgblight_get_mode rgb_matrix_get_mode +# define rgblight_get_hue rgb_matrix_get_hue +# define rgblight_get_sat rgb_matrix_get_sat +# define rgblight_get_val rgb_matrix_get_val +# define rgblight_get_hsv rgb_matrix_get_hsv #endif typedef struct { @@ -165,14 +178,14 @@ extern const rgb_matrix_driver_t rgb_matrix_driver; extern rgb_config_t rgb_matrix_config; -extern bool g_suspend_state; -extern rgb_counters_t g_rgb_counters; -extern led_config_t g_led_config; +extern bool g_suspend_state; +extern uint32_t g_rgb_timer; +extern led_config_t g_led_config; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED extern last_hit_t g_last_hit_tracker; #endif #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS -extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; +extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; #endif #endif diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h index 92431555e7..887425f9da 100644 --- a/quantum/rgb_matrix_animations/breathing_anim.h +++ b/quantum/rgb_matrix_animations/breathing_anim.h @@ -6,7 +6,7 @@ bool BREATHING(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = rgb_matrix_config.hsv; - uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8); + uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); RGB rgb = hsv_to_rgb(hsv); for (uint8_t i = led_min; i < led_max; i++) { diff --git a/quantum/rgb_matrix_animations/digital_rain_anim.h b/quantum/rgb_matrix_animations/digital_rain_anim.h index 7a4a52db1b..1de45f8e8d 100644 --- a/quantum/rgb_matrix_animations/digital_rain_anim.h +++ b/quantum/rgb_matrix_animations/digital_rain_anim.h @@ -18,7 +18,7 @@ bool DIGITAL_RAIN(effect_params_t* params) { if (params->init) { rgb_matrix_set_color_all(0, 0, 0); - memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer)); + memset(g_rgb_frame_buffer, 0, sizeof(g_rgb_frame_buffer)); drop = 0; } @@ -27,10 +27,10 @@ bool DIGITAL_RAIN(effect_params_t* params) { if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) { // top row, pixels have just fallen and we're // making a new rain drop in this column - rgb_frame_buffer[row][col] = max_intensity; - } else if (rgb_frame_buffer[row][col] > 0 && rgb_frame_buffer[row][col] < max_intensity) { + g_rgb_frame_buffer[row][col] = max_intensity; + } else if (g_rgb_frame_buffer[row][col] > 0 && g_rgb_frame_buffer[row][col] < max_intensity) { // neither fully bright nor dark, decay it - rgb_frame_buffer[row][col]--; + g_rgb_frame_buffer[row][col]--; } // set the pixel colour uint8_t led[LED_HITS_TO_REMEMBER]; @@ -38,11 +38,11 @@ bool DIGITAL_RAIN(effect_params_t* params) { // TODO: multiple leds are supported mapped to the same row/column if (led_count > 0) { - if (rgb_frame_buffer[row][col] > pure_green_intensity) { - const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity)); + if (g_rgb_frame_buffer[row][col] > pure_green_intensity) { + const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (g_rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity)); rgb_matrix_set_color(led[0], boost, max_intensity, boost); } else { - const uint8_t green = (uint8_t)((uint16_t)max_intensity * rgb_frame_buffer[row][col] / pure_green_intensity); + const uint8_t green = (uint8_t)((uint16_t)max_intensity * g_rgb_frame_buffer[row][col] / pure_green_intensity); rgb_matrix_set_color(led[0], 0, green, 0); } } @@ -55,15 +55,15 @@ bool DIGITAL_RAIN(effect_params_t* params) { for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { // if ths is on the bottom row and bright allow decay - if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[row][col] == max_intensity) { - rgb_frame_buffer[row][col]--; + if (row == MATRIX_ROWS - 1 && g_rgb_frame_buffer[row][col] == max_intensity) { + g_rgb_frame_buffer[row][col]--; } // check if the pixel above is bright - if (rgb_frame_buffer[row - 1][col] == max_intensity) { + if (g_rgb_frame_buffer[row - 1][col] == max_intensity) { // allow old bright pixel to decay - rgb_frame_buffer[row - 1][col]--; + g_rgb_frame_buffer[row - 1][col]--; // make this pixel bright - rgb_frame_buffer[row][col] = max_intensity; + g_rgb_frame_buffer[row][col] = max_intensity; } } } diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index 5596146a38..ef2d1500b0 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -12,7 +12,7 @@ static void jellybean_raindrops_set_color(int i, effect_params_t* params) { bool JELLYBEAN_RAINDROPS(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 - if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { + if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); } return false; diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index 9f839a1bce..6e1b5acb0d 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -22,7 +22,7 @@ static void raindrops_set_color(int i, effect_params_t* params) { bool RAINDROPS(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 - if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { + if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); } return false; diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h index dd313f16a5..e82c1b49ee 100644 --- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h +++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h @@ -10,20 +10,20 @@ void process_rgb_matrix_typing_heatmap(keyrecord_t* record) { uint8_t m_col = col - 1; uint8_t p_col = col + 1; - if (m_col < col) rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16); - rgb_frame_buffer[row][col] = qadd8(rgb_frame_buffer[row][col], 32); - if (p_col < MATRIX_COLS) rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16); + if (m_col < col) g_rgb_frame_buffer[row][m_col] = qadd8(g_rgb_frame_buffer[row][m_col], 16); + g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], 32); + if (p_col < MATRIX_COLS) g_rgb_frame_buffer[row][p_col] = qadd8(g_rgb_frame_buffer[row][p_col], 16); if (p_row < MATRIX_ROWS) { - if (m_col < col) rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13); - rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16); - if (p_col < MATRIX_COLS) rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13); + if (m_col < col) g_rgb_frame_buffer[p_row][m_col] = qadd8(g_rgb_frame_buffer[p_row][m_col], 13); + g_rgb_frame_buffer[p_row][col] = qadd8(g_rgb_frame_buffer[p_row][col], 16); + if (p_col < MATRIX_COLS) g_rgb_frame_buffer[p_row][p_col] = qadd8(g_rgb_frame_buffer[p_row][p_col], 13); } if (m_row < row) { - if (m_col < col) rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13); - rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16); - if (p_col < MATRIX_COLS) rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13); + if (m_col < col) g_rgb_frame_buffer[m_row][m_col] = qadd8(g_rgb_frame_buffer[m_row][m_col], 13); + g_rgb_frame_buffer[m_row][col] = qadd8(g_rgb_frame_buffer[m_row][col], 16); + if (p_col < MATRIX_COLS) g_rgb_frame_buffer[m_row][p_col] = qadd8(g_rgb_frame_buffer[m_row][p_col], 13); } } @@ -31,18 +31,18 @@ bool TYPING_HEATMAP(effect_params_t* params) { // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT; - if (led_max > sizeof(rgb_frame_buffer)) led_max = sizeof(rgb_frame_buffer); + if (led_max > sizeof(g_rgb_frame_buffer)) led_max = sizeof(g_rgb_frame_buffer); if (params->init) { rgb_matrix_set_color_all(0, 0, 0); - memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer); + memset(g_rgb_frame_buffer, 0, sizeof g_rgb_frame_buffer); } // Render heatmap & decrease for (int i = led_min; i < led_max; i++) { uint8_t row = i % MATRIX_ROWS; uint8_t col = i / MATRIX_ROWS; - uint8_t val = rgb_frame_buffer[row][col]; + uint8_t val = g_rgb_frame_buffer[row][col]; // set the pixel colour uint8_t led[LED_HITS_TO_REMEMBER]; @@ -55,10 +55,10 @@ bool TYPING_HEATMAP(effect_params_t* params) { rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); } - rgb_frame_buffer[row][col] = qsub8(val, 1); + g_rgb_frame_buffer[row][col] = qsub8(val, 1); } - return led_max < sizeof(rgb_frame_buffer); + return led_max < sizeof(g_rgb_frame_buffer); } # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h index 3d312190a5..9d0c9fab19 100644 --- a/quantum/rgb_matrix_runners/effect_runner_dx_dy.h +++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h @@ -5,7 +5,7 @@ typedef HSV (*dx_dy_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t time); bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); + uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h index 1f4767e321..2824c82527 100644 --- a/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h +++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h @@ -5,7 +5,7 @@ typedef HSV (*dx_dy_dist_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8 bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2); + uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; diff --git a/quantum/rgb_matrix_runners/effect_runner_i.h b/quantum/rgb_matrix_runners/effect_runner_i.h index eebfb78c02..5e6bf5daaf 100644 --- a/quantum/rgb_matrix_runners/effect_runner_i.h +++ b/quantum/rgb_matrix_runners/effect_runner_i.h @@ -5,7 +5,7 @@ typedef HSV (*i_f)(HSV hsv, uint8_t i, uint8_t time); bool effect_runner_i(effect_params_t* params, i_f effect_func) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); + uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time)); diff --git a/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h index c02352b86d..3fb7d48051 100644 --- a/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h +++ b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h @@ -5,7 +5,7 @@ typedef HSV (*sin_cos_i_f)(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t t bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); + uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4); int8_t cos_value = cos8(time) - 128; int8_t sin_value = sin8(time) - 128; for (uint8_t i = led_min; i < led_max; i++) { diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index fc23f55d0e..f447ac9c56 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h @@ -44,13 +44,6 @@ typedef struct PACKED { } effect_params_t; typedef struct PACKED { - // Global tick at 20 Hz - uint32_t tick; - // Ticks since this key was last hit. - uint32_t any_key_hit; -} rgb_counters_t; - -typedef struct PACKED { uint8_t x; uint8_t y; } point_t; diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 26cb41a96f..d33484ccfd 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -15,6 +15,7 @@ */ #include <math.h> #include <string.h> +#include <stdlib.h> #ifdef __AVR__ # include <avr/eeprom.h> # include <avr/interrupt.h> @@ -367,6 +368,8 @@ void rgblight_disable_noeeprom(void) { rgblight_set(); } +bool rgblight_is_enabled(void) { return rgblight_config.enable; } + void rgblight_increase_hue_helper(bool write_to_eeprom) { uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); @@ -521,6 +524,8 @@ uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } uint8_t rgblight_get_val(void) { return rgblight_config.val; } +HSV rgblight_get_hsv(void) { return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; } + void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { if (!rgblight_config.enable) { return; @@ -561,7 +566,7 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) { rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); } -#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) +#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) || defined(RGBLIGHT_EFFECT_TWINKLE) static uint8_t get_interval_time(const uint8_t *default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { return @@ -612,7 +617,7 @@ void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_set #ifdef RGBLIGHT_LAYERS void rgblight_set_layer_state(uint8_t layer, bool enabled) { - uint8_t mask = 1 << layer; + rgblight_layer_mask_t mask = 1 << layer; if (enabled) { rgblight_status.enabled_layer_mask |= mask; } else { @@ -623,10 +628,17 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { if (rgblight_status.timer_enabled == false) { rgblight_mode_noeeprom(rgblight_config.mode); } + +# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF + // If not enabled, then nothing else will actually set the LEDs... + if (!rgblight_config.enable) { + rgblight_set(); + } +# endif } bool rgblight_get_layer_state(uint8_t layer) { - uint8_t mask = 1 << layer; + rgblight_layer_mask_t mask = 1 << layer; return (rgblight_status.enabled_layer_mask & mask) != 0; } @@ -658,21 +670,41 @@ static void rgblight_layers_write(void) { } } } + +# ifdef RGBLIGHT_LAYER_BLINK +rgblight_layer_mask_t _blinked_layer_mask = 0; +uint16_t _blink_duration = 0; +static uint16_t _blink_timer; + +void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { + rgblight_set_layer_state(layer, true); + _blinked_layer_mask |= 1 << layer; + _blink_timer = timer_read(); + _blink_duration = duration_ms; +} + +void rgblight_unblink_layers(void) { + if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { + for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { + if ((_blinked_layer_mask & 1 << layer) != 0) { + rgblight_set_layer_state(layer, false); + } + } + _blinked_layer_mask = 0; + } +} +# endif + #endif __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } #ifndef RGBLIGHT_CUSTOM_DRIVER + void rgblight_set(void) { LED_TYPE *start_led; uint8_t num_leds = rgblight_ranges.clipping_num_leds; -# ifdef RGBLIGHT_LAYERS - if (rgblight_layers != NULL) { - rgblight_layers_write(); - } -# endif - if (!rgblight_config.enable) { for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { led[i].r = 0; @@ -684,6 +716,16 @@ void rgblight_set(void) { } } +# ifdef RGBLIGHT_LAYERS + if (rgblight_layers != NULL +# ifndef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF + && rgblight_config.enable +# endif + ) { + rgblight_layers_write(); + } +# endif + # ifdef RGBLIGHT_LED_MAP LED_TYPE led0[RGBLED_NUM]; for (uint8_t i = 0; i < RGBLED_NUM; i++) { @@ -880,6 +922,12 @@ void rgblight_task(void) { effect_func = (effect_func_t)rgblight_effect_alternating; } # endif +# ifdef RGBLIGHT_EFFECT_TWINKLE + else if (rgblight_status.base_mode == RGBLIGHT_MODE_TWINKLE) { + interval_time = get_interval_time(&RGBLED_TWINKLE_INTERVALS[delta % 3], 5, 50); + effect_func = (effect_func_t)rgblight_effect_twinkle; + } +# endif if (animation_status.restart) { animation_status.restart = false; animation_status.last_timer = timer_read() - interval_time - 1; @@ -909,6 +957,10 @@ void rgblight_task(void) { # endif } } + +# ifdef RGBLIGHT_LAYER_BLINK + rgblight_unblink_layers(); +# endif } #endif /* RGBLIGHT_USE_TIMER */ @@ -1160,3 +1212,58 @@ void rgblight_effect_alternating(animation_status_t *anim) { anim->pos = (anim->pos + 1) % 2; } #endif + +#ifdef RGBLIGHT_EFFECT_TWINKLE +__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {50, 25, 10}; + +typedef struct PACKED { + HSV hsv; + uint8_t life; + bool up; +} TwinkleState; + +static TwinkleState led_twinkle_state[RGBLED_NUM]; + +void rgblight_effect_twinkle(animation_status_t *anim) { + bool random_color = anim->delta / 3; + bool restart = anim->pos == 0; + anim->pos = 1; + + for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { + TwinkleState *t = &(led_twinkle_state[i]); + HSV * c = &(t->hsv); + if (restart) { + // Restart + t->life = 0; + t->hsv.v = 0; + } else if (t->life) { + // This LED is already on, either brightening or dimming + t->life--; + uint8_t on = t->up ? RGBLIGHT_EFFECT_TWINKLE_LIFE - t->life : t->life; + c->v = (uint16_t)rgblight_config.val * on / RGBLIGHT_EFFECT_TWINKLE_LIFE; + if (t->life == 0 && t->up) { + t->up = false; + t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE; + } + if (!random_color) { + c->h = rgblight_config.hue; + c->s = rgblight_config.sat; + } + } else if (rand() < RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY) { + // This LED is off, but was randomly selected to start brightening + c->h = random_color ? rand() % 0xFF : rgblight_config.hue; + c->s = random_color ? (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2) : rgblight_config.sat; + c->v = 0; + t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE; + t->up = true; + } else { + // This LED is off, and was NOT selected to start brightening + } + + LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos; + sethsv(c->h, c->s, c->v, ledp); + } + + rgblight_set(); +} +#endif diff --git a/quantum/rgblight.h b/quantum/rgblight.h index b1585b158b..c36b328a35 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -59,6 +59,12 @@ | 34 | RGBLIGHT_MODE_STATIC_GRADIENT + 9 | | 35 | RGBLIGHT_MODE_RGB_TEST | | 36 | RGBLIGHT_MODE_ALTERNATING | +| 37 | RGBLIGHT_MODE_TWINKLE | +| 38 | RGBLIGHT_MODE_TWINKLE + 1 | +| 39 | RGBLIGHT_MODE_TWINKLE + 2 | +| 40 | RGBLIGHT_MODE_TWINKLE + 3 | +| 41 | RGBLIGHT_MODE_TWINKLE + 4 | +| 42 | RGBLIGHT_MODE_TWINKLE + 5 | |-----------------|-----------------------------------| *****/ @@ -73,6 +79,7 @@ # define RGBLIGHT_EFFECT_STATIC_GRADIENT # define RGBLIGHT_EFFECT_RGB_TEST # define RGBLIGHT_EFFECT_ALTERNATING +# define RGBLIGHT_EFFECT_TWINKLE #endif #ifdef RGBLIGHT_STATIC_PATTERNS @@ -89,7 +96,8 @@ || defined(RGBLIGHT_EFFECT_KNIGHT) \ || defined(RGBLIGHT_EFFECT_CHRISTMAS) \ || defined(RGBLIGHT_EFFECT_RGB_TEST) \ - || defined(RGBLIGHT_EFFECT_ALTERNATING) + || defined(RGBLIGHT_EFFECT_ALTERNATING) \ + || defined(RGBLIGHT_EFFECT_TWINKLE) # define RGBLIGHT_USE_TIMER #endif @@ -141,6 +149,14 @@ enum RGBLIGHT_EFFECT_MODE { # define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 # endif +# ifndef RGBLIGHT_EFFECT_TWINKLE_LIFE +# define RGBLIGHT_EFFECT_TWINKLE_LIFE 75 +# endif + +# ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY +# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 127 +# endif + # ifndef RGBLIGHT_HUE_STEP # define RGBLIGHT_HUE_STEP 8 # endif @@ -180,7 +196,20 @@ typedef struct { # define RGBLIGHT_END_SEGMENT_INDEX (255) # define RGBLIGHT_END_SEGMENTS \ { RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 } -# define RGBLIGHT_MAX_LAYERS 8 +# ifndef RGBLIGHT_MAX_LAYERS +# define RGBLIGHT_MAX_LAYERS 8 +# endif +# if RGBLIGHT_MAX_LAYERS <= 0 +# error invalid RGBLIGHT_MAX_LAYERS value (must be >= 1) +# elif RGBLIGHT_MAX_LAYERS <= 8 +typedef uint8_t rgblight_layer_mask_t; +# elif RGBLIGHT_MAX_LAYERS <= 16 +typedef uint16_t rgblight_layer_mask_t; +# elif RGBLIGHT_MAX_LAYERS <= 32 +typedef uint32_t rgblight_layer_mask_t; +# else +# error invalid RGBLIGHT_MAX_LAYERS value (must be <= 32) +# endif # define RGBLIGHT_LAYER_SEGMENTS(...) \ { __VA_ARGS__, RGBLIGHT_END_SEGMENTS } # define RGBLIGHT_LAYERS_LIST(...) \ @@ -192,6 +221,12 @@ bool rgblight_get_layer_state(uint8_t layer); // Point this to an array of rgblight_segment_t arrays in keyboard_post_init_user to use rgblight layers extern const rgblight_segment_t *const *rgblight_layers; + +# ifdef RGBLIGHT_LAYER_BLINK +# define RGBLIGHT_USE_TIMER +void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms); +# endif + # endif extern LED_TYPE led[RGBLED_NUM]; @@ -202,6 +237,7 @@ extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM; +extern const uint8_t RGBLED_TWINKLE_INTERVALS[3] PROGMEM; extern bool is_rgblight_initialized; // Should stay in sycn with rgb matrix config as we reuse eeprom storage for both (for now) @@ -224,7 +260,7 @@ typedef struct _rgblight_status_t { uint8_t change_flags; # endif # ifdef RGBLIGHT_LAYERS - uint8_t enabled_layer_mask; + rgblight_layer_mask_t enabled_layer_mask; # endif } rgblight_status_t; @@ -314,6 +350,8 @@ uint8_t rgblight_get_mode(void); uint8_t rgblight_get_hue(void); uint8_t rgblight_get_sat(void); uint8_t rgblight_get_val(void); +bool rgblight_is_enabled(void); +HSV rgblight_get_hsv(void); /* === qmk_firmware (core)internal Functions === */ void rgblight_init(void); @@ -392,6 +430,7 @@ void rgblight_effect_knight(animation_status_t *anim); void rgblight_effect_christmas(animation_status_t *anim); void rgblight_effect_rgbtest(animation_status_t *anim); void rgblight_effect_alternating(animation_status_t *anim); +void rgblight_effect_twinkle(animation_status_t *anim); # endif diff --git a/quantum/rgblight_modes.h b/quantum/rgblight_modes.h index 40c9ce4980..7abdb87bc6 100644 --- a/quantum/rgblight_modes.h +++ b/quantum/rgblight_modes.h @@ -53,6 +53,14 @@ _RGBM_SINGLE_DYNAMIC(RGB_TEST) # ifdef RGBLIGHT_EFFECT_ALTERNATING _RGBM_SINGLE_DYNAMIC(ALTERNATING) # endif +# ifdef RGBLIGHT_EFFECT_TWINKLE +_RGBM_MULTI_DYNAMIC(TWINKLE) +_RGBM_TMP_DYNAMIC(twinkle_38, TWINKLE) +_RGBM_TMP_DYNAMIC(twinkle_39, TWINKLE) +_RGBM_TMP_DYNAMIC(twinkle_40, TWINKLE) +_RGBM_TMP_DYNAMIC(twinkle_41, TWINKLE) +_RGBM_TMP_DYNAMIC(TWINKLE_end, TWINKLE) +# endif //// Add a new mode here. // #ifdef RGBLIGHT_EFFECT_<name> // _RGBM_<SINGLE|MULTI>_<STATIC|DYNAMIC>( <name> ) diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 95ee2433ad..5bad9db08f 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -61,17 +61,22 @@ static void init_pins(void) { } static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { - matrix_row_t last_row_value = current_matrix[current_row]; - current_matrix[current_row] = 0; + // Start with a clear matrix row + matrix_row_t current_row_value = 0; for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { pin_t pin = direct_pins[current_row][col_index]; if (pin != NO_PIN) { - current_matrix[current_row] |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index); + current_row_value |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index); } } - return (last_row_value != current_matrix[current_row]); + // If the row has changed, store the row and return the changed flag. + if (current_matrix[current_row] != current_row_value) { + current_matrix[current_row] = current_row_value; + return true; + } + return false; } #elif defined(DIODE_DIRECTION) @@ -98,11 +103,8 @@ static void init_pins(void) { } static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { - // Store last value of row prior to reading - matrix_row_t last_row_value = current_matrix[current_row]; - - // Clear data in matrix row - current_matrix[current_row] = 0; + // Start with a clear matrix row + matrix_row_t current_row_value = 0; // Select row and wait for row selecton to stabilize select_row(current_row); @@ -114,13 +116,18 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) uint8_t pin_state = readPin(col_pins[col_index]); // Populate the matrix row with the state of the col pin - current_matrix[current_row] |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); + current_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); } // Unselect row unselect_row(current_row); - return (last_row_value != current_matrix[current_row]); + // If the row has changed, store the row and return the changed flag. + if (current_matrix[current_row] != current_row_value) { + current_matrix[current_row] = current_row_value; + return true; + } + return false; } # elif (DIODE_DIRECTION == ROW2COL) @@ -155,20 +162,22 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) // For each row... for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) { // Store last value of row prior to reading - matrix_row_t last_row_value = current_matrix[row_index]; + matrix_row_t last_row_value = current_matrix[row_index]; + matrix_row_t current_row_value = last_row_value; // Check row pin state if (readPin(row_pins[row_index]) == 0) { // Pin LO, set col bit - current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col); + current_row_value |= (MATRIX_ROW_SHIFTER << current_col); } else { // Pin HI, clear col bit - current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col); + current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col); } // Determine if the matrix changed state - if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) { - matrix_changed = true; + if ((last_row_value != current_row_value)) { + matrix_changed |= true; + current_matrix[row_index] = current_row_value; } } diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index fb6a3b85af..dfd06f5f94 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -6,6 +6,14 @@ #include "transport.h" #include "quantum.h" +#ifdef PROTOCOL_LUFA +# include <LUFA/Drivers/USB/USB.h> +#endif + +#ifdef PROTOCOL_VUSB +# include "usbdrv.h" +#endif + #ifdef EE_HANDS # include "eeconfig.h" #endif @@ -22,30 +30,54 @@ # define SPLIT_USB_TIMEOUT_POLL 10 #endif +#ifdef PROTOCOL_CHIBIOS +# define SPLIT_USB_DETECT // Force this on for now +#endif + volatile bool isLeftHand = true; -bool waitForUsb(void) { +#if defined(SPLIT_USB_DETECT) +# if defined(PROTOCOL_LUFA) +static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); } +static inline void usbDisable(void) { USB_Disable(); } +# elif defined(PROTOCOL_CHIBIOS) +static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } +static inline void usbDisable(void) { usbStop(&USBD1); } +# elif defined(PROTOCOL_VUSB) +static inline bool usbHasActiveConnection(void) { + usbPoll(); + return usbConfiguration; +} +static inline void usbDisable(void) { usbDeviceDisconnect(); } +# else +static inline bool usbHasActiveConnection(void) { return true; } +static inline void usbDisable(void) {} +# endif + +bool usbIsActive(void) { for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { // This will return true if a USB connection has been established -#if defined(__AVR__) - if (UDADDR & _BV(ADDEN)) { -#else - if (usbGetDriverStateI(&USBD1) == USB_ACTIVE) { -#endif + if (usbHasActiveConnection()) { return true; } wait_ms(SPLIT_USB_TIMEOUT_POLL); } // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow -#if defined(__AVR__) - (USBCON &= ~(_BV(USBE) | _BV(OTGPADE))); -#else - usbStop(&USBD1); -#endif + usbDisable(); return false; } +#elif defined(PROTOCOL_LUFA) +static inline bool usbIsActive(void) { + USB_OTGPAD_On(); // enables VBUS pad + wait_us(5); + + return USB_VBUS_GetStatus(); // checks state of VBUS +} +#else +static inline bool usbIsActive(void) { return true; } +#endif __attribute__((weak)) bool is_keyboard_left(void) { #if defined(SPLIT_HAND_PIN) @@ -66,16 +98,7 @@ __attribute__((weak)) bool is_keyboard_master(void) { // only check once, as this is called often if (usbstate == UNKNOWN) { -#if defined(SPLIT_USB_DETECT) || defined(PROTOCOL_CHIBIOS) - usbstate = waitForUsb() ? MASTER : SLAVE; -#elif defined(__AVR__) - USBCON |= (1 << OTGPADE); // enables VBUS pad - wait_us(5); - - usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS -#else - usbstate = MASTER; -#endif + usbstate = usbIsActive() ? MASTER : SLAVE; } return (usbstate == MASTER); diff --git a/quantum/stm32/halconf.h b/quantum/stm32/halconf.h index 533803a25f..b6c7b392ca 100644 --- a/quantum/stm32/halconf.h +++ b/quantum/stm32/halconf.h @@ -203,7 +203,7 @@ * @note Disabling this option saves both code and data space. */ # if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) -# define PAL_USE_CALLBACKS FALSE +# define PAL_USE_CALLBACKS TRUE # endif /** @@ -211,7 +211,7 @@ * @note Disabling this option saves both code and data space. */ # if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) -# define PAL_USE_WAIT FALSE +# define PAL_USE_WAIT TRUE # endif /*===========================================================================*/ diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk index b9b81a6750..9e18b33827 100644 --- a/quantum/template/ps2avrgb/rules.mk +++ b/quantum/template/ps2avrgb/rules.mk @@ -22,5 +22,3 @@ COMMAND_ENABLE = yes # Commands for debug and configuration BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow WS2812_DRIVER = i2c - -OPT_DEFS = -DDEBUG_LEVEL=0 |