qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

white.c (5360B)


      1 /* Copyright 2023 @ Keychron (https://www.keychron.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 
     17 #include "quantum.h"
     18 
     19 // clang-format off
     20 #ifdef LED_MATRIX_ENABLE
     21 const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
     22 /* Refer to SNLED27351 manual for these locations
     23  *   driver
     24  *   |  LED address
     25  *   |  |   */
     26     {0, CB1_CA16}, // esc
     27     {0, CB1_CA15}, // f1
     28     {0, CB1_CA14}, // f2
     29     {0, CB1_CA13}, // f3
     30     {0, CB1_CA12}, // f4
     31     {0, CB1_CA11}, // f5
     32     {0, CB1_CA10}, // f6
     33     {0, CB1_CA9},  // f7
     34     {0, CB1_CA8},  // f8
     35     {0, CB1_CA7},  // f9
     36     {0, CB1_CA6},  // f10
     37     {0, CB1_CA5},  // f11
     38     {0, CB1_CA4},  // f12
     39     {0, CB1_CA2},  // print
     40     {0, CB1_CA1},  // siri
     41     {0, CB7_CA1},  // light
     42 
     43     {0, CB2_CA16}, // ~
     44     {0, CB2_CA15}, // 1!
     45     {0, CB2_CA14}, // 2@
     46     {0, CB2_CA13}, // 3#
     47     {0, CB2_CA12}, // 4$
     48     {0, CB2_CA11}, // 5%
     49     {0, CB2_CA10}, // 6^
     50     {0, CB2_CA9},  // 7&
     51     {0, CB2_CA8},  // 8*
     52     {0, CB2_CA7},  // 9(
     53     {0, CB2_CA6},  // 0)
     54     {0, CB2_CA5},  // -_
     55     {0, CB2_CA4},  // =+
     56     {0, CB2_CA3},  // back space
     57     {0, CB2_CA2},  // INS
     58     {0, CB2_CA1},  // HOME
     59     {0, CB8_CA1},  // PGUP
     60 
     61     {0, CB3_CA16}, // tab
     62     {0, CB3_CA15}, // q
     63     {0, CB3_CA14}, // w
     64     {0, CB3_CA13}, // e
     65     {0, CB3_CA12}, // r
     66     {0, CB3_CA11}, // t
     67     {0, CB3_CA10}, // y
     68     {0, CB3_CA9},  // u
     69     {0, CB3_CA8},  // i
     70     {0, CB3_CA7},  // o
     71     {0, CB3_CA6},  // p
     72     {0, CB3_CA5},  // [{
     73     {0, CB3_CA4},  // ]}
     74     {0, CB3_CA3},  // \|
     75     {0, CB3_CA2},  // DEL
     76     {0, CB3_CA1},  // END
     77     {0, CB7_CA6},  // PGDN
     78 
     79     {0, CB4_CA16}, // caps lock
     80     {0, CB4_CA15}, // a
     81     {0, CB4_CA14}, // s
     82     {0, CB4_CA13}, // d
     83     {0, CB4_CA12}, // f
     84     {0, CB4_CA11}, // g
     85     {0, CB4_CA10}, // h
     86     {0, CB4_CA9},  // j
     87     {0, CB4_CA8},  // k
     88     {0, CB4_CA7},  // l
     89     {0, CB4_CA6},  // ;:
     90     {0, CB4_CA5},  // '"
     91     {0, CB4_CA3},  // enter
     92 
     93     {0, CB8_CA7},  // CPAS
     94     {0, CB8_CA8},  // MAC
     95     {0, CB8_CA9},  // WIN
     96 
     97     {0, CB5_CA16}, // left shift
     98     {0, CB5_CA14}, // z
     99     {0, CB5_CA13}, // x
    100     {0, CB5_CA12}, // c
    101     {0, CB5_CA11}, // v
    102     {0, CB5_CA10}, // b
    103     {0, CB5_CA9},  // b
    104     {0, CB5_CA8},  // n
    105     {0, CB5_CA7},  // m
    106     {0, CB5_CA6},  // ,<
    107     {0, CB5_CA5},  // .>
    108     {0, CB5_CA3},  // right shift
    109     {0, CB5_CA1},  // up
    110 
    111     {0, CB6_CA16}, // left ctrl
    112     {0, CB6_CA15}, // left command
    113     {0, CB6_CA14}, // left option
    114     {0, CB6_CA10}, // space
    115     {0, CB6_CA6},  // right command
    116     {0, CB6_CA5},  // right option
    117     {0, CB6_CA4},  // right ctrl
    118     {0, CB6_CA3},  // Fn
    119     {0, CB6_CA2},  // left
    120     {0, CB6_CA1},  // down
    121     {0, CB7_CA13}, // right
    122 };
    123 
    124 // clang-format on
    125 
    126 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
    127     if (!process_record_user(keycode, record)) {
    128         return false;
    129     }
    130     switch (keycode) {
    131         case LM_TOGG:
    132             if (record->event.pressed) {
    133                 switch (led_matrix_get_flags()) {
    134                     case LED_FLAG_ALL: {
    135                         led_matrix_set_flags(LED_FLAG_NONE);
    136                         led_matrix_set_value_all(0);
    137                     } break;
    138                     default: {
    139                         led_matrix_set_flags(LED_FLAG_ALL);
    140                     } break;
    141                 }
    142             }
    143             if (!led_matrix_is_enabled()) {
    144                 led_matrix_set_flags(LED_FLAG_ALL);
    145                 led_matrix_enable();
    146             }
    147             return false;
    148     }
    149     return true;
    150 }
    151 
    152 bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
    153     if (!led_matrix_indicators_advanced_user(led_min, led_max)) {
    154         return false;
    155     }
    156     if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
    157         led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
    158         led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
    159         led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
    160     } else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
    161         led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
    162         led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
    163         led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
    164     } else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
    165         led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
    166         led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
    167         led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
    168     } else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
    169         led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
    170         led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
    171         led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
    172     }
    173     return true;
    174 }
    175 
    176 #endif