Remove *_CALLBACK_ENABLE related code; Fix V2 Max device name

This commit is contained in:
lokher 2024-02-01 09:56:04 +08:00
parent 0b812c9dc0
commit f9f4cf410f
21 changed files with 67 additions and 435 deletions

View file

@ -296,14 +296,6 @@ bool factory_test_task(void) {
return true;
}
#ifdef KEYCHRON_CALLBACK_ENABLE
void factory_test_init(void) {
register_keychron_task(factory_test_task, false);
register_record_process(process_record_factory_test, false);
register_led_indicator_task(factory_test_indicator, false);
}
#endif
void factory_test_send(uint8_t *payload, uint8_t length) {
#ifdef RAW_ENABLE
uint16_t checksum = 0;

View file

@ -22,139 +22,18 @@
# include "factory_test.h"
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
typedef struct lk_node {
keychron_cb lk_cb;
struct lk_node *next;
} lk_Node;
typedef struct lk_process_node {
keychron_record_process_cb process_cb;
struct lk_process_node *next;
} lk_process_Node;
lk_Node *p;
lk_Node *lk_task_list = NULL;
lk_process_Node *p_process;
lk_process_Node *lk_record_process_list = NULL;
# if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)
lk_Node *led_indicator_task_list = NULL;
# endif
void register_keychron_cb(lk_Node **head, keychron_cb cb, bool priority) {
/* Create task node */
lk_Node *task = (lk_Node *)malloc(sizeof(lk_Node));
task->lk_cb = cb;
task->next = NULL;
/* Add to the list*/
if (*head) {
if (priority) {
task->next = *head;
*head = task;
} else {
p = *head;
while (p->next)
p = p->next;
p->next = task;
}
} else {
*head = task;
}
}
void deregister_keychron_cb(lk_Node **head, keychron_cb cb) {
p = *head;
while (p) {
if (p->lk_cb == cb) {
// lk_Node* temp = p;
// if
}
}
}
void register_keychron_task(keychron_cb cb, bool priority) {
register_keychron_cb(&lk_task_list, cb, priority);
}
void register_led_indicator_task(keychron_cb cb, bool priority) {
register_keychron_cb(&led_indicator_task_list, cb, priority);
}
void register_record_process(keychron_record_process_cb cb, bool priority) {
lk_process_Node *process = (lk_process_Node *)malloc(sizeof(lk_process_Node));
process->process_cb = cb;
process->next = NULL;
/* Add to the list*/
if (lk_record_process_list) {
if (priority) {
process->next = lk_record_process_list;
lk_record_process_list = process;
} else {
p_process = lk_record_process_list;
while (p_process->next)
p_process = p_process->next;
p_process->next = process;
}
} else {
lk_record_process_list = process;
}
}
inline void keychron_task(void) {
p = lk_task_list;
while (p) {
p->lk_cb();
p = p->next;
}
}
inline bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
p_process = lk_record_process_list;
while (p_process) {
if (!p_process->process_cb(keycode, record)) {
return false;
}
p_process = p_process->next;
}
return true;
}
# if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)
# if defined(LED_MATRIX_ENABLE)
inline bool led_matrix_indicators_keychron(void) {
# else
inline bool rgb_matrix_indicators_keychron(void) {
# endif
p = led_indicator_task_list;
while (p) {
p->lk_cb();
p = p->next;
}
return true;
}
# endif
#else
__attribute__((weak)) bool process_record_keychron_kb(uint16_t keycode, keyrecord_t *record) {
return true;
}
bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
# ifdef LK_WIRELESS_ENABLE
#ifdef LK_WIRELESS_ENABLE
extern bool process_record_wireless(uint16_t keycode, keyrecord_t * record);
if (!process_record_wireless(keycode, record)) return false;
# endif
# ifdef FACTORY_TEST_ENABLE
#endif
#ifdef FACTORY_TEST_ENABLE
if (!process_record_factory_test(keycode, record)) return false;
# endif
#endif
// extern bool process_record_keychron_kb(uint16_t keycode, keyrecord_t *record);
if (!process_record_keychron_kb(keycode, record)) return false;
@ -162,49 +41,48 @@ bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
return true;
}
# if defined(LED_MATRIX_ENABLE)
#if defined(LED_MATRIX_ENABLE)
bool led_matrix_indicators_keychron(void) {
# ifdef LK_WIRELESS_ENABLE
# ifdef LK_WIRELESS_ENABLE
extern bool led_matrix_indicators_bt(void);
led_matrix_indicators_bt();
# endif
# ifdef FACTORY_TEST_ENABLE
# endif
# ifdef FACTORY_TEST_ENABLE
factory_test_indicator();
# endif
# endif
return true;
}
# endif
#endif
# if defined(RGB_MATRIX_ENABLE)
#if defined(RGB_MATRIX_ENABLE)
bool rgb_matrix_indicators_keychron(void) {
# ifdef LK_WIRELESS_ENABLE
# ifdef LK_WIRELESS_ENABLE
extern bool rgb_matrix_indicators_bt(void);
rgb_matrix_indicators_bt();
# endif
# ifdef FACTORY_TEST_ENABLE
# endif
# ifdef FACTORY_TEST_ENABLE
factory_test_indicator();
# endif
# endif
return true;
}
# endif
#endif
__attribute__((weak)) bool keychron_task_kb(void) {
return true;
}
void keychron_task(void) {
# ifdef LK_WIRELESS_ENABLE
#ifdef LK_WIRELESS_ENABLE
extern void wireless_tasks(void);
wireless_tasks();
# endif
# ifdef FACTORY_TEST_ENABLE
#endif
#ifdef FACTORY_TEST_ENABLE
factory_test_task();
# endif
#endif
keychron_common_task();
keychron_task_kb();
}
#endif // #ifdef KEYCHRON_CALLBACK_ENABLE
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) return false;

View file

@ -13,29 +13,13 @@
* 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 "stdint.h"
#include "action.h"
#ifdef KEYCHRON_CALLBACK_ENABLE
typedef bool (*keychron_cb)(void);
typedef bool (*keychron_record_process_cb)(uint16_t keycode, keyrecord_t *record);
bool process_record_keychron(uint16_t keycode, keyrecord_t *record);
void register_keychron_task(keychron_cb cb, bool priority);
void register_record_process(keychron_record_process_cb cb, bool priority);
#if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)
void register_led_indicator_task(keychron_cb cb, bool priority);
#endif
#else
bool keychron_task_kb(void);
bool process_record_keychron_kb(uint16_t keycode, keyrecord_t *record);
#endif
void keychron_task(void);

View file

@ -180,9 +180,6 @@ void indicator_init(void) {
setPinOutput(BAT_LOW_LED_PIN);
writePin(BAT_LOW_LED_PIN, !BAT_LOW_LED_PIN_ON_STATE);
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
register_led_indicator_task(LED_INDICATORS_KB, false);
#endif
}
#if defined(LED_MATRIX_ENABLE) || defined(RGB_MATRIX_ENABLE)

View file

@ -59,10 +59,6 @@ void report_buffer_init(void) {
report_buffer_queue_tail = 0;
retry = 0;
report_timer_buffer = timer_read32();
#ifdef KEYCHRON_CALLBACK_ENABLE
register_keychron_task(report_buffer_task, true);
#endif
}
bool report_buffer_enqueue(report_buffer_t *report) {

View file

@ -113,10 +113,6 @@ void wireless_init(void) {
nkro.bluetooth = keymap_config.nkro;
# endif
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
register_wt_tasks();
register_record_process(process_record_wireless, false);
#endif
}
/*

View file

@ -34,9 +34,3 @@ bool wireless_tasks(void) {
if (get_transport() == TRANSPORT_USB) usb_remote_wakeup();
return true;
}
#ifdef KEYCHRON_CALLBACK_ENABLE
void register_wt_tasks(void) {
register_keychron_task(wireless_tasks, true);
}
#endif

View file

@ -27,10 +27,6 @@
# include "battery.h"
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
bool keychron_task_kb(void);
#endif
#ifdef DIP_SWITCH_ENABLE
bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
@ -55,11 +51,6 @@ void keyboard_post_init_kb(void) {
encoder_cb_init();
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
factory_test_init();
register_record_process(process_record_keychron_kb, false);
register_keychron_task(keychron_task_kb, false);
#endif
keyboard_post_init_user();
}

View file

@ -27,10 +27,6 @@
# include "battery.h"
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
bool keychron_task_kb(void);
#endif
#ifdef DIP_SWITCH_ENABLE
bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
@ -55,11 +51,6 @@ void keyboard_post_init_kb(void) {
encoder_cb_init();
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
factory_test_init();
register_record_process(process_record_keychron_kb, false);
register_keychron_task(keychron_task_kb, false);
#endif
keyboard_post_init_user();
}

View file

@ -27,10 +27,6 @@
# include "battery.h"
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
bool keychron_task_kb(void);
#endif
#ifdef DIP_SWITCH_ENABLE
bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
@ -55,11 +51,6 @@ void keyboard_post_init_kb(void) {
encoder_cb_init();
#endif
#ifdef KEYCHRON_CALLBACK_ENABLE
factory_test_init();
register_record_process(process_record_keychron_kb, false);
register_keychron_task(keychron_task_kb, false);
#endif
keyboard_post_init_user();
}

View file

@ -1,5 +1,5 @@
{
"keyboard_name": "Keychron Q2 Max",
"keyboard_name": "Keychron V2 Max",
"manufacturer": "Keychron",
"url": "https://github.com/Keychron",
"maintainer": "lokher",

View file

@ -68,7 +68,6 @@ bool keychron_task_kb(void) {
#ifdef LK_WIRELESS_ENABLE
writePin(BAT_LOW_LED_PIN, !BAT_LOW_LED_PIN_ON_STATE);
#endif
} else {
#ifdef LK_WIRELESS_ENABLE
writePin(BAT_LOW_LED_PIN, BAT_LOW_LED_PIN_ON_STATE);