Browse Source

Add charybdis config syncing

fix typo

Fix compilation issue
pull/17435/head
Drashna Jael're 1 year ago
parent
commit
a3070ca77e
No known key found for this signature in database GPG Key ID: DBA1FD3A860D1B11
3 changed files with 67 additions and 0 deletions
  1. +42
    -0
      keyboards/bastardkb/charybdis/charybdis.c
  2. +5
    -0
      keyboards/bastardkb/charybdis/post_config.h
  3. +20
    -0
      keyboards/bastardkb/charybdis/readme.md

+ 42
- 0
keyboards/bastardkb/charybdis/charybdis.c View File

@ -18,6 +18,8 @@
*/
#include "charybdis.h"
#include "transactions.h"
#include <string.h>
#ifdef CONSOLE_ENABLE
# include "print.h"
@ -339,8 +341,48 @@ void matrix_init_kb(void) {
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

+ 5
- 0
keyboards/bastardkb/charybdis/post_config.h 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


+ 20
- 0
keyboards/bastardkb/charybdis/readme.md 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.

Loading…
Cancel
Save