Merge remote-tracking branch 'origin/develop' into xap

This commit is contained in:
QMK Bot 2022-07-02 13:59:11 +00:00
commit 234f47b503
4 changed files with 75 additions and 6 deletions

View File

@ -18,6 +18,8 @@
*/
#include "charybdis.h"
#include "transactions.h"
#include <string.h>
#ifdef CONSOLE_ENABLE
# include "print.h"
@ -160,10 +162,8 @@ void charybdis_set_pointer_dragscroll_enabled(bool enable) {
maybe_update_pointing_device_cpi(&g_charybdis_config);
}
void pointing_device_init_kb(void) { maybe_update_pointing_device_cpi(&g_charybdis_config); }
# ifndef CONSTRAIN_HID
# define CONSTRAIN_HID(value) ((value) < -127 ? -127 : ((value) > 127 ? 127 : (value)))
# define CONSTRAIN_HID(value) ((value) < XY_REPORT_MIN ? XY_REPORT_MIN : ((value) > XY_REPORT_MAX ? XY_REPORT_MAX : (value)))
# endif // !CONSTRAIN_HID
/**
@ -340,4 +340,49 @@ void matrix_init_kb(void) {
read_charybdis_config_from_eeprom(&g_charybdis_config);
matrix_init_user();
}
# ifdef CHARYBDIS_CONFIG_SYNC
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
void keyboard_post_init_kb(void) {
maybe_update_pointing_device_cpi(&g_charybdis_config);
# ifdef CHARYBDIS_CONFIG_SYNC
transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, charybdis_config_sync_handler);
# endif
keyboard_post_init_user();
}
# ifdef CHARYBDIS_CONFIG_SYNC
void housekeeping_task_kb(void) {
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};
static uint32_t last_sync = 0;
bool needs_sync = false;
// Check if the state values are different
if (memcmp(&g_charybdis_config, &last_charybdis_config, sizeof(g_charybdis_config))) {
needs_sync = true;
memcpy(&last_charybdis_config, &g_charybdis_config, sizeof(g_charybdis_config));
}
// Send to slave every 500ms regardless of state change
if (timer_elapsed32(last_sync) > 500) {
needs_sync = true;
}
// Perform the sync if requested
if (needs_sync) {
if (transaction_rpc_send(RPC_ID_KB_CONFIG_SYNC, sizeof(g_charybdis_config), &g_charybdis_config)) {
last_sync = timer_read32();
}
}
}
// no need for user function, is called already
}
# endif // CHARYBDIS_CONFIG_SYNC
#endif // POINTING_DEVICE_ENABLE

View File

@ -20,6 +20,11 @@
#pragma once
// Enable syncing of charybdis config
#ifdef CHARYBDIS_CONFIG_SYNC
# define SPLIT_TRANSACTION_IDS_KB RPC_ID_KB_CONFIG_SYNC
#endif
/* Mouse config. */
#ifndef MOUSEKEY_MOVE_DELTA

View File

@ -176,3 +176,23 @@ To disable the custom keycodes, and reduce binary size, simply add a definition
```c
#define NO_CHARYBDIS_KEYCODES
```
### Configuration Syncing
If you want/need to enable syncing of the charybdis config, such as to read the sniping or drag scroll modes on the other half (such as for displaying the status via rgb matrix, or added on screens, or what not), you can enabled this. To do so, add this to your `config.h`:
```c
#define CHARYBDIS_CONFIG_SYNC
```
Note that you will need to reflash both sides when enabling this.
### Enable Large Mouse Reports
By default, the X and Y motion for the pointing device/mouse reports is -127 to 127. You can definitely hit the limit for that with the sensors. You can enable support for -32767 to 32767 by adding this to your `config.h`:
```c
#define MOUSE_EXTENDED_REPORT
```
Note that you will need to reflash both sides when enabling this.

View File

@ -159,10 +159,8 @@ void charybdis_set_pointer_dragscroll_enabled(bool enable) {
maybe_update_pointing_device_cpi(&g_charybdis_config);
}
void pointing_device_init_kb(void) { maybe_update_pointing_device_cpi(&g_charybdis_config); }
# ifndef CONSTRAIN_HID
# define CONSTRAIN_HID(value) ((value) < -127 ? -127 : ((value) > 127 ? 127 : (value)))
# define CONSTRAIN_HID(value) ((value) < XY_REPORT_MIN ? XY_REPORT_MIN : ((value) > XY_REPORT_MAX ? XY_REPORT_MAX : (value)))
# endif // !CONSTRAIN_HID
/**
@ -339,6 +337,7 @@ void charybdis_config_sync_handler(uint8_t initiator2target_buffer_size, const v
}
void keyboard_post_init_kb(void) {
maybe_update_pointing_device_cpi(&g_charybdis_config);
transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, charybdis_config_sync_handler);
keyboard_post_init_user();