[TractylM] Overhaul configuration

This commit is contained in:
Drashna Jael're 2024-06-08 23:22:56 -07:00
parent c67f8b6bbd
commit 1bc6ded8d6
No known key found for this signature in database
GPG Key ID: DBA1FD3A860D1B11
12 changed files with 230 additions and 231 deletions

View File

@ -1,78 +0,0 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2015 Jack Humbert
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
// #define USB_VBUS_PIN B10 // doesn't seem to work for me on one of my controllers... */
#define SPLIT_HAND_PIN A13 // high = left, low = right
// WS2812 RGB LED strip input and number of LEDs
#define WS2812_PWM_DRIVER PWMD1 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 1 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
#define WS2812_EXTERNAL_PULLUP
#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
#define WS2812_PWM_DMA_STREAM STM32_DMA2_STREAM5 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_PWM_DMA_CHANNEL 6 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_PWM_TARGET_PERIOD 800000
#define DEBUG_LED_PIN C13
/* Audio config */
#define AUDIO_PIN A4
#define AUDIO_PIN_ALT A5
#define AUDIO_PIN_ALT_AS_NEGATIVE
/* serial.c configuration for split keyboard */
#define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode.
#define SERIAL_USART_TX_PIN A9
#define SERIAL_USART_RX_PIN A10
#define SERIAL_USART_DRIVER SD1
#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
#define SERIAL_USART_RX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100
#define SERIAL_USART_SPEED 921600
#define CRC8_USE_TABLE
#define CRC8_OPTIMIZE_SPEED
/* i2c config for oleds */
#define I2C_DRIVER I2CD1
#define I2C1_CLOCK_SPEED 400000
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_16_9
/* spi config for eeprom and pmw3360 sensor */
#define SPI_DRIVER SPID2
#define SPI_SCK_PIN B13
#define SPI_SCK_PAL_MODE 5
#define SPI_MOSI_PIN B14
#define SPI_MOSI_PAL_MODE 5
#define SPI_MISO_PIN B15
#define SPI_MISO_PAL_MODE 5
/* pmw3360 config */
#define PMW33XX_CS_PIN A4
// lcd
/*
RST C6
DC C7
CS B12
*/

View File

@ -0,0 +1,84 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2015 Jack Humbert
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
#define USB_VBUS_PIN B12
#define SPLIT_HAND_PIN A13 // high = left, low = right
#define USER_BUTTON_PIN C13
// #define DEBUG_LED_PIN B2
// WS2812 RGB LED strip input and number of LEDs
#define WS2812_PWM_DRIVER PWMD1
#define WS2812_PWM_CHANNEL 2
#define WS2812_PWM_PAL_MODE 1
#define WS2812_PWM_DMA_STREAM STM32_DMA2_STREAM5
#define WS2812_PWM_DMA_CHANNEL 6
#define WS2812_PWM_TARGET_PERIOD 800000
#define WS2812_PWM_COMPLEMENTARY_OUTPUT
#define WS2812_EXTERNAL_PULLUP
/* Audio config */
#define AUDIO_PIN A4
#define AUDIO_PIN_ALT A5
#define AUDIO_POWER_CONTROL_PIN B11
#define AUDIO_PIN_ALT_AS_NEGATIVE
/* serial.c configuration for split keyboard */
#define SERIAL_USART_DRIVER SD1
#define SERIAL_USART_TX_PIN A9
#define SERIAL_USART_TX_PAL_MODE 7
#define SERIAL_USART_RX_PIN A10
#define SERIAL_USART_RX_PAL_MODE 7
#define SERIAL_USART_TIMEOUT 10
#define SERIAL_USART_SPEED 921600
#define SERIAL_USART_FULL_DUPLEX
#define CRC8_USE_TABLE
#define CRC8_OPTIMIZE_SPEED
/* i2c config for oleds */
#define I2C_DRIVER I2CD1
#define I2C1_CLOCK_SPEED 400000
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_16_9
/* spi config for eeprom and pmw3360 sensor */
#define SPI_DRIVER SPID2
#define SPI_SCK_PIN B13
#define SPI_SCK_PAL_MODE 5
#define SPI_MOSI_PIN B14
#define SPI_MOSI_PAL_MODE 5
#define SPI_MISO_PIN B15
#define SPI_MISO_PAL_MODE 5
/* pmw3360 config */
#define POINTING_DEVICE_CS_PIN C6
// lcd
#define DISPLAY_RST_PIN C8
#define DISPLAY_DC_PIN C7
#define DISPLAY_CS_PIN C9
#if defined(OLED_ENABLE) && defined(OLED_TRANSPORT_SPI)
#define OLED_RST_PIN DISPLAY_RST_PIN
#define OLED_DC_PIN DISPLAY_DC_PIN
#define OLED_CS_PIN DISPLAY_CS_PIN
#define OLED_SPI_DIVISOR 4
#endif

View File

@ -16,42 +16,6 @@
#include "tractyl_manuform.h"
void keyboard_pre_init_sub(void) {
// gpio_set_pin_input_high(A0);
}
void matrix_scan_sub_kb(void) {
// if (!gpio_read_pin(A0)) {
// reset_keyboard();
// }
}
// __attribute__((weak)) void bootmagic_scan(void) {
// // We need multiple scans because debouncing can't be turned off.
// matrix_scan();
// #if defined(DEBOUNCE) && DEBOUNCE > 0
// wait_ms(DEBOUNCE * 2);
// #else
// wait_ms(30);
// #endif
// matrix_scan();
// uint8_t row = BOOTMAGIC_ROW;
// uint8_t col = BOOTMAGIC_COLUMN;
// #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT)
// if (!is_keyboard_left()) {
// row = BOOTMAGIC_ROW_RIGHT;
// col = BOOTMAGIC_COLUMN_RIGHT;
// }
// #endif
// if (matrix_get_row(row) & (1 << col) || !gpio_read_pin(A0)) {
// eeconfig_disable();
// bootloader_jump();
// }
// }
#ifdef USB_VBUS_PIN
bool usb_vbus_state(void) {
gpio_set_pin_input_low(USB_VBUS_PIN);
@ -65,3 +29,17 @@ void matrix_output_unselect_delay(uint8_t line, bool key_pressed) {
__asm__ volatile("nop" ::: "memory");
}
}
void user_button_init(void) {
// Pin needs to be configured as input low
#ifdef USER_BUTTON_PIN
gpio_set_pin_input_low(USER_BUTTON_PIN);
#endif // USER_BUTTON_PIN
}
bool check_user_button_state(void) {
#ifdef USER_BUTTON_PIN
return gpio_read_pin(USER_BUTTON_PIN);
#endif // USER_BUTTON_PIN
return false;
}

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define USB_VBUS_PIN B10 // doesn't seem to work for me on one of my controllers... */
#define SPLIT_HAND_PIN C14 // high = left, low = right
#define USER_BUTTON_PIN A0
// WS2812 RGB LED strip input and number of LEDs
#define WS2812_PWM_DRIVER PWMD2 // default: PWMD2

View File

@ -16,41 +16,6 @@
#include "tractyl_manuform.h"
void keyboard_pre_init_sub(void) { gpio_set_pin_input_high(A0); }
void matrix_scan_sub_kb(void) {
if (!gpio_read_pin(A0)) {
reset_keyboard();
}
}
__attribute__((weak)) void bootmagic_scan(void) {
// We need multiple scans because debouncing can't be turned off.
matrix_scan();
#if defined(DEBOUNCE) && DEBOUNCE > 0
wait_ms(DEBOUNCE * 2);
#else
wait_ms(30);
#endif
matrix_scan();
uint8_t row = BOOTMAGIC_ROW;
uint8_t col = BOOTMAGIC_COLUMN;
#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT)
if (!is_keyboard_left()) {
row = BOOTMAGIC_ROW_RIGHT;
col = BOOTMAGIC_COLUMN_RIGHT;
}
#endif
if (matrix_get_row(row) & (1 << col) || !gpio_read_pin(A0)) {
eeconfig_disable();
bootloader_jump();
}
}
#ifdef USB_VBUS_PIN
bool usb_vbus_state(void) {
gpio_set_pin_input_low(USB_VBUS_PIN);

View File

@ -15,48 +15,47 @@
*/
#include "tractyl_manuform.h"
#include "keyboard.h"
#include "pointing_device.h"
#include "quantum.h"
#include "transactions.h"
#include <string.h>
#ifdef CONSOLE_ENABLE
# include "print.h"
#endif // CONSOLE_ENABLE
#endif // CONSOLE_ENABLE
#ifdef POINTING_DEVICE_ENABLE
# ifndef CHARYBDIS_MINIMUM_DEFAULT_DPI
# define CHARYBDIS_MINIMUM_DEFAULT_DPI 400
# endif // CHARYBDIS_MINIMUM_DEFAULT_DPI
# endif // CHARYBDIS_MINIMUM_DEFAULT_DPI
# ifndef CHARYBDIS_DEFAULT_DPI_CONFIG_STEP
# define CHARYBDIS_DEFAULT_DPI_CONFIG_STEP 200
# endif // CHARYBDIS_DEFAULT_DPI_CONFIG_STEP
# endif // CHARYBDIS_DEFAULT_DPI_CONFIG_STEP
# ifndef CHARYBDIS_MINIMUM_SNIPING_DPI
# define CHARYBDIS_MINIMUM_SNIPING_DPI 200
# endif // CHARYBDIS_MINIMUM_SNIPER_MODE_DPI
# endif // CHARYBDIS_MINIMUM_SNIPER_MODE_DPI
# ifndef CHARYBDIS_SNIPING_DPI_CONFIG_STEP
# define CHARYBDIS_SNIPING_DPI_CONFIG_STEP 100
# endif // CHARYBDIS_SNIPING_DPI_CONFIG_STEP
# endif // CHARYBDIS_SNIPING_DPI_CONFIG_STEP
// Fixed DPI for drag-scroll.
# ifndef CHARYBDIS_DRAGSCROLL_DPI
# define CHARYBDIS_DRAGSCROLL_DPI 100
# endif // CHARYBDIS_DRAGSCROLL_DPI
# endif // CHARYBDIS_DRAGSCROLL_DPI
# ifndef CHARYBDIS_DRAGSCROLL_BUFFER_SIZE
# define CHARYBDIS_DRAGSCROLL_BUFFER_SIZE 6
# endif // !CHARYBDIS_DRAGSCROLL_BUFFER_SIZE
# ifndef CHARYBDIS_POINTER_ACCELERATION_FACTOR
# define CHARYBDIS_POINTER_ACCELERATION_FACTOR 24
# endif // !CHARYBDIS_POINTER_ACCELERATION_FACTOR
# endif // !CHARYBDIS_DRAGSCROLL_BUFFER_SIZE
typedef union {
uint8_t raw;
struct {
uint8_t pointer_default_dpi : 4; // 16 steps available.
uint8_t pointer_sniping_dpi : 2; // 4 steps available.
uint8_t pointer_default_dpi : 4; // 16 steps available.
uint8_t pointer_sniping_dpi : 2; // 4 steps available.
bool is_dragscroll_enabled : 1;
bool is_sniping_enabled : 1;
} __attribute__((packed));
@ -86,13 +85,19 @@ static void read_charybdis_config_from_eeprom(charybdis_config_t* config) {
* resets these 2 values to `false` since it does not make sense to persist
* these across reboots of the board.
*/
static void write_charybdis_config_to_eeprom(charybdis_config_t* config) { eeconfig_update_kb(config->raw); }
static void write_charybdis_config_to_eeprom(charybdis_config_t* config) {
eeconfig_update_kb(config->raw);
}
/** \brief Return the current value of the pointer's default DPI. */
static uint16_t get_pointer_default_dpi(charybdis_config_t* config) { return (uint16_t)config->pointer_default_dpi * CHARYBDIS_DEFAULT_DPI_CONFIG_STEP + CHARYBDIS_MINIMUM_DEFAULT_DPI; }
static uint16_t get_pointer_default_dpi(charybdis_config_t* config) {
return (uint16_t)config->pointer_default_dpi * CHARYBDIS_DEFAULT_DPI_CONFIG_STEP + CHARYBDIS_MINIMUM_DEFAULT_DPI;
}
/** \brief Return the current value of the pointer's sniper-mode DPI. */
static uint16_t get_pointer_sniping_dpi(charybdis_config_t* config) { return (uint16_t)config->pointer_sniping_dpi * CHARYBDIS_SNIPING_DPI_CONFIG_STEP + CHARYBDIS_MINIMUM_SNIPING_DPI; }
static uint16_t get_pointer_sniping_dpi(charybdis_config_t* config) {
return (uint16_t)config->pointer_sniping_dpi * CHARYBDIS_SNIPING_DPI_CONFIG_STEP + CHARYBDIS_MINIMUM_SNIPING_DPI;
}
/** \brief Set the appropriate DPI for the input config. */
static void maybe_update_pointing_device_cpi(charybdis_config_t* config) {
@ -127,64 +132,54 @@ static void step_pointer_sniping_dpi(charybdis_config_t* config, bool forward) {
maybe_update_pointing_device_cpi(config);
}
uint16_t charybdis_get_pointer_default_dpi(void) { return get_pointer_default_dpi(&g_charybdis_config); }
uint16_t charybdis_get_pointer_default_dpi(void) {
return get_pointer_default_dpi(&g_charybdis_config);
}
uint16_t charybdis_get_pointer_sniping_dpi(void) { return get_pointer_sniping_dpi(&g_charybdis_config); }
uint16_t charybdis_get_pointer_sniping_dpi(void) {
return get_pointer_sniping_dpi(&g_charybdis_config);
}
void charybdis_cycle_pointer_default_dpi_noeeprom(bool forward) { step_pointer_default_dpi(&g_charybdis_config, forward); }
void charybdis_cycle_pointer_default_dpi_noeeprom(bool forward) {
step_pointer_default_dpi(&g_charybdis_config, forward);
}
void charybdis_cycle_pointer_default_dpi(bool forward) {
step_pointer_default_dpi(&g_charybdis_config, forward);
write_charybdis_config_to_eeprom(&g_charybdis_config);
}
void charybdis_cycle_pointer_sniping_dpi_noeeprom(bool forward) { step_pointer_sniping_dpi(&g_charybdis_config, forward); }
void charybdis_cycle_pointer_sniping_dpi_noeeprom(bool forward) {
step_pointer_sniping_dpi(&g_charybdis_config, forward);
}
void charybdis_cycle_pointer_sniping_dpi(bool forward) {
step_pointer_sniping_dpi(&g_charybdis_config, forward);
write_charybdis_config_to_eeprom(&g_charybdis_config);
}
bool charybdis_get_pointer_sniping_enabled(void) { return g_charybdis_config.is_sniping_enabled; }
bool charybdis_get_pointer_sniping_enabled(void) {
return g_charybdis_config.is_sniping_enabled;
}
void charybdis_set_pointer_sniping_enabled(bool enable) {
g_charybdis_config.is_sniping_enabled = enable;
maybe_update_pointing_device_cpi(&g_charybdis_config);
}
bool charybdis_get_pointer_dragscroll_enabled(void) { return g_charybdis_config.is_dragscroll_enabled; }
bool charybdis_get_pointer_dragscroll_enabled(void) {
return g_charybdis_config.is_dragscroll_enabled;
}
void charybdis_set_pointer_dragscroll_enabled(bool enable) {
g_charybdis_config.is_dragscroll_enabled = enable;
maybe_update_pointing_device_cpi(&g_charybdis_config);
}
# ifndef CONSTRAIN_HID
# define CONSTRAIN_HID(value) ((value) < XY_REPORT_MIN ? XY_REPORT_MIN : ((value) > XY_REPORT_MAX ? XY_REPORT_MAX : (value)))
# endif // !CONSTRAIN_HID
/**
* \brief Add optional acceleration effect.
*
* If `CHARYBDIS_ENABLE_POINTER_ACCELERATION` is defined, add a simple and naive
* acceleration effect to the provided value. Return the value unchanged
* otherwise.
*/
# ifndef DISPLACEMENT_WITH_ACCELERATION
# ifdef CHARYBDIS_POINTER_ACCELERATION_ENABLE
# define DISPLACEMENT_WITH_ACCELERATION(d) (CONSTRAIN_HID(d > 0 ? d * d / CHARYBDIS_POINTER_ACCELERATION_FACTOR + d : -d * d / CHARYBDIS_POINTER_ACCELERATION_FACTOR + d))
# else // !CHARYBDIS_POINTER_ACCELERATION_ENABLE
# define DISPLACEMENT_WITH_ACCELERATION(d) (d)
# endif // CHARYBDIS_POINTER_ACCELERATION_ENABLE
# endif // !DISPLACEMENT_WITH_ACCELERATION
/**
* \brief Augment the pointing device behavior.
*
* Implement the Charybdis-specific features for pointing devices:
* - Drag-scroll
* - Sniping
* - Acceleration
* Implement drag-scroll.
*/
static void pointing_device_task_charybdis(report_mouse_t* mouse_report) {
static int16_t scroll_buffer_x = 0;
@ -194,12 +189,12 @@ static void pointing_device_task_charybdis(report_mouse_t* mouse_report) {
scroll_buffer_x -= mouse_report->x;
# else
scroll_buffer_x += mouse_report->x;
# endif // CHARYBDIS_DRAGSCROLL_REVERSE_X
# endif // CHARYBDIS_DRAGSCROLL_REVERSE_X
# ifdef CHARYBDIS_DRAGSCROLL_REVERSE_Y
scroll_buffer_y -= mouse_report->y;
# else
scroll_buffer_y += mouse_report->y;
# endif // CHARYBDIS_DRAGSCROLL_REVERSE_Y
# endif // CHARYBDIS_DRAGSCROLL_REVERSE_Y
mouse_report->x = 0;
mouse_report->y = 0;
if (abs(scroll_buffer_x) > CHARYBDIS_DRAGSCROLL_BUFFER_SIZE) {
@ -210,18 +205,20 @@ static void pointing_device_task_charybdis(report_mouse_t* mouse_report) {
mouse_report->v = scroll_buffer_y > 0 ? 1 : -1;
scroll_buffer_y = 0;
}
} else if (!g_charybdis_config.is_sniping_enabled) {
mouse_report->x = DISPLACEMENT_WITH_ACCELERATION(mouse_report->x);
mouse_report->y = DISPLACEMENT_WITH_ACCELERATION(mouse_report->y);
}
}
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
pointing_device_task_charybdis(&mouse_report);
mouse_report = pointing_device_task_user(mouse_report);
if (is_keyboard_master()) {
pointing_device_task_charybdis(&mouse_report);
mouse_report = pointing_device_task_user(mouse_report);
}
return mouse_report;
}
void pointing_device_init_kb(void) {
read_charybdis_config_from_eeprom(&g_charybdis_config);
pointing_device_init_user();
}
# if defined(POINTING_DEVICE_ENABLE) && !defined(NO_CHARYBDIS_KEYCODES)
/** \brief Whether SHIFT mod is enabled. */
@ -230,9 +227,9 @@ static bool has_shift_mod(void) {
return mod_config(get_mods()) & MOD_MASK_SHIFT;
# else
return mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;
# endif // NO_ACTION_ONESHOT
# endif // NO_ACTION_ONESHOT
}
# endif // POINTING_DEVICE_ENABLE && !NO_CHARYBDIS_KEYCODES
# endif // POINTING_DEVICE_ENABLE && !NO_CHARYBDIS_KEYCODES
/**
* \brief Outputs the Charybdis configuration to console.
@ -247,16 +244,16 @@ static bool has_shift_mod(void) {
*/
__attribute__((unused)) static void debug_charybdis_config_to_console(charybdis_config_t* config) {
# ifdef CONSOLE_ENABLE
IGNORE_FORMAT_WARNING(dprintf("(charybdis) process_record_kb: config = {\n"
"\traw = 0x%04X,\n"
"\t{\n"
"\t\tis_dragscroll_enabled=%b\n"
"\t\tis_sniping_enabled=%b\n"
"\t\tdefault_dpi=0x%02X (%ld)\n"
"\t\tsniping_dpi=0x%01X (%ld)\n"
"\t}\n"
"}\n",
config->raw, config->is_dragscroll_enabled, config->is_sniping_enabled, config->pointer_default_dpi, get_pointer_default_dpi(config), config->pointer_sniping_dpi, get_pointer_sniping_dpi(config)));
dprintf("(charybdis) process_record_kb: config = {\n"
"\traw = 0x%X,\n"
"\t{\n"
"\t\tis_dragscroll_enabled=%u\n"
"\t\tis_sniping_enabled=%u\n"
"\t\tdefault_dpi=0x%X (%u)\n"
"\t\tsniping_dpi=0x%X (%u)\n"
"\t}\n"
"}\n",
config->raw, config->is_dragscroll_enabled, config->is_sniping_enabled, config->pointer_default_dpi, get_pointer_default_dpi(config), config->pointer_sniping_dpi, get_pointer_sniping_dpi(config));
# endif // CONSOLE_ENABLE
}
@ -307,7 +304,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
}
break;
}
# endif // !NO_CHARYBDIS_KEYCODES
# endif // !NO_CHARYBDIS_KEYCODES
return true;
}
@ -318,22 +315,50 @@ void eeconfig_init_kb(void) {
eeconfig_init_user();
}
void matrix_power_up(void) { pointing_device_task(); }
void matrix_init_kb(void) {
read_charybdis_config_from_eeprom(&g_charybdis_config);
matrix_init_user();
}
void matrix_power_up(void) {
pointing_device_task();
}
void charybdis_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
if (initiator2target_buffer_size == sizeof(g_charybdis_config)) {
memcpy(&g_charybdis_config, initiator2target_buffer, sizeof(g_charybdis_config));
}
}
#endif // POINTING_DEVICE_ENABLE
__attribute__((weak)) void user_button_init(void) {
#ifdef USER_BUTTON_PIN
gpio_set_pin_input_high(USER_BUTTON_PIN);
#endif // USER_BUTTON_PIN
}
__attribute__((weak)) bool check_user_button_state(void) {
#ifdef USER_BUTTON_PIN
return !gpio_read_pin(USER_BUTTON_PIN);
#endif // USER_BUTTON_PIN
return false;
}
void keyboard_post_init_kb(void) {
user_button_init();
#ifdef POINTING_DEVICE_ENABLE
maybe_update_pointing_device_cpi(&g_charybdis_config);
transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, charybdis_config_sync_handler);
#endif // POINTING_DEVICE_ENABLE
keyboard_post_init_user();
}
void housekeeping_task_kb(void) {
if (check_user_button_state() && is_keyboard_master()) {
reset_keyboard();
}
#ifdef POINTING_DEVICE_ENABLE
if (is_keyboard_master()) {
// Keep track of the last state, so that we can tell if we need to propagate to slave
static charybdis_config_t last_charybdis_config = {0};
@ -357,22 +382,46 @@ void housekeeping_task_kb(void) {
}
}
}
// no need for user function, is called already
#endif // POINTING_DEVICE_ENABLE
// no need for user function, is called already
}
#endif // POINTING_DEVICE_ENABLE
#ifdef USER_BUTTON_PIN
__attribute__((weak)) void bootmagic_scan(void) {
// We need multiple scans because debouncing can't be turned off.
matrix_scan();
# if defined(DEBOUNCE) && DEBOUNCE > 0
wait_ms(DEBOUNCE * 2);
# else
wait_ms(30);
# endif
matrix_scan();
__attribute__((weak)) void matrix_init_sub_kb(void) {}
void matrix_init_kb(void) {
#ifdef POINTING_DEVICE_ENABLE
read_charybdis_config_from_eeprom(&g_charybdis_config);
#endif // POINTING_DEVICE_ENABLE
matrix_init_sub_kb();
matrix_init_user();
}
uint8_t row = BOOTMAGIC_ROW;
uint8_t col = BOOTMAGIC_COLUMN;
__attribute__((weak)) void matrix_scan_sub_kb(void) {}
void matrix_scan_kb(void) {
matrix_scan_sub_kb();
matrix_scan_user();
# if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_ROW_RIGHT) && defined(BOOTMAGIC_COLUMN_RIGHT)
if (!is_keyboard_left()) {
row = BOOTMAGIC_ROW_RIGHT;
col = BOOTMAGIC_COLUMN_RIGHT;
}
# endif
if (matrix_get_row(row) & (1 << col) || (is_keyboard_master() && check_user_button_state())) {
eeconfig_disable();
bootloader_jump();
}
}
#endif // USER_BUTTON_PIN
bool shutdown_kb(bool jump_to_bootloader) {
if (!shutdown_user(jump_to_bootloader)) {
return false;
}
#ifdef RGB_MATRIX_ENABLE
void rgb_matrix_update_pwm_buffers(void);
rgb_matrix_set_color_all(RGB_RED);
rgb_matrix_update_pwm_buffers();
#endif // RGB_MATRIX_ENABLE
return true;
}