Community modules (#24848)
This commit is contained in:
parent
63b095212b
commit
1efc82403b
37 changed files with 987 additions and 84 deletions
|
@ -45,7 +45,7 @@ typedef struct {
|
|||
} tap_t;
|
||||
|
||||
/* Key event container for recording */
|
||||
typedef struct {
|
||||
typedef struct keyrecord_t {
|
||||
keyevent_t event;
|
||||
#ifndef NO_ACTION_TAPPING
|
||||
tap_t tap;
|
||||
|
|
|
@ -289,6 +289,21 @@ __attribute__((weak)) void keyboard_pre_init_kb(void) {
|
|||
keyboard_pre_init_user();
|
||||
}
|
||||
|
||||
/** \brief keyboard_pre_init_modules
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__((weak)) void keyboard_pre_init_modules(void) {}
|
||||
|
||||
/** \brief keyboard_pre_init_quantum
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void keyboard_pre_init_quantum(void) {
|
||||
keyboard_pre_init_modules();
|
||||
keyboard_pre_init_kb();
|
||||
}
|
||||
|
||||
/** \brief keyboard_post_init_user
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
@ -305,6 +320,23 @@ __attribute__((weak)) void keyboard_post_init_kb(void) {
|
|||
keyboard_post_init_user();
|
||||
}
|
||||
|
||||
/** \brief keyboard_post_init_modules
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
|
||||
__attribute__((weak)) void keyboard_post_init_modules(void) {}
|
||||
|
||||
/** \brief keyboard_post_init_quantum
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
|
||||
void keyboard_post_init_quantum(void) {
|
||||
keyboard_post_init_modules();
|
||||
keyboard_post_init_kb();
|
||||
}
|
||||
|
||||
/** \brief matrix_can_read
|
||||
*
|
||||
* Allows overriding when matrix scanning operations should be executed.
|
||||
|
@ -323,7 +355,7 @@ void keyboard_setup(void) {
|
|||
eeprom_driver_init();
|
||||
#endif
|
||||
matrix_setup();
|
||||
keyboard_pre_init_kb();
|
||||
keyboard_pre_init_quantum();
|
||||
}
|
||||
|
||||
#ifndef SPLIT_KEYBOARD
|
||||
|
@ -355,6 +387,13 @@ __attribute__((weak)) bool should_process_keypress(void) {
|
|||
return is_keyboard_master();
|
||||
}
|
||||
|
||||
/** \brief housekeeping_task_modules
|
||||
*
|
||||
* Codegen will override this if community modules are enabled.
|
||||
* This is specific to keyboard-level functionality.
|
||||
*/
|
||||
__attribute__((weak)) void housekeeping_task_modules(void) {}
|
||||
|
||||
/** \brief housekeeping_task_kb
|
||||
*
|
||||
* Override this function if you have a need to execute code for every keyboard main loop iteration.
|
||||
|
@ -374,6 +413,7 @@ __attribute__((weak)) void housekeeping_task_user(void) {}
|
|||
* Invokes hooks for executing code after QMK is done after each loop iteration.
|
||||
*/
|
||||
void housekeeping_task(void) {
|
||||
housekeeping_task_modules();
|
||||
housekeeping_task_kb();
|
||||
housekeeping_task_user();
|
||||
}
|
||||
|
@ -493,7 +533,7 @@ void keyboard_init(void) {
|
|||
debug_enable = true;
|
||||
#endif
|
||||
|
||||
keyboard_post_init_kb(); /* Always keep this last */
|
||||
keyboard_post_init_quantum(); /* Always keep this last */
|
||||
}
|
||||
|
||||
/** \brief key_event_task
|
||||
|
|
|
@ -76,6 +76,8 @@ enum qk_keycode_ranges {
|
|||
QK_MACRO_MAX = 0x777F,
|
||||
QK_CONNECTION = 0x7780,
|
||||
QK_CONNECTION_MAX = 0x77BF,
|
||||
QK_COMMUNITY_MODULE = 0x77C0,
|
||||
QK_COMMUNITY_MODULE_MAX = 0x77FF,
|
||||
QK_LIGHTING = 0x7800,
|
||||
QK_LIGHTING_MAX = 0x78FF,
|
||||
QK_QUANTUM = 0x7C00,
|
||||
|
@ -1476,6 +1478,7 @@ enum qk_keycode_defines {
|
|||
#define IS_QK_STENO(code) ((code) >= QK_STENO && (code) <= QK_STENO_MAX)
|
||||
#define IS_QK_MACRO(code) ((code) >= QK_MACRO && (code) <= QK_MACRO_MAX)
|
||||
#define IS_QK_CONNECTION(code) ((code) >= QK_CONNECTION && (code) <= QK_CONNECTION_MAX)
|
||||
#define IS_QK_COMMUNITY_MODULE(code) ((code) >= QK_COMMUNITY_MODULE && (code) <= QK_COMMUNITY_MODULE_MAX)
|
||||
#define IS_QK_LIGHTING(code) ((code) >= QK_LIGHTING && (code) <= QK_LIGHTING_MAX)
|
||||
#define IS_QK_QUANTUM(code) ((code) >= QK_QUANTUM && (code) <= QK_QUANTUM_MAX)
|
||||
#define IS_QK_KB(code) ((code) >= QK_KB && (code) <= QK_KB_MAX)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Copyright 2022 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#if defined(COMMUNITY_MODULES_ENABLE)
|
||||
# include "community_modules_introspection.h"
|
||||
#endif // defined(COMMUNITY_MODULES_ENABLE)
|
||||
|
||||
// Pull the actual keymap code so that we can inspect stuff from it
|
||||
#include KEYMAP_C
|
||||
|
||||
|
@ -171,3 +175,10 @@ __attribute__((weak)) const key_override_t* key_override_get(uint16_t key_overri
|
|||
}
|
||||
|
||||
#endif // defined(KEY_OVERRIDE_ENABLE)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Community modules (must be last in this file!)
|
||||
|
||||
#if defined(COMMUNITY_MODULES_ENABLE)
|
||||
# include "community_modules_introspection.c"
|
||||
#endif // defined(COMMUNITY_MODULES_ENABLE)
|
||||
|
|
|
@ -72,6 +72,8 @@ static volatile struct usb_device_state maxprev_usb_device_state = {.configure_s
|
|||
static volatile bool debouncing = false;
|
||||
static volatile fast_timer_t last_time = 0;
|
||||
|
||||
bool process_detected_host_os_modules(os_variant_t os);
|
||||
|
||||
void os_detection_task(void) {
|
||||
#ifdef OS_DETECTION_KEYBOARD_RESET
|
||||
// resetting the keyboard on the USB device state change callback results in instability, so delegate that to this task
|
||||
|
@ -96,12 +98,17 @@ void os_detection_task(void) {
|
|||
if (detected_os != reported_os || first_report) {
|
||||
first_report = false;
|
||||
reported_os = detected_os;
|
||||
process_detected_host_os_modules(detected_os);
|
||||
process_detected_host_os_kb(detected_os);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool process_detected_host_os_modules(os_variant_t os) {
|
||||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool process_detected_host_os_kb(os_variant_t detected_os) {
|
||||
return process_detected_host_os_user(detected_os);
|
||||
}
|
||||
|
|
|
@ -162,6 +162,10 @@ __attribute__((weak)) void tap_code16(uint16_t code) {
|
|||
tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool pre_process_record_modules(uint16_t keycode, keyrecord_t *record) {
|
||||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
return pre_process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -174,6 +178,10 @@ __attribute__((weak)) bool process_action_kb(keyrecord_t *record) {
|
|||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool process_record_modules(uint16_t keycode, keyrecord_t *record) {
|
||||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
@ -182,12 +190,22 @@ __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *re
|
|||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) void post_process_record_modules(uint16_t keycode, keyrecord_t *record) {}
|
||||
|
||||
__attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
post_process_record_user(keycode, record);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
|
||||
|
||||
__attribute__((weak)) bool shutdown_modules(bool jump_to_bootloader) {
|
||||
return true;
|
||||
}
|
||||
|
||||
__attribute__((weak)) void suspend_power_down_modules(void) {}
|
||||
|
||||
__attribute__((weak)) void suspend_wakeup_init_modules(void) {}
|
||||
|
||||
void shutdown_quantum(bool jump_to_bootloader) {
|
||||
clear_keyboard();
|
||||
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
|
||||
|
@ -199,11 +217,13 @@ void shutdown_quantum(bool jump_to_bootloader) {
|
|||
# endif
|
||||
uint16_t timer_start = timer_read();
|
||||
PLAY_SONG(goodbye_song);
|
||||
shutdown_modules(jump_to_bootloader);
|
||||
shutdown_kb(jump_to_bootloader);
|
||||
while (timer_elapsed(timer_start) < 250)
|
||||
wait_ms(1);
|
||||
stop_all_notes();
|
||||
#else
|
||||
shutdown_modules(jump_to_bootloader);
|
||||
shutdown_kb(jump_to_bootloader);
|
||||
wait_ms(250);
|
||||
#endif
|
||||
|
@ -258,7 +278,7 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
|
|||
|
||||
/* Get keycode, and then process pre tapping functionality */
|
||||
bool pre_process_record_quantum(keyrecord_t *record) {
|
||||
return pre_process_record_kb(get_record_keycode(record, true), record) &&
|
||||
return pre_process_record_modules(get_record_keycode(record, true), record) && pre_process_record_kb(get_record_keycode(record, true), record) &&
|
||||
#ifdef COMBO_ENABLE
|
||||
process_combo(get_record_keycode(record, true), record) &&
|
||||
#endif
|
||||
|
@ -268,6 +288,7 @@ bool pre_process_record_quantum(keyrecord_t *record) {
|
|||
/* Get keycode, and then call keyboard function */
|
||||
void post_process_record_quantum(keyrecord_t *record) {
|
||||
uint16_t keycode = get_record_keycode(record, false);
|
||||
post_process_record_modules(keycode, record);
|
||||
post_process_record_kb(keycode, record);
|
||||
}
|
||||
|
||||
|
@ -332,6 +353,7 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||
#if defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
|
||||
process_auto_mouse(keycode, record) &&
|
||||
#endif
|
||||
process_record_modules(keycode, record) && // modules must run before kb
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(VIA_ENABLE)
|
||||
process_record_via(keycode, record) &&
|
||||
|
@ -526,6 +548,7 @@ __attribute__((weak)) bool shutdown_kb(bool jump_to_bootloader) {
|
|||
}
|
||||
|
||||
void suspend_power_down_quantum(void) {
|
||||
suspend_power_down_modules();
|
||||
suspend_power_down_kb();
|
||||
#ifndef NO_SUSPEND_POWER_DOWN
|
||||
// Turn off backlight
|
||||
|
@ -593,6 +616,7 @@ __attribute__((weak)) void suspend_wakeup_init_quantum(void) {
|
|||
#if defined(RGB_MATRIX_ENABLE)
|
||||
rgb_matrix_set_suspend_state(false);
|
||||
#endif
|
||||
suspend_wakeup_init_modules();
|
||||
suspend_wakeup_init_kb();
|
||||
}
|
||||
|
||||
|
|
|
@ -244,6 +244,10 @@ extern layer_state_t layer_state;
|
|||
# include "layer_lock.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMMUNITY_MODULES_ENABLE
|
||||
# include "community_modules.h"
|
||||
#endif
|
||||
|
||||
void set_single_default_layer(uint8_t default_layer);
|
||||
void set_single_persistent_default_layer(uint8_t default_layer);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue