summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_tri_layer.c
blob: 1e681b9a1c2e5663f0a6980833c1c46281664dab (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
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#include "process_tri_layer.h"
#include "tri_layer.h"
#include "action_layer.h"

bool process_tri_layer(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
        case QK_TRI_LAYER_LOWER:
            if (record->event.pressed) {
                layer_on(get_tri_layer_lower_layer());
                update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
            } else {
                layer_off(get_tri_layer_lower_layer());
                update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
            }
            return false;
        case QK_TRI_LAYER_UPPER:
            if (record->event.pressed) {
                layer_on(get_tri_layer_upper_layer());
                update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
            } else {
                layer_off(get_tri_layer_upper_layer());
                update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
            }
            return false;
    }
    return true;
}