qmk_firmware

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

snap.c (1957B)


      1 /* Copyright 2021 Jay Greco
      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 #include "snap.h"
     17 
     18 void matrix_init_kb(void) {
     19     set_bitc_LED(LED_OFF);
     20     matrix_init_remote_kb();
     21     matrix_init_user();
     22 }
     23 
     24 void keyboard_post_init_kb(void) {
     25 #ifdef CONSOLE_ENABLE
     26     debug_enable = true;
     27     debug_matrix = true;
     28 #endif
     29     keyboard_post_init_user();
     30 }
     31 
     32 void matrix_scan_kb(void) {
     33     matrix_scan_remote_kb();
     34     matrix_scan_user();
     35 }
     36 
     37 // Use Bit-C LED to show CAPS LOCK and NUM LOCK status
     38 void led_update_ports(led_t led_state) {
     39     set_bitc_LED(led_state.caps_lock ? LED_DIM : LED_OFF);
     40 }
     41 
     42 bool shutdown_kb(bool jump_to_bootloader) {
     43     if (!shutdown_user(jump_to_bootloader)) {
     44         return false;
     45     }
     46 
     47     set_bitc_LED(LED_DIM);
     48 #ifdef RGBLIGHT_ENABLE
     49     rgblight_disable_noeeprom();
     50 #endif
     51 #ifdef OLED_ENABLE
     52     oled_off();
     53 #endif
     54     return true;
     55 }
     56 
     57 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
     58     // If console is enabled, it will print the matrix position and status of each key pressed
     59 #ifdef CONSOLE_ENABLE
     60     dprintf("kc: 0x%04X, col: %u, row: %u, pressed: %b, time: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time);
     61 #endif
     62 
     63     process_record_remote_kb(keycode, record);
     64     if (!process_record_user(keycode, record)) return false;
     65 
     66     return true;
     67 }