mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-23 08:02:03 +00:00
213 lines
12 KiB
C
213 lines
12 KiB
C
/* Copyright 2019 Thomas Baart <thomas@splitkb.com>
|
|
*
|
|
* 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 QMK_KEYBOARD_H
|
|
|
|
#define _QWERTY 0
|
|
#define _LOWER 1
|
|
#define _RAISE 2
|
|
#define _ADJUST 3
|
|
|
|
enum custom_keycodes {
|
|
LOWER = SAFE_RANGE,
|
|
RAISE
|
|
};
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
/*
|
|
* QWERTY Base Layer
|
|
*
|
|
* ,-------------------------------------------. ,-------------------------------------------.
|
|
* |RAIS/ESC| Q | W | E | R | T | | Y | U | I | O | P | | \ |
|
|
* |--------+------+------+------+------+------| |------+------+------+------+------+--------|
|
|
* |Ctrl/BS | A | S | D | F | G | | H | J | K | L | ; : | ' " |
|
|
* |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
|
|
* | LShift | Z | X | C | V | B |LShift|LShift| |LShift|LShift| N | M | , < | . > | / ? | - _ |
|
|
* `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
|
|
* | GUI | Del | Enter| Space| Esc | | Enter| Space| Tab | Bksp | AltGr|
|
|
* | | | Alt | Lower| Raise| | Lower| Raise| | | |
|
|
* `----------------------------------' `----------------------------------'
|
|
*/
|
|
[_QWERTY] = LAYOUT(
|
|
LT(RAISE, KC_ESC), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_PIPE, \
|
|
MT(MOD_LCTL, KC_BSPC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LSFT, KC_LSFT, KC_LSFT, KC_LSFT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, \
|
|
KC_GUI, KC_DEL, MT(MOD_LALT, KC_ENT), LT(LOWER, KC_SPC), LT(RAISE, KC_ESC), LT(LOWER, KC_ENT), LT(RAISE, KC_SPC), KC_TAB, KC_BSPC, KC_RALT
|
|
),
|
|
/*
|
|
* Lower Layer
|
|
*
|
|
* ,-------------------------------------------. ,-------------------------------------------.
|
|
* | | ! | @ | { | } | | | | | | | | | | \ |
|
|
* |--------+------+------+------+------+------| |------+------+------+------+------+--------|
|
|
* | | # | $ | ( | ) | ` | | + | - | / | * | % | ' " |
|
|
* |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
|
|
* | | % | ^ | [ | ] | ~ | | | | | | & | = | , | . | / ? | - _ |
|
|
* `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
|
|
* | | | | ; | = | | = | ; | | | |
|
|
* | | | | | | | | | | | |
|
|
* `----------------------------------' `----------------------------------'
|
|
*/
|
|
[_LOWER] = LAYOUT(
|
|
_______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, _______, _______, _______, KC_BSLS, \
|
|
_______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC, KC_QUOT, \
|
|
_______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, _______, _______, _______, _______, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, \
|
|
_______, _______, _______, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, _______, _______, _______
|
|
),
|
|
/*
|
|
* Raise Layer
|
|
*
|
|
* ,-------------------------------------------. ,-------------------------------------------.
|
|
* | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
|
|
* |--------+------+------+------+------+------| |------+------+------+------+------+--------|
|
|
* | | | Prev | Play | Next | VolUp| | Left | Down | Up | Right| | |
|
|
* |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
|
|
* | | | | | Mute | VolDn| | | | | | MLeft| Mdown| MUp |MRight| | |
|
|
* `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
|
|
* | | | | | | | | | | | |
|
|
* | | | | | | | | | | | |
|
|
* `----------------------------------' `----------------------------------'
|
|
*/
|
|
[_RAISE] = LAYOUT(
|
|
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \
|
|
_______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_VOLU, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, \
|
|
_______, _______, _______, _______, KC_MUTE, KC_VOLD, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, _______, _______, \
|
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
|
),
|
|
/*
|
|
* Adjust Layer
|
|
*
|
|
* ,-------------------------------------------. ,-------------------------------------------.
|
|
* | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | |
|
|
* |--------+------+------+------+------+------| |------+------+------+------+------+--------|
|
|
* | | | SAI | HUI | VAI | | | | | | F11 | F12 | |
|
|
* |--------+------+------+------+------+------+-------------. ,-------------+------+------+------+------+------+--------|
|
|
* | | | SAD | HUD | VAD | | | | | | | | | | | | |
|
|
* `----------------------+------+------+------+------+------| |------+------+------+------+------+----------------------'
|
|
* | | | | | | | | | | | |
|
|
* | | | | | | | | | | | |
|
|
* `----------------------------------' `----------------------------------'
|
|
*/
|
|
[_ADJUST] = LAYOUT(
|
|
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, \
|
|
_______, _______, RGB_SAI, RGB_HUI, RGB_VAI, _______, _______, _______, _______, KC_F11, KC_F12, _______, \
|
|
_______, _______, RGB_SAD, RGB_HUD, RGB_VAD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
|
),
|
|
};
|
|
|
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
switch (keycode) {
|
|
case LOWER:
|
|
if (record->event.pressed) {
|
|
layer_on(_LOWER);
|
|
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
|
} else {
|
|
layer_off(_LOWER);
|
|
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
|
}
|
|
return false;
|
|
break;
|
|
case RAISE:
|
|
if (record->event.pressed) {
|
|
layer_on(_RAISE);
|
|
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
|
} else {
|
|
layer_off(_RAISE);
|
|
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
|
}
|
|
return false;
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#ifdef OLED_DRIVER_ENABLE
|
|
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
|
return OLED_ROTATION_180;
|
|
}
|
|
|
|
static void render_kyria_logo(void) {
|
|
static const char PROGMEM kyria_logo[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0F, 0x0E, 0x1E, 0x1C, 0x3C, 0x38, 0x78, 0x70, 0x70, 0x70, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x70, 0x70, 0x70, 0x78, 0x38, 0x3C, 0x1C, 0x1E, 0x0E, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
oled_write_raw_P(kyria_logo, sizeof(kyria_logo));
|
|
}
|
|
|
|
static void render_qmk_logo(void) {
|
|
static const char PROGMEM qmk_logo[] = {
|
|
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
|
|
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
|
|
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
|
|
|
|
oled_write_P(qmk_logo, false);
|
|
}
|
|
|
|
static void render_status(void) {
|
|
// QMK Logo and version information
|
|
render_qmk_logo();
|
|
oled_write_P(PSTR("Kyria rev1.0\n\n"), false);
|
|
|
|
// Host Keyboard Layer Status
|
|
oled_write_P(PSTR("Layer: "), false);
|
|
switch (get_highest_layer(layer_state)) {
|
|
case _QWERTY:
|
|
oled_write_P(PSTR("Default\n"), false);
|
|
break;
|
|
case _LOWER:
|
|
oled_write_P(PSTR("Lower\n"), false);
|
|
break;
|
|
case _RAISE:
|
|
oled_write_P(PSTR("Raise\n"), false);
|
|
break;
|
|
case _ADJUST:
|
|
oled_write_P(PSTR("Adjust\n"), false);
|
|
break;
|
|
default:
|
|
oled_write_P(PSTR("Undefined\n"), false);
|
|
}
|
|
|
|
// Host Keyboard LED Status
|
|
uint8_t led_usb_state = host_keyboard_leds();
|
|
oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
|
|
oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
|
|
oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
|
|
}
|
|
|
|
void oled_task_user(void) {
|
|
if (is_keyboard_master()) {
|
|
render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
|
|
} else {
|
|
render_kyria_logo();
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifdef ENCODER_ENABLE
|
|
void encoder_update_user(uint8_t index, bool clockwise) {
|
|
if (index == 0) {
|
|
if (clockwise) {
|
|
tap_code(KC_VOLU);
|
|
} else {
|
|
tap_code(KC_VOLD);
|
|
}
|
|
}
|
|
else if (index == 1) {
|
|
if (clockwise) {
|
|
tap_code(KC_PGDN);
|
|
} else {
|
|
tap_code(KC_PGUP);
|
|
}
|
|
}
|
|
}
|
|
#endif |