Skip to content

Commit

Permalink
Le rework
Browse files Browse the repository at this point in the history
  • Loading branch information
adophoxia committed Jan 14, 2024
1 parent c06ac5d commit 0780b59
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 70 deletions.
143 changes: 143 additions & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/adophoxia.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/* Copyright 2023 @Adophoxia
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
#include "adophoxia.h"

void keyboard_post_init_user(void) {
// Customise these values to desired behaviour
debug_enable=true;
debug_matrix=true;
//debug_keyboard=true;
//debug_mouse=true;
}

bool shutdown_user(bool jump_to_bootloader) {
if (jump_to_bootloader) {
// turn off LEDs for bootloader
rgb_matrix_set_color_all(RGB_OFF);
}
void rgb_matrix_update_pwm_buffers(void);
// force flushing -- otherwise will never happen
rgb_matrix_update_pwm_buffers();
// false to not process kb level
return false;
}

bool is_base_active = true;
#define BASE_LAYER _BASE
uint16_t base_layer_timer = 0;

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _BASE:

break;
case _FN1 && _FN2
if (current_layer > _BASE) {
is_base_active = false;
}
break;
default:
// Reset back to the current profile
ap2_led_reset_foreground_color();
break;
}
return state;
}





bool is_base_active = false;
#define LAYER_BASE 0
uint16_t base_layer_timer = 0;

uint8_t current_layer = get_highest_layer(layer_state);

if (current_layer > LAYER_BASE) {
return false;
}






























#### Super ALT↯TAB

This macro will register `KC_LALT` and tap `KC_TAB`, then wait for 1000ms. If the key is tapped again, it will send another `KC_TAB`; if there is no tap, `KC_LALT` will be unregistered, thus allowing you to cycle through windows.

```c
bool is_alt_tab_active = false; // ADD this near the beginning of keymap.c
uint16_t alt_tab_timer = 0; // we will be using them soon.

enum custom_keycodes { // Make sure have the awesome keycode ready
ALT_TAB = SAFE_RANGE,
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { // This will do most of the grunt work with the keycodes.
case ALT_TAB:
if (record->event.pressed) {
if (!is_alt_tab_active) {
is_alt_tab_active = true;
register_code(KC_LALT);
}
alt_tab_timer = timer_read();
register_code(KC_TAB);
} else {
unregister_code(KC_TAB);
}
break;
}
return true;
}

void matrix_scan_user(void) { // The very important timer.
if (is_alt_tab_active) {
if (timer_elapsed(alt_tab_timer) > 1000) {
unregister_code(KC_LALT);
is_alt_tab_active = false;
}
}
}
```
19 changes: 19 additions & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/adophoxia.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright 2023 @Adophoxia
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/>.
*/

#pragma once

enum layers { _BASE, _FN1, _FN2};
24 changes: 24 additions & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Copyright 2023 @Adophoxia
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/>.
*/

#pragma once

#ifdef RGB_MATRIX_ENABLE
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_BREATHING
#define RGB_MATRIX_DEFAULT_HUE 160
#endif

#define DEBUG_MATRIX_SCAN_RATE
88 changes: 88 additions & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/indicators.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* Copyright 2023 @Adophoxia
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/>.
*/

#pragma once
#include "indicators.h"
#include "lib/lib8tion/lib8tion.h"

#define ARRAYSIZE(arr) sizeof(arr)/sizeof(arr[0])

uint8_t numlock_arrows[] = {
9, 11, 13, 16
};

uint8_t fn_keys[] = {
4, 5, 6,
8, 9, 10,
11, 12, 13,
15, 16, 17
};

uint8_t fn2_modifiers_keys[] = {
1, 2, 3
};

/*
{ 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 8, 9, 10, 14 },
{ 11, 12, 13, __ },
{ 15, 16, 17, 20 },
{ 18, __, 19, __ }
*/

void numlock_arrows_indicators() {
if (!host_keyboard_led_state().num_lock) {
for (uint8_t i = 0; i < ARRAYSIZE(numlock_arrows); i++) {
rgb_matrix_set_color(numlock_arrows[i], RGB_BLUE);
}
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, RGB_WHITE);
} else {
if (!rgb_matrix_get_flags()) {
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, RGB_BLACK);
}
}
}

void fn_keys_indicators() {
for (uint8_t i = 0; i < ARRAYSIZE(fn_keys); i++) {
rgb_matrix_set_color(fn_keys[i], RGB_PURPLE);
}
}

void fn2_modifiers() {
for (uint8_t i = 0; i < ARRAYSIZE(fn2_modifiers_keys); i++) {
rgb_matrix_set_color(fn2_modifiers_keys[i], RGB_PINK);
}
}

bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
switch (get_highest_layer(layer_state)) {
case _BASE:
numlock_arrows_indicators();
rgb_matrix_set_color(0, RGB_RED);
break;
case _FN1:
fn_keys_indicators();
fn2_modifiers();
rgb_matrix_set_color(0, RGB_GREEN);
break;
case _FN2:
rgb_matrix_set_color(0, RGB_BLUE);
break;
}
return false;
}
21 changes: 21 additions & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/indicators.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2023 @Adophoxia
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/>.
*/

#pragma once

void numlock_arrows_indicators(void);
void fn_keys_indicators(void);
void fn2_modifiers(void);
51 changes: 13 additions & 38 deletions keyboards/keychron/q0/base/keymaps/adophoxia/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

#include QMK_KEYBOARD_H

enum layers { _BASE, _FN1};
#include "adophoxia.c"
#include "indicators.c"

/*
* ┌───┬───┬───┬───┐
Expand Down Expand Up @@ -45,45 +45,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),

[_FN1] = LAYOUT_numpad_6x4(
TG(_FN1), KC_MUTE, KC_VOLD, KC_VOLU,
TG(_FN2), KC_LCTL, KC_LGUI, KC_LALT,
KC_F10, KC_F11, KC_F12, _______,
KC_F7, KC_F8, KC_F9,
KC_F4, KC_F5, KC_F6, _______,
KC_F1, KC_F2, KC_F3,
_______, _______, _______
),

[_FN2] = LAYOUT_numpad_6x4(
TO(_BASE), KC_MUTE, KC_VOLD, KC_VOLU,
RGB_MOD, RGB_VAI, RGB_HUI, KC_DEL,
RGB_RMOD, RGB_VAD, RGB_HUD,
RGB_SAI, RGB_SPI, KC_MPRV, _______,
RGB_SAD, RGB_SPD, KC_MPLY,
RGB_TOG, KC_MNXT, _______
)
};

#define ARRAYSIZE(arr) sizeof(arr)/sizeof(arr[0])

uint8_t numlock_arrows[] = {
9, 11, 13, 16
};

void numlock_arrows_indicators(void);

void numlock_arrows_indicators() {
if (!host_keyboard_led_state().num_lock) {
for (uint8_t i = 0; i < ARRAYSIZE(numlock_arrows); i++) {
rgb_matrix_set_color(numlock_arrows[i], RGB_BLUE);
}
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, RGB_WHITE);
} else {
if (!rgb_matrix_get_flags()) {
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, RGB_BLACK);
}
}
}

bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
switch (get_highest_layer(layer_state)) {
case _BASE:
numlock_arrows_indicators();
rgb_matrix_set_color(0, RGB_RED);
break;
case _FN1:
rgb_matrix_set_color(0, RGB_YELLOW);
break;
}
return false;
}
};
1 change: 1 addition & 0 deletions keyboards/keychron/q0/base/keymaps/adophoxia/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VIA_ENABLE = yes
CONSOLE_ENABLE = yes
Loading

0 comments on commit 0780b59

Please sign in to comment.