94 lines
No EOL
3 KiB
C
94 lines
No EOL
3 KiB
C
// Copyright 2024 splitkb.com (support@splitkb.com)
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
#include "halcyon.h"
|
|
#include "transactions.h"
|
|
#include "print.h"
|
|
#include "split_util.h"
|
|
#include "pointing_device.h"
|
|
|
|
__attribute__((weak)) bool module_post_init_kb(void) {
|
|
return module_post_init_user();
|
|
}
|
|
__attribute__((weak)) bool module_housekeeping_task_kb(void) {
|
|
return module_housekeeping_task_user();
|
|
}
|
|
__attribute__((weak)) bool display_module_housekeeping_task_kb(bool second_display) {
|
|
return display_module_housekeeping_task_user(second_display);
|
|
}
|
|
|
|
__attribute__((weak)) bool module_post_init_user(void) {
|
|
return true;
|
|
}
|
|
__attribute__((weak)) bool module_housekeeping_task_user(void) {
|
|
return true;
|
|
}
|
|
__attribute__((weak)) bool display_module_housekeeping_task_user(bool second_display) {
|
|
return true;
|
|
}
|
|
|
|
module_t module;
|
|
#ifdef HLC_NONE
|
|
module_t module = hlc_none;
|
|
#endif
|
|
#ifdef HLC_CIRQUE_TRACKPAD
|
|
module_t module = hlc_cirque_trackpad;
|
|
#endif
|
|
#ifdef HLC_ENCODER
|
|
module_t module = hlc_encoder;
|
|
#endif
|
|
#ifdef HLC_TFT_DISPLAY
|
|
module_t module = hlc_tft_display;
|
|
#endif
|
|
|
|
void module_sync_slave_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
|
|
if (initiator2target_buffer_size == sizeof(module)) {
|
|
memcpy(&module_master, initiator2target_buffer, sizeof(module_master));
|
|
}
|
|
}
|
|
|
|
void keyboard_post_init_kb(void) {
|
|
// Register module sync split transaction
|
|
transaction_register_rpc(MODULE_SYNC, module_sync_slave_handler);
|
|
|
|
// Do any post init for modules
|
|
module_post_init_kb();
|
|
|
|
// User post init
|
|
keyboard_post_init_user();
|
|
}
|
|
|
|
void housekeeping_task_kb(void) {
|
|
if (is_keyboard_master()) {
|
|
static bool synced = 0;
|
|
if(is_transport_connected() && synced == 0) {
|
|
transaction_rpc_send(MODULE_SYNC, sizeof(module), &module); // Sync to slave
|
|
synced = 1;
|
|
}
|
|
display_module_housekeeping_task_kb(false); // Is master so can never be the second display
|
|
}
|
|
if (!is_keyboard_master()) {
|
|
if (module_master == hlc_tft_display) {
|
|
display_module_housekeeping_task_kb(true); // If there is a display on master, become the second display
|
|
} else {
|
|
display_module_housekeeping_task_kb(false); // Otherwise be the main display
|
|
}
|
|
}
|
|
module_housekeeping_task_kb();
|
|
|
|
housekeeping_task_user();
|
|
}
|
|
|
|
report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report) {
|
|
// Only runs on master
|
|
// Fixes the following bug: If master is right and master is NOT a cirque trackpad, the inputs would be inverted.
|
|
if(module != hlc_cirque_trackpad && !is_keyboard_left()) {
|
|
mouse_xy_report_t x = left_report.x;
|
|
mouse_xy_report_t y = left_report.y;
|
|
left_report.x = -x;
|
|
left_report.y = -y;
|
|
}
|
|
return pointing_device_task_combined_user(left_report, right_report);
|
|
} |