diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/keymap_extras/keymap_us_extended.h | 227 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_us_international.h | 20 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_us_international_linux.h | 224 | ||||
-rw-r--r-- | quantum/keymap_extras/sendstring_us_international.h | 100 | ||||
-rw-r--r-- | quantum/quantum.c | 33 | ||||
-rw-r--r-- | quantum/quantum.h | 2 | ||||
-rw-r--r-- | quantum/rgb_matrix.c | 6 | ||||
-rw-r--r-- | quantum/rgblight.c | 102 | ||||
-rw-r--r-- | quantum/rgblight.h | 2 | ||||
-rw-r--r-- | quantum/split_common/matrix.c | 29 | ||||
-rw-r--r-- | quantum/split_common/transport.c | 95 |
11 files changed, 768 insertions, 72 deletions
diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h new file mode 100644 index 0000000000..b2b3a734c9 --- /dev/null +++ b/quantum/keymap_extras/keymap_us_extended.h @@ -0,0 +1,227 @@ +/* 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/>. + */ + +#pragma once + +#include "keymap.h" + +// clang-format off + +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ` │ 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 US_GRV KC_GRV // ` +#define US_1 KC_1 // 1 +#define US_2 KC_2 // 2 +#define US_3 KC_3 // 3 +#define US_4 KC_4 // 4 +#define US_5 KC_5 // 5 +#define US_6 KC_6 // 6 +#define US_7 KC_7 // 7 +#define US_8 KC_8 // 8 +#define US_9 KC_9 // 9 +#define US_0 KC_0 // 0 +#define US_MINS KC_MINS // - +#define US_EQL KC_EQL // = +// Row 2 +#define US_Q KC_Q // Q +#define US_W KC_W // W +#define US_E KC_E // E +#define US_R KC_R // R +#define US_T KC_T // T +#define US_Y KC_Y // Y +#define US_U KC_U // U +#define US_I KC_I // I +#define US_O KC_O // O +#define US_P KC_P // P +#define US_LBRC KC_LBRC // [ +#define US_RBRC KC_RBRC // ] +#define US_BSLS KC_BSLS // (backslash) +// Row 3 +#define US_A KC_A // A +#define US_S KC_S // S +#define US_D KC_D // D +#define US_F KC_F // F +#define US_G KC_G // G +#define US_H KC_H // H +#define US_J KC_J // J +#define US_K KC_K // K +#define US_L KC_L // L +#define US_SCLN KC_SCLN // ; +#define US_QUOT KC_QUOT // ' +// Row 4 +#define US_Z KC_Z // Z +#define US_X KC_X // X +#define US_C KC_C // C +#define US_V KC_V // V +#define US_B KC_B // B +#define US_N KC_N // N +#define US_M KC_M // M +#define US_COMM KC_COMM // , +#define US_DOT KC_DOT // . +#define US_SLSH KC_SLSH // / + +/* Shifted symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define US_TILD S(US_GRV) // ~ +#define US_EXLM S(US_1) // ! +#define US_AT S(US_2) // @ +#define US_HASH S(US_3) // # +#define US_DLR S(US_4) // $ +#define US_PERC S(US_5) // % +#define US_CIRC S(US_6) // ^ +#define US_AMPR S(US_7) // & +#define US_ASTR S(US_8) // * +#define US_LPRN S(US_9) // ( +#define US_RPRN S(US_0) // ) +#define US_UNDS S(US_MINS) // _ +#define US_PLUS S(US_EQL) // + +// Row 2 +#define US_LCBR S(US_LBRC) // { +#define US_RCBR S(US_RBRC) // } +#define US_PIPE S(US_BSLS) // | +// Row 3 +#define US_COLN S(US_SCLN) // : +#define US_DQUO S(US_QUOT) // " +// Row 4 +#define US_LABK S(US_COMM) // < +#define US_RABK S(US_DOT) // > +#define US_QUES S(US_SLSH) // ? + +/* AltGr symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ` │ ¹ │ ² │ ³ │ ¤ │ € │ ^ │ ̛ │ ¾ │ ‘ │ ’ │ ¥ │ × │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │ ¬ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ Á │ ß │ Ð │ │ │ │ Ï │ Œ │ Ø │ ¶ │ ' │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ Æ │ │ © │ │ │ Ñ │ µ │ Ç │ ˙ │ ¿ │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define US_DGRV ALGR(US_GRV) // ` (dead) +#define US_SUP1 ALGR(US_1) // ¹ +#define US_SUP2 ALGR(US_2) // ² +#define US_SUP3 ALGR(US_3) // ³ +#define US_CURR ALGR(US_4) // ¤ +#define US_EURO ALGR(US_5) // € +#define US_DCIR ALGR(US_6) // ^ (dead) +#define US_HORN ALGR(US_7) // ̛̛ (dead) +#define US_OGON ALGR(US_8) // ˛ (dead) +#define US_LSQU ALGR(US_9) // ‘ +#define US_RSQU ALGR(US_0) // ’ +#define US_YEN ALGR(US_MINS) // ¥ +#define US_MUL ALGR(US_EQL) // × +// Row 2 +#define US_ADIA ALGR(US_Q) // Ä +#define US_ARNG ALGR(US_W) // Å +#define US_EACU ALGR(US_E) // É +#define US_EDIA ALGR(US_R) // Ë +#define US_THRN ALGR(US_T) // Þ +#define US_UDIA ALGR(US_Y) // Ü +#define US_UACU ALGR(US_U) // Ú +#define US_IACU ALGR(US_I) // Í +#define US_OACU ALGR(US_O) // Ó +#define US_ODIA ALGR(US_P) // Ö +#define US_LDAQ ALGR(US_LBRC) // « +#define US_RDAQ ALGR(US_RBRC) // » +#define US_NOT ALGR(US_BSLS) // ¬ +// Row 3 +#define US_AACU ALGR(US_A) // Á +#define US_SS ALGR(US_S) // ß +#define US_ETH ALGR(US_D) // Ð +#define US_IDIA ALGR(US_J) // Ï +#define US_OE ALGR(US_K) // Œ +#define US_OSTR ALGR(US_L) // Ø +#define US_PILC ALGR(US_SCLN) // ¶ +#define US_ACUT ALGR(US_QUOT) // ´ (dead) +// Row 4 +#define US_AE ALGR(US_Z) // Æ +#define US_OE_2 ALGR(US_X) // Œ +#define US_COPY ALGR(US_C) // © +#define US_REGD ALGR(US_V) // ® +#define US_NTIL ALGR(US_N) // Ñ +#define US_MICR ALGR(US_M) // µ +#define US_CCED ALGR(US_COMM) // Ç +#define US_DOTA ALGR(US_DOT) // ˙ (dead) +#define US_IQUE ALGR(US_SLSH) // ¿ + +/* Shift+AltGr symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ~ │ ¡ │ ˝ │ ¯ │ £ │ ¸ │ ¼ │ ½ │ ¾ │ ˘ │ ° │ ̣ │ ÷ │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ “ │ ” │ ¦ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ │ § │ │ │ │ │ │ │ │ ° │ " │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ │ │ ¢ │ │ │ │ │ │ ˇ │ ̉ │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define US_DTIL S(ALGR(US_GRV)) // ~ (dead) +#define US_IEXL S(ALGR(US_1)) // ¡ +#define US_DACU S(ALGR(US_2)) // ˝ (dead) +#define US_MACR S(ALGR(US_3)) // ¯ (dead) +#define US_PND S(ALGR(US_4)) // £ +#define US_CEDL S(ALGR(US_5)) // ¸ (dead) +#define US_QRTR S(ALGR(US_6)) // ¼ +#define US_HALF S(ALGR(US_7)) // ½ +#define US_TQTR S(ALGR(US_8)) // ¾ +#define US_BREV S(ALGR(US_9)) // ˘ (dead) +#define US_RNGA S(ALGR(US_0)) // ° (dead) +#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead) +#define US_DIV S(ALGR(US_EQL)) // ÷ +// Row 2 +#define US_LDQU S(ALGR(US_LBRC)) // “ +#define US_RDQU S(ALGR(US_LBRC)) // ” +#define US_BRKP S(ALGR(US_BSLS)) // ¦ +// Row 3 +#define US_SECT S(ALGR(US_S)) // § +#define US_DEG S(ALGR(US_SCLN)) // ° +#define US_DIAE S(ALGR(US_QUOT)) // ¨ (dead) +// Row 4 +#define US_CENT S(ALGR(US_C)) // ¢ +#define US_CARN S(ALGR(US_DOT)) // ˇ (dead) +#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead) + diff --git a/quantum/keymap_extras/keymap_us_international.h b/quantum/keymap_extras/keymap_us_international.h index a3bc465971..49afcc4fb2 100644 --- a/quantum/keymap_extras/keymap_us_international.h +++ b/quantum/keymap_extras/keymap_us_international.h @@ -26,7 +26,7 @@ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ \ │ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ - * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ │ + * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ´ │ │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ * │ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ │ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ @@ -34,7 +34,7 @@ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ */ // Row 1 -#define US_GRV KC_GRV // ` (dead) +#define US_DGRV KC_GRV // ` (dead) #define US_1 KC_1 // 1 #define US_2 KC_2 // 2 #define US_3 KC_3 // 3 @@ -72,7 +72,7 @@ #define US_K KC_K // K #define US_L KC_L // L #define US_SCLN KC_SCLN // ; -#define US_QUOT KC_QUOT // ' (dead) +#define US_ACUT KC_QUOT // ´ (dead) // Row 4 #define US_Z KC_Z // Z #define US_X KC_X // X @@ -91,7 +91,7 @@ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ - * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │ + * │ │ │ │ │ │ │ │ │ │ │ : │ ¨ │ │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ @@ -99,13 +99,13 @@ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ */ // Row 1 -#define US_TILD S(US_GRV) // ~ (dead) +#define US_DTIL S(US_DGRV) // ~ (dead) #define US_EXLM S(US_1) // ! -#define US_AT S(US_2) // " +#define US_AT S(US_2) // @ #define US_HASH S(US_3) // # #define US_DLR S(US_4) // $ #define US_PERC S(US_5) // % -#define US_CIRC S(US_6) // ^ +#define US_DCIR S(US_6) // ^ (dead) #define US_AMPR S(US_7) // & #define US_ASTR S(US_8) // * #define US_LPRN S(US_9) // ( @@ -118,7 +118,7 @@ #define US_PIPE S(US_BSLS) // | // Row 3 #define US_COLN S(US_SCLN) // : -#define US_DQUO S(US_QUOT) // " (dead) +#define US_DIAE S(US_ACUT) // ¨ (dead) // Row 4 #define US_LABK S(US_COMM) // < #define US_RABK S(US_DOT) // > @@ -170,7 +170,7 @@ #define US_ETH ALGR(US_D) // Ð #define US_OSTR ALGR(US_L) // Ø #define US_PILC ALGR(US_SCLN) // ¶ -#define US_ACUT ALGR(US_QUOT) // ´ +#define US_NDAC ALGR(US_ACUT) // ´ // Row 4 #define US_AE ALGR(US_Z) // Æ #define US_COPY ALGR(US_C) // © @@ -201,6 +201,6 @@ // Row 3 #define US_SECT S(ALGR(US_S)) // § #define US_DEG S(ALGR(US_SCLN)) // ° -#define US_DIAE S(ALGR(US_QUOT)) // ¨ +#define US_NDDR S(ALGR(US_ACUT)) // ¨ // Row 4 #define US_CENT S(ALGR(US_C)) // ¢ diff --git a/quantum/keymap_extras/keymap_us_international_linux.h b/quantum/keymap_extras/keymap_us_international_linux.h new file mode 100644 index 0000000000..2c3e230393 --- /dev/null +++ b/quantum/keymap_extras/keymap_us_international_linux.h @@ -0,0 +1,224 @@ +/* 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/>. + */ + +#pragma once + +#include "keymap.h" + +// clang-format off + +/* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ` │ 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 US_DGRV KC_GRV // ` (dead) +#define US_1 KC_1 // 1 +#define US_2 KC_2 // 2 +#define US_3 KC_3 // 3 +#define US_4 KC_4 // 4 +#define US_5 KC_5 // 5 +#define US_6 KC_6 // 6 +#define US_7 KC_7 // 7 +#define US_8 KC_8 // 8 +#define US_9 KC_9 // 9 +#define US_0 KC_0 // 0 +#define US_MINS KC_MINS // - +#define US_EQL KC_EQL // = +// Row 2 +#define US_Q KC_Q // Q +#define US_W KC_W // W +#define US_E KC_E // E +#define US_R KC_R // R +#define US_T KC_T // T +#define US_Y KC_Y // Y +#define US_U KC_U // U +#define US_I KC_I // I +#define US_O KC_O // O +#define US_P KC_P // P +#define US_LBRC KC_LBRC // [ +#define US_RBRC KC_RBRC // ] +#define US_BSLS KC_BSLS // (backslash) +// Row 3 +#define US_A KC_A // A +#define US_S KC_S // S +#define US_D KC_D // D +#define US_F KC_F // F +#define US_G KC_G // G +#define US_H KC_H // H +#define US_J KC_J // J +#define US_K KC_K // K +#define US_L KC_L // L +#define US_SCLN KC_SCLN // ; +#define US_ACUT KC_QUOT // ´ (dead) +// Row 4 +#define US_Z KC_Z // Z +#define US_X KC_X // X +#define US_C KC_C // C +#define US_V KC_V // V +#define US_B KC_B // B +#define US_N KC_N // N +#define US_M KC_M // M +#define US_COMM KC_COMM // , +#define US_DOT KC_DOT // . +#define US_SLSH KC_SLSH // / + +/* Shifted symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ │ │ │ │ │ │ │ │ │ : │ ¨ │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define US_DTIL S(US_DGRV) // ~ (dead) +#define US_EXLM S(US_1) // ! +#define US_AT S(US_2) // @ +#define US_HASH S(US_3) // # +#define US_DLR S(US_4) // $ +#define US_PERC S(US_5) // % +#define US_DCIR S(US_6) // ^ (dead) +#define US_AMPR S(US_7) // & +#define US_ASTR S(US_8) // * +#define US_LPRN S(US_9) // ( +#define US_RPRN S(US_0) // ) +#define US_UNDS S(US_MINS) // _ +#define US_PLUS S(US_EQL) // + +// Row 2 +#define US_LCBR S(US_LBRC) // { +#define US_RCBR S(US_RBRC) // } +#define US_PIPE S(US_BSLS) // | +// Row 3 +#define US_COLN S(US_SCLN) // : +#define US_DIAE S(US_ACUT) // ¨ (dead) +// Row 4 +#define US_LABK S(US_COMM) // < +#define US_RABK S(US_DOT) // > +#define US_QUES S(US_SLSH) // ? + +/* AltGr symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ` │ ¡ │ ² │ ³ │ ¤ │ € │ ¼ │ ½ │ ¾ │ ‘ │ ’ │ ¥ │ × │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │ ¬ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ Á │ ß │ Ð │ │ │ │ │ Œ │ Ø │ ¶ │ ' │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ Æ │ │ © │ │ │ Ñ │ µ │ Ç │ ˙ │ ¿ │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ + +// Row 1 +#define US_GRV ALGR(US_DGRV) // ` +#define US_IEXL ALGR(US_1) // ¡ +#define US_SUP2 ALGR(US_2) // ² +#define US_SUP3 ALGR(US_3) // ³ +#define US_CURR ALGR(US_4) // ¤ +#define US_EURO ALGR(US_5) // € +#define US_QRTR ALGR(US_6) // ¼ +#define US_HALF ALGR(US_7) // ½ +#define US_TQTR ALGR(US_8) // ¾ +#define US_LSQU ALGR(US_9) // ‘ +#define US_RSQU ALGR(US_0) // ’ +#define US_YEN ALGR(US_MINS) // ¥ +#define US_MUL ALGR(US_EQL) // × +// Row 2 +#define US_ADIA ALGR(US_Q) // Ä +#define US_ARNG ALGR(US_W) // Å +#define US_EACU ALGR(US_E) // É +#define US_REGD ALGR(US_R) // ® +#define US_THRN ALGR(US_T) // Þ +#define US_UDIA ALGR(US_Y) // Ü +#define US_UACU ALGR(US_U) // Ú +#define US_IACU ALGR(US_I) // Í +#define US_OACU ALGR(US_O) // Ó +#define US_ODIA ALGR(US_P) // Ö +#define US_LDAQ ALGR(US_LBRC) // « +#define US_RDAQ ALGR(US_RBRC) // » +#define US_NOT ALGR(US_BSLS) // ¬ +// Row 3 +#define US_AACU ALGR(US_A) // Á +#define US_SS ALGR(US_S) // ß +#define US_ETH ALGR(US_D) // Ð +#define US_OE ALGR(US_K) // Œ +#define US_OSTR ALGR(US_L) // Ø +#define US_PILC ALGR(US_SCLN) // ¶ +#define US_QUOT ALGR(US_ACUT) // ' +// Row 4 +#define US_AE ALGR(US_Z) // Æ +#define US_COPY ALGR(US_C) // © +#define US_NTIL ALGR(US_N) // Ñ +#define US_MICR ALGR(US_M) // µ +#define US_CCED ALGR(US_COMM) // Ç +#define US_DOTA ALGR(US_DOT) // ˙ (dead) +#define US_IQUE ALGR(US_SLSH) // ¿ + +/* Shift+AltGr symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ~ │ ¹ │ ˝ │ ¯ │ £ │ ¸ │ ^ │ ̛ │ ˛ │ ˘ │ ° │ ̣ │ ÷ │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ “ │ ” │ ¦ │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ │ § │ │ │ │ │ │ │ │ ° │ " │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ │ │ ¢ │ │ │ │ │ │ ˇ │ ̉ │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define US_TILD S(ALGR(US_DGRV)) // ~ +#define US_SUP1 S(ALGR(US_1)) // ¹ +#define US_DACU S(ALGR(US_2)) // ˝ (dead) +#define US_MACR S(ALGR(US_3)) // ¯ (dead) +#define US_PND S(ALGR(US_4)) // £ +#define US_CEDL S(ALGR(US_5)) // ¸ (dead) +#define US_CIRC S(ALGR(US_6)) // ^ +#define US_HORN S(ALGR(US_7)) // ̛ (dead) +#define US_OGON S(ALGR(US_8)) // ˛ (dead) +#define US_BREV S(ALGR(US_9)) // ˘ (dead) +#define US_RNGA S(ALGR(US_0)) // ° (dead) +#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead) +#define US_DIV S(ALGR(US_EQL)) // ÷ +// Row 2 +#define US_LDQU S(ALGR(US_LBRC)) // “ +#define US_RDQU S(ALGR(US_LBRC)) // ” +#define US_BRKP S(ALGR(US_BSLS)) // ¦ +// Row 3 +#define US_SECT S(ALGR(US_S)) // § +#define US_DEG S(ALGR(US_SCLN)) // ° +#define US_DQUO S(ALGR(US_ACUT)) // " +// Row 4 +#define US_CENT S(ALGR(US_C)) // ¢ +#define US_CARN S(ALGR(US_DOT)) // ˇ (dead) +#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead) diff --git a/quantum/keymap_extras/sendstring_us_international.h b/quantum/keymap_extras/sendstring_us_international.h new file mode 100644 index 0000000000..53a5891fb1 --- /dev/null +++ b/quantum/keymap_extras/sendstring_us_international.h @@ -0,0 +1,100 @@ +/* Copyright 2019 Rys Sommefeldt + * + * 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 UK layouts + +#pragma once + +#include "keymap_us_international.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, 0), + 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, 1, 0, 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, 1, 1, 1, 1, 1), + KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 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, 1, 1, 1, 1, 0), +}; + +__attribute__((weak)) const uint8_t ascii_to_dead_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, 1, 0, 0, 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), + 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, 1, 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, 0, 0, 0, 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, US_1, US_ACUT, US_3, US_4, US_5, US_7, US_ACUT, + // ( ) * + , - . / + US_9, US_0, US_8, US_EQL, US_COMM, US_MINS, US_DOT, US_SLSH, + // 0 1 2 3 4 5 6 7 + US_0, US_1, US_2, US_3, US_4, US_5, US_6, US_7, + // 8 9 : ; < = > ? + US_8, US_9, US_SCLN, US_SCLN, US_COMM, US_EQL, US_DOT, US_SLSH, + // @ A B C D E F G + US_2, US_A, US_B, US_C, US_D, US_E, US_F, US_G, + // H I J K L M N O + US_H, US_I, US_J, US_K, US_L, US_M, US_N, US_O, + // P Q R S T U V W + US_P, US_Q, US_R, US_S, US_T, US_U, US_V, US_W, + // X Y Z [ \ ] ^ _ + US_X, US_Y, US_Z, US_LBRC, US_BSLS, US_RBRC, US_6, US_MINS, + // ` a b c d e f g + US_DGRV, US_A, US_B, US_C, US_D, US_E, US_F, US_G, + // h i j k l m n o + US_H, US_I, US_J, US_K, US_L, US_M, US_N, US_O, + // p q r s t u v w + US_P, US_Q, US_R, US_S, US_T, US_U, US_V, US_W, + // x y z { | } ~ DEL + US_X, US_Y, US_Z, US_LBRC, US_BSLS, US_RBRC, US_DGRV, KC_DEL +}; diff --git a/quantum/quantum.c b/quantum/quantum.c index 3ac0ed8716..ece0388d32 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -391,6 +391,29 @@ __attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = { KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), }; +/* Bit-Packed look-up table to convert an ASCII character to whether + * [Space] needs to be sent after the keycode + */ +__attribute__((weak)) const uint8_t ascii_to_dead_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, 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, 0, 0, 0, 0), + KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), +}; + /* Look-up table to convert an ASCII character to a keycode. */ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { @@ -528,9 +551,10 @@ void send_char(char ascii_code) { } #endif - uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); - bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code); - bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code); + uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); + bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code); + bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code); + bool is_dead = PGM_LOADBIT(ascii_to_dead_lut, (uint8_t)ascii_code); if (is_shifted) { register_code(KC_LSFT); @@ -545,6 +569,9 @@ void send_char(char ascii_code) { if (is_shifted) { unregister_code(KC_LSFT); } + if (is_dead) { + tap_code(KC_SPACE); + } } void set_single_persistent_default_layer(uint8_t default_layer) { diff --git a/quantum/quantum.h b/quantum/quantum.h index f4df5bf155..83694c8324 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -53,6 +53,7 @@ #include "eeconfig.h" #include "bootloader.h" #include "timer.h" +#include "sync_timer.h" #include "config_common.h" #include "led.h" #include "action_util.h" @@ -288,6 +289,7 @@ static __inline__ void __interrupt_enable__(const uint8_t *__s) { extern const uint8_t ascii_to_keycode_lut[128]; extern const uint8_t ascii_to_shift_lut[16]; extern const uint8_t ascii_to_altgr_lut[16]; +extern const uint8_t ascii_to_dead_lut[16]; // clang-format off #define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \ ( ((a) ? 1 : 0) << 0 \ diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 04af3ae9ec..a945df68e0 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -266,9 +266,9 @@ static bool rgb_matrix_none(effect_params_t *params) { static void rgb_task_timers(void) { #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 - uint32_t deltaTime = timer_elapsed32(rgb_timer_buffer); + uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 - rgb_timer_buffer = timer_read32(); + rgb_timer_buffer = sync_timer_read32(); // Update double buffer timers #if RGB_DISABLE_TIMEOUT > 0 @@ -296,7 +296,7 @@ static void rgb_task_timers(void) { static void rgb_task_sync(void) { // next task - if (timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; + if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; } static void rgb_task_start(void) { diff --git a/quantum/rgblight.c b/quantum/rgblight.c index d856f6d6c8..b16c3e7c26 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -29,7 +29,7 @@ #endif #include "wait.h" #include "progmem.h" -#include "timer.h" +#include "sync_timer.h" #include "rgblight.h" #include "color.h" #include "debug.h" @@ -42,6 +42,9 @@ #ifndef MIN # define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif +#ifndef MAX +# define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif #ifdef RGBLIGHT_SPLIT /* for split keyboard */ @@ -689,18 +692,16 @@ 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 |= (rgblight_layer_mask_t)1 << layer; - _blink_timer = timer_read(); - _blink_duration = duration_ms; + _blink_timer = sync_timer_read() + duration_ms; } void rgblight_unblink_layers(void) { - if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { + if (_blinked_layer_mask != 0 && timer_expired(sync_timer_read(), _blink_timer)) { for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { if ((_blinked_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) { rgblight_set_layer_state(layer, false); @@ -842,7 +843,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) { animation_status.restart = true; } # endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */ -# endif /* RGBLIGHT_USE_TIMER */ +# endif /* RGBLIGHT_USE_TIMER */ } #endif /* RGBLIGHT_SPLIT */ @@ -875,7 +876,7 @@ void rgblight_timer_enable(void) { if (!is_static_effect(rgblight_config.mode)) { rgblight_status.timer_enabled = true; } - animation_status.last_timer = timer_read(); + animation_status.last_timer = sync_timer_read(); RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; dprintf("rgblight timer enabled.\n"); } @@ -978,24 +979,25 @@ void rgblight_task(void) { # 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); + interval_time = get_interval_time(&RGBLED_TWINKLE_INTERVALS[delta % 3], 5, 30); 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; + animation_status.last_timer = sync_timer_read(); animation_status.pos16 = 0; // restart signal to local each effect } - if (timer_elapsed(animation_status.last_timer) >= interval_time) { + uint16_t now = sync_timer_read(); + if (timer_expired(now, animation_status.last_timer)) { # if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) static uint16_t report_last_timer = 0; static bool tick_flag = false; uint16_t oldpos16; if (tick_flag) { tick_flag = false; - if (timer_elapsed(report_last_timer) >= 30000) { - report_last_timer = timer_read(); + if (timer_expired(now, report_last_timer)) { + report_last_timer += 30000; dprintf("rgblight animation tick report to slave\n"); RGBLIGHT_SPLIT_ANIMATION_TICK; } @@ -1019,8 +1021,7 @@ void rgblight_task(void) { #endif /* RGBLIGHT_USE_TIMER */ -// Effects -#ifdef RGBLIGHT_EFFECT_BREATHING +#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_TWINKLE) # ifndef RGBLIGHT_EFFECT_BREATHE_CENTER # ifndef RGBLIGHT_BREATHE_TABLE_SIZE @@ -1029,17 +1030,24 @@ void rgblight_task(void) { # include <rgblight_breathe_table.h> # endif -__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; - -void rgblight_effect_breathing(animation_status_t *anim) { - float val; - +static uint8_t breathe_calc(uint8_t pos) { // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ # ifdef RGBLIGHT_EFFECT_BREATHE_TABLE - val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]); + return pgm_read_byte(&rgblight_effect_breathe_table[pos / table_scale]); # else - val = (exp(sin((anim->pos / 255.0) * M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER / M_E) * (RGBLIGHT_EFFECT_BREATHE_MAX / (M_E - 1 / M_E)); + return (exp(sin((pos / 255.0) * M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER / M_E) * (RGBLIGHT_EFFECT_BREATHE_MAX / (M_E - 1 / M_E)); # endif +} + +#endif + +// Effects +#ifdef RGBLIGHT_EFFECT_BREATHING + +__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; + +void rgblight_effect_breathing(animation_status_t *anim) { + uint8_t val = breathe_calc(anim->pos); rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); anim->pos = (anim->pos + 1); } @@ -1291,48 +1299,54 @@ void rgblight_effect_alternating(animation_status_t *anim) { #endif #ifdef RGBLIGHT_EFFECT_TWINKLE -__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {50, 25, 10}; +__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {30, 15, 5}; typedef struct PACKED { HSV hsv; uint8_t life; - bool up; + uint8_t max_life; } 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; + const bool random_color = anim->delta / 3; + const bool restart = anim->pos == 0; + anim->pos = 1; + + const uint8_t bottom = breathe_calc(0); + const uint8_t top = breathe_calc(127); + + uint8_t frac(uint8_t n, uint8_t d) { return (uint16_t)255 * n / d; } + uint8_t scale(uint16_t v, uint8_t scale) { return (v * scale) >> 8; } for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { TwinkleState *t = &(led_twinkle_state[i]); HSV * c = &(t->hsv); + + if (!random_color) { + c->h = rgblight_config.hue; + c->s = rgblight_config.sat; + } + if (restart) { // Restart - t->life = 0; - t->hsv.v = 0; + t->life = 0; + c->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) { + uint8_t unscaled = frac(breathe_calc(frac(t->life, t->max_life)) - bottom, top - bottom); + c->v = scale(rgblight_config.val, unscaled); + } else if (rand() < scale((uint16_t)RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2)) { // 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; + if (random_color) { + c->h = rand() % 0xFF; + c->s = (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2); + } + c->v = 0; + t->max_life = MAX(20, MIN(RGBLIGHT_EFFECT_TWINKLE_LIFE, rgblight_config.val)); + t->life = t->max_life; } else { // This LED is off, and was NOT selected to start brightening } diff --git a/quantum/rgblight.h b/quantum/rgblight.h index efbffa7fdb..b9306e4d2c 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -150,7 +150,7 @@ enum RGBLIGHT_EFFECT_MODE { # endif # ifndef RGBLIGHT_EFFECT_TWINKLE_LIFE -# define RGBLIGHT_EFFECT_TWINKLE_LIFE 75 +# define RGBLIGHT_EFFECT_TWINKLE_LIFE 200 # endif # ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 51bf8b1095..06bab734e7 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -245,48 +245,59 @@ void matrix_init(void) { split_post_init(); } -void matrix_post_scan(void) { +bool matrix_post_scan(void) { + bool changed = false; if (is_keyboard_master()) { static uint8_t error_count; - if (!transport_master(matrix + thatHand)) { + matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; + if (!transport_master(slave_matrix)) { error_count++; if (error_count > ERROR_DISCONNECT_COUNT) { // reset other half if disconnected for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[thatHand + i] = 0; + slave_matrix[i] = 0; } } } else { error_count = 0; } + for (int i = 0; i < ROWS_PER_HAND; ++i) { + if (matrix[thatHand + i] != slave_matrix[i]) { + matrix[thatHand + i] = slave_matrix[i]; + changed = true; + } + } + matrix_scan_quantum(); } else { transport_slave(matrix + thisHand); matrix_slave_scan_user(); } + + return changed; } uint8_t matrix_scan(void) { - bool changed = false; + bool local_changed = false; #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { - changed |= read_cols_on_row(raw_matrix, current_row); + local_changed |= read_cols_on_row(raw_matrix, current_row); } #elif (DIODE_DIRECTION == ROW2COL) // Set col, read rows for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { - changed |= read_rows_on_col(raw_matrix, current_col); + local_changed |= read_rows_on_col(raw_matrix, current_col); } #endif - debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); + debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); - matrix_post_scan(); - return (uint8_t)changed; + bool remote_changed = matrix_post_scan(); + return (uint8_t)(local_changed || remote_changed); } diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 467ff81a97..e601fb4df5 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c @@ -6,6 +6,7 @@ #include "quantum.h" #define ROWS_PER_HAND (MATRIX_ROWS / 2) +#define SYNC_TIMER_OFFSET 2 #ifdef RGBLIGHT_ENABLE # include "rgblight.h" @@ -27,8 +28,20 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A; # include "i2c_slave.h" typedef struct _I2C_slave_buffer_t { +# ifndef DISABLE_SYNC_TIMER + uint32_t sync_timer; +# endif matrix_row_t smatrix[ROWS_PER_HAND]; +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods; + uint8_t weak_mods; +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods; +# endif +# endif +# ifdef BACKLIGHT_ENABLE uint8_t backlight_level; +# endif # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) rgblight_syncinfo_t rgblight_sync; # endif @@ -42,9 +55,13 @@ typedef struct _I2C_slave_buffer_t { static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; +# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) +# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) +# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) +# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) +# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) -# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) @@ -91,10 +108,43 @@ bool transport_master(matrix_row_t matrix[]) { } } # endif + +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods = get_mods(); + if (real_mods != i2c_buffer->real_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_REAL_MODS_START, (void *)&real_mods, sizeof(real_mods), TIMEOUT) >= 0) { + i2c_buffer->real_mods = real_mods; + } + } + + uint8_t weak_mods = get_weak_mods(); + if (weak_mods != i2c_buffer->weak_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WEAK_MODS_START, (void *)&weak_mods, sizeof(weak_mods), TIMEOUT) >= 0) { + i2c_buffer->weak_mods = weak_mods; + } + } + +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods = get_oneshot_mods(); + if (oneshot_mods != i2c_buffer->oneshot_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_ONESHOT_MODS_START, (void *)&oneshot_mods, sizeof(oneshot_mods), TIMEOUT) >= 0) { + i2c_buffer->oneshot_mods = oneshot_mods; + } + } +# endif +# endif + +# ifndef DISABLE_SYNC_TIMER + i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; + i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); +# endif return true; } void transport_slave(matrix_row_t matrix[]) { +# ifndef DISABLE_SYNC_TIMER + sync_timer_update(i2c_buffer->sync_timer); +# endif // Copy matrix to I2C buffer memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); @@ -118,6 +168,14 @@ void transport_slave(matrix_row_t matrix[]) { # ifdef WPM_ENABLE set_current_wpm(i2c_buffer->current_wpm); # endif + +# ifdef SPLIT_MODS_ENABLE + set_mods(i2c_buffer->real_mods); + set_weak_mods(i2c_buffer->weak_mods); +# ifndef NO_ACTION_ONESHOT + set_oneshot_mods(i2c_buffer->oneshot_mods); +# endif +# endif } void transport_master_init(void) { i2c_init(); } @@ -133,12 +191,22 @@ typedef struct _Serial_s2m_buffer_t { matrix_row_t smatrix[ROWS_PER_HAND]; # ifdef ENCODER_ENABLE - uint8_t encoder_state[NUMBER_OF_ENCODERS]; + uint8_t encoder_state[NUMBER_OF_ENCODERS]; # endif } Serial_s2m_buffer_t; typedef struct _Serial_m2s_buffer_t { +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods; + uint8_t weak_mods; +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods; +# endif +# endif +# ifndef DISABLE_SYNC_TIMER + uint32_t sync_timer; +# endif # ifdef BACKLIGHT_ENABLE uint8_t backlight_level; # endif @@ -251,11 +319,26 @@ bool transport_master(matrix_row_t matrix[]) { // Write wpm to slave serial_m2s_buffer.current_wpm = get_current_wpm(); # endif + +# ifdef SPLIT_MODS_ENABLE + serial_m2s_buffer.real_mods = get_mods(); + serial_m2s_buffer.weak_mods = get_weak_mods(); +# ifndef NO_ACTION_ONESHOT + serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); +# endif +# endif +# ifndef DISABLE_SYNC_TIMER + serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; +# endif return true; } void transport_slave(matrix_row_t matrix[]) { transport_rgblight_slave(); +# ifndef DISABLE_SYNC_TIMER + sync_timer_update(serial_m2s_buffer.sync_timer); +# endif + // TODO: if MATRIX_COLS > 8 change to pack() for (int i = 0; i < ROWS_PER_HAND; ++i) { serial_s2m_buffer.smatrix[i] = matrix[i]; @@ -271,6 +354,14 @@ void transport_slave(matrix_row_t matrix[]) { # ifdef WPM_ENABLE set_current_wpm(serial_m2s_buffer.current_wpm); # endif + +# ifdef SPLIT_MODS_ENABLE + set_mods(serial_m2s_buffer.real_mods); + set_weak_mods(serial_m2s_buffer.weak_mods); +# ifndef NO_ACTION_ONESHOT + set_oneshot_mods(serial_m2s_buffer.oneshot_mods); +# endif +# endif } #endif |