summaryrefslogtreecommitdiff
path: root/keyboards/qvex/lynepad/lynepad.c
blob: 33620d9da3232d06e9af0476b354a9b38cbed4aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Copyright 2020 KemoNine
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/>.
*/
#include "lynepad.h"

void keyboard_pre_init_kb(void) {
    // Encoder pins
    setPinInput(PIN_TW_SW);
    setPinInput(PIN_RJ_SW);
    setPinInput(PIN_RJ_DIR_A);
    setPinInput(PIN_RJ_DIR_C);
    setPinInput(PIN_RJ_DIR_B);
    setPinInput(PIN_RJ_DIR_D);

    keyboard_pre_init_user();
}

int16_t enc1Center = 1;
int16_t enc1CenterPrev = 1;
int16_t enc2Center = 1;
int16_t enc2CenterPrev = 1;
int16_t enc2Up = 1;
int16_t enc2UpPrev = 1;
int16_t enc2Down = 1;
int16_t enc2DownPrev = 1;
int16_t enc2Left = 1;
int16_t enc2LeftPrev = 1;
int16_t enc2Right = 1;
int16_t enc2RightPrev = 1;

void matrix_scan_kb(void) {
    enc1CenterPrev = enc1Center;
    enc1Center = readPin(PIN_TW_SW);

    enc2CenterPrev = enc2Center;
    enc2Center = readPin(PIN_RJ_SW);
    enc2UpPrev = enc2Up;
    enc2Up = readPin(PIN_RJ_DIR_A);
    enc2DownPrev = enc2Down;
    enc2Down = readPin(PIN_RJ_DIR_C);
    enc2LeftPrev = enc2Left;
    enc2Left = readPin(PIN_RJ_DIR_B);
    enc2RightPrev = enc2Right;
    enc2Right = readPin(PIN_RJ_DIR_D);

    // Ensure any user customizations are called (for some reason this wasn't happening by default)
    matrix_scan_user();
}