lynepad.c (1864B)
1 /* 2 Copyright 2020 KemoNine 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 This program is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 GNU General Public License for more details. 11 You should have received a copy of the GNU General Public License 12 along with this program. If not, see <http://www.gnu.org/licenses/>. 13 */ 14 #include "quantum.h" 15 16 void keyboard_pre_init_kb(void) { 17 // Encoder pins 18 gpio_set_pin_input(PIN_TW_SW); 19 gpio_set_pin_input(PIN_RJ_SW); 20 gpio_set_pin_input(PIN_RJ_DIR_A); 21 gpio_set_pin_input(PIN_RJ_DIR_C); 22 gpio_set_pin_input(PIN_RJ_DIR_B); 23 gpio_set_pin_input(PIN_RJ_DIR_D); 24 25 keyboard_pre_init_user(); 26 } 27 28 int16_t enc1Center = 1; 29 int16_t enc1CenterPrev = 1; 30 int16_t enc2Center = 1; 31 int16_t enc2CenterPrev = 1; 32 int16_t enc2Up = 1; 33 int16_t enc2UpPrev = 1; 34 int16_t enc2Down = 1; 35 int16_t enc2DownPrev = 1; 36 int16_t enc2Left = 1; 37 int16_t enc2LeftPrev = 1; 38 int16_t enc2Right = 1; 39 int16_t enc2RightPrev = 1; 40 41 void matrix_scan_kb(void) { 42 enc1CenterPrev = enc1Center; 43 enc1Center = gpio_read_pin(PIN_TW_SW); 44 45 enc2CenterPrev = enc2Center; 46 enc2Center = gpio_read_pin(PIN_RJ_SW); 47 enc2UpPrev = enc2Up; 48 enc2Up = gpio_read_pin(PIN_RJ_DIR_A); 49 enc2DownPrev = enc2Down; 50 enc2Down = gpio_read_pin(PIN_RJ_DIR_C); 51 enc2LeftPrev = enc2Left; 52 enc2Left = gpio_read_pin(PIN_RJ_DIR_B); 53 enc2RightPrev = enc2Right; 54 enc2Right = gpio_read_pin(PIN_RJ_DIR_D); 55 56 // Ensure any user customizations are called (for some reason this wasn't happening by default) 57 matrix_scan_user(); 58 }