forked from qmk/qmk_userspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
402 additions
and
70 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
keyboards/keychron/q0/base/keymaps/adophoxia/adophoxia.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
VIA_ENABLE = yes | ||
CONSOLE_ENABLE = yes |
Oops, something went wrong.