qmk_firmware

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

dgk6x.c (1994B)


      1 /* Copyright 2021 Jessica Sullivan and Don Kjer
      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 "dgk6x.h"
     18 
     19 /* Private Functions */
     20 void off_all_leds(void) {
     21     gpio_write_pin_high(LED_CAPS_LOCK_PIN);
     22     gpio_write_pin_high(LED_WIN_LOCK_PIN);
     23     gpio_write_pin_high(LED_MR_LOCK_PIN);
     24 }
     25 
     26 void on_all_leds(void) {
     27     gpio_write_pin_low(LED_CAPS_LOCK_PIN);
     28     gpio_write_pin_low(LED_WIN_LOCK_PIN);
     29     gpio_write_pin_low(LED_MR_LOCK_PIN);
     30 }
     31 
     32 /* WinLock and MR LEDs are non-standard. Need to override led init */
     33 void led_init_ports(void) {
     34     gpio_set_pin_output(LED_CAPS_LOCK_PIN);
     35     gpio_set_pin_output(LED_WIN_LOCK_PIN);
     36     gpio_set_pin_output(LED_MR_LOCK_PIN);
     37     off_all_leds();
     38 }
     39 
     40 
     41 #ifndef WINLOCK_DISABLED
     42 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
     43     switch (keycode) {
     44         case GU_TOGG:
     45             if (record->event.pressed) {
     46                 // Toggle LED on key press
     47                 gpio_toggle_pin(LED_WIN_LOCK_PIN);
     48             }
     49             break;
     50     }
     51     return process_record_user(keycode, record);
     52 }
     53 #endif /* WINLOCK_DISABLED */
     54 
     55 #ifdef RGB_MATRIX_ENABLE
     56 
     57 bool rgb_matrix_indicators_kb(void) {
     58     if (!rgb_matrix_indicators_user()) {
     59         return false;
     60     }
     61 
     62     if (host_keyboard_led_state().caps_lock) {
     63         rgb_matrix_set_color(CAPS_LED, 0xFF, 0xFF, 0xFF);
     64     }
     65     return true;
     66 }
     67 #endif /* RGB_MATRIX_ENABLE */