/*
 * Copyright (c) 2020 The ZMK Contributors
 *
 * SPDX-License-Identifier: MIT
 */

#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>
#include <dt-bindings/zmk/ext_power.h>
#include <dt-bindings/zmk/rgb.h>

#define DEFAULT 0
#define LOWER   1

/ {
    keymap {
        compatible = "zmk,keymap";

        default_layer {
            // | Esc   | Vol Up | Esc   | F1   | F2  | F3  | F4  | F5  | F6    | F5     | F6  | F7  | F8  | F9  | F10  | F11   | F12   | Del    |
            // | Home  | Vol Dn | `     | 1    | 2   | 3   | 4   | 5   | 6     | 5      | 6   | 7   | 8   | 9   | 0    | -     | =     | Bk Spc |
            // | End   | Tab    | Tab   | Q    | W   | E   | R   | T   | Y     | T      | Y   | U   | I   | O   | P    | [     | ]     | \      |
            // | Pg Up | Caps   | Ctrl  | A    | S   | D   | F   | G   | H     | G      | H   | J   | K   | L   | ;    | '     | Enter | Enter  |
            // | Pg Dn | Up     | Shift | Z    | X   | C   | V   | B   | N     | B      | N   | M   | ,   | .   | /    | Shift | Up    |        |
            // | Left  | Dn     | Right | Ctrl | Alt | Win | Spc | Spc | Enter | Bk Spc | Spc | Spc | Win | Alt | Ctrl | Left  | Dn    | Right  |
            bindings = <
            &kp ESC   &kp C_VOL_UP &kp ESC   &kp F1    &kp F2   &kp F3    &kp F4    &kp F5    &kp F6    &kp F5     &kp F6    &kp F7    &kp F8    &kp F9   &kp F10   &kp F11   &kp F12   &kp DEL
            &kp HOME  &kp C_VOL_DN &kp GRAVE &kp N1    &kp N2   &kp N3    &kp N4    &kp N5    &kp N6    &kp N5     &kp N6    &kp N7    &kp N8    &kp N9   &kp N0    &kp MINUS &kp EQUAL &kp BSPC
            &kp END   &kp TAB      &kp TAB   &kp Q     &kp W    &kp E     &kp R     &kp T     &kp Y     &kp T      &kp Y     &kp U     &kp I     &kp O    &kp P     &kp LBKT  &kp RBKT  &kp BSLH
            &kp PG_UP &kp CAPS     &kp LCTRL &kp A     &kp S    &kp D     &kp F     &kp G     &kp H     &kp G      &kp H     &kp J     &kp K     &kp L    &kp SEMI  &kp APOS  &kp ENTER &kp ENTER
            &kp PG_DN &kp UP       &kp LSHFT &kp Z     &kp X    &kp C     &kp V     &kp B     &kp N     &kp B      &kp N     &kp M     &kp COMMA &kp DOT  &kp SLASH &kp RSHFT &kp UP    &mo LOWER
            &kp LEFT  &kp DOWN     &kp RIGHT &kp LCTRL &kp LALT &kp LMETA &kp SPACE &kp SPACE &kp ENTER &kp BSPC   &kp SPACE &kp SPACE &kp RMETA &kp RALT &kp RCTRL &kp LEFT  &kp DOWN  &kp RIGHT
            >;
        };

        lower_layer {
            // | | | | | | | | | | | | | | | | | | |
            // | | | | | | | | | | | | | | | | | | |
            // | | | | | | | | | | | | | | | | | | |
            // | | | | | | | | | | | | | | | | | | |
            // | | | | | | | | | | | | | | | | | | |
            // | | | | | | | | | | | | | | | | | | |
            bindings = <
            &bt BT_CLR       &bt BT_SEL 0      &bt BT_SEL 1    &bt BT_SEL 2    &bt BT_SEL 3    &bt BT_SEL 4    &bt BT_SEL 5 &bt BT_SEL 6 &bt BT_SEL 7 &bt BT_CLR       &bt BT_SEL 0      &bt BT_SEL 1    &bt BT_SEL 2    &bt BT_SEL 3    &bt BT_SEL 4    &bt BT_SEL 5 &bt BT_SEL 6 &bt BT_SEL 7
            &out OUT_USB     &out OUT_BLE      &trans          &trans          &trans          &trans          &trans       &trans       &trans       &out OUT_USB     &out OUT_BLE      &trans          &trans          &trans          &trans          &trans       &trans       &trans
            &ext_power EP_ON &ext_power EP_OFF &trans          &trans          &trans          &trans          &trans       &trans       &trans       &ext_power EP_ON &ext_power EP_OFF &trans          &trans          &trans          &trans          &trans       &trans       &trans
            &sys_reset           &bootloader       &trans          &trans          &trans          &trans          &trans       &trans       &trans       &sys_reset           &bootloader       &trans          &trans          &trans          &trans          &trans       &trans       &trans
            &rgb_ug RGB_TOG  &rgb_ug RGB_HUI   &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &trans       &trans       &trans       &rgb_ug RGB_TOG  &rgb_ug RGB_HUI   &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &trans       &trans       &trans
            &trans           &rgb_ug RGB_HUD   &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &trans       &trans       &trans       &trans           &rgb_ug RGB_HUD   &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &trans       &trans       &trans
            >;
        };
    };
};
