[Keyboard] Tractyl Manuform - configuration updates (#14314)

* [Keyboard] Tractyl Manuform - configuration updates

* Update readmes

* Add more details

* Fix issues with encoder pins

* Additional fixes for pin config

* Fix up some comments
This commit is contained in:
Drashna Jaelre 2021-09-08 16:52:43 -07:00 committed by GitHub
parent 8f8411a98a
commit 4294aa0f1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 140 additions and 117 deletions

View file

@ -24,7 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COL_PINS \ #define MATRIX_COL_PINS \
{ A15, B3, B4, B5, B6, B7 } { A15, B3, B4, B5, B6, B7 }
#define MATRIX_ROW_PINS \ #define MATRIX_ROW_PINS \
{ B12, B13, B14, B15, A8, A9 } { B12, B13, B14, B15, A8, A10 }
#define UNUSED_PINS \
{ C15 }
// B2 used for BOOT1, has internal pull down?
// A9 has internal pull-down
// A11 and A12 are used for USB sense. DO NOT USE.
#define DIODE_DIRECTION COL2ROW #define DIODE_DIRECTION COL2ROW
@ -45,12 +51,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLED_SPLIT \ #define RGBLED_SPLIT \
{ 10, 10 } { 10, 10 }
#define DEBUG_LED_PIN C13 #define DEBUG_LED_PIN C13
#define AUDIO_PIN A0 /* Audio config */
#define AUDIO_PWM_DRIVER PWMD5 #define AUDIO_PIN B1
#define AUDIO_PWM_CHANNEL 1 #define AUDIO_PWM_DRIVER PWMD3
#define AUDIO_STATE_TIMER GPTD4 #define AUDIO_PWM_CHANNEL 4
#define AUDIO_PWM_PAL_MODE 2
#define AUDIO_STATE_TIMER GPTD4
/* serial.c configuration for split keyboard */ /* serial.c configuration for split keyboard */
#define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. #define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode.
@ -60,10 +68,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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_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_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_TIMEOUT 100 // USART driver timeout. default 100
#undef SOFT_SERIAL_PIN
// #define EE_HANDS
/* i2c config for oleds */
#define I2C_DRIVER I2CD1 #define I2C_DRIVER I2CD1
#define I2C1_SCL_BANK GPIOB #define I2C1_SCL_BANK GPIOB
#define I2C1_SDA_BANK GPIOB #define I2C1_SDA_BANK GPIOB
@ -73,11 +79,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define I2C1_SDA_PAL_MODE 4 #define I2C1_SDA_PAL_MODE 4
#define I2C1_CLOCK_SPEED 400000 #define I2C1_CLOCK_SPEED 400000
/* encoder config */
#define ENCODERS_PAD_A \ #define ENCODERS_PAD_A \
{ B1 } { A13 }
#define ENCODERS_PAD_B \ #define ENCODERS_PAD_B \
{ B2 } { A14 }
/* spi config for eeprom and pmw3360 sensor */
#define SPI_DRIVER SPID1 #define SPI_DRIVER SPID1
#define SPI_SCK_PIN A5 #define SPI_SCK_PIN A5
#define SPI_SCK_PAL_MODE 5 #define SPI_SCK_PAL_MODE 5
@ -86,6 +94,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SPI_MISO_PIN A6 #define SPI_MISO_PIN A6
#define SPI_MISO_PAL_MODE 5 #define SPI_MISO_PAL_MODE 5
/* eeprom config */
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A4 #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A4
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 #define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8
// #define EXTERNAL_EEPROM_BYTE_COUNT 8196 // #define EXTERNAL_EEPROM_BYTE_COUNT 8196
@ -93,6 +102,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define EXTERNAL_EEPROM_ADDRESS_SIZE 2 // #define EXTERNAL_EEPROM_ADDRESS_SIZE 2
// #define DEBUG_EEPROM_OUTPUT // #define DEBUG_EEPROM_OUTPUT
/* pmw3360 config */
#define PMW3360_CS_PIN B0 #define PMW3360_CS_PIN B0
#define PMW3360_SPI_MODE 3 #define PMW3360_SPI_MODE 3
#define PMW3360_SPI_DIVISOR 4 #define PMW3360_SPI_DIVISOR 4

View file

@ -15,7 +15,6 @@
*/ */
#pragma once #pragma once
// #define HAL_USE_DAC TRUE
#define HAL_USE_PWM TRUE #define HAL_USE_PWM TRUE
#define HAL_USE_SERIAL TRUE #define HAL_USE_SERIAL TRUE
#define HAL_USE_I2C TRUE #define HAL_USE_I2C TRUE

View file

@ -24,11 +24,14 @@
#undef STM32_PWM_USE_TIM5 #undef STM32_PWM_USE_TIM5
#define STM32_PWM_USE_TIM5 TRUE #define STM32_PWM_USE_TIM5 TRUE
#undef STM32_GPT_USE_TIM4 #undef STM32_PWM_USE_TIM3
#define STM32_GPT_USE_TIM4 TRUE #define STM32_PWM_USE_TIM3 TRUE
#undef STM32_SPI_USE_SPI1 #undef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE #define STM32_SPI_USE_SPI1 TRUE
#undef STM32_SERIAL_USE_USART2 #undef STM32_SERIAL_USE_USART2
#define STM32_SERIAL_USE_USART2 TRUE #define STM32_SERIAL_USE_USART2 TRUE
#undef STM32_GPT_USE_TIM4
#define STM32_GPT_USE_TIM4 TRUE

View file

@ -0,0 +1,24 @@
# Drashna's Blackpill Tractyl Manuform (5x6) with a right side trackball
* VBUS mod, using PB10
* Split Hand Pin, using PC14
* Full Duplex Serial/USART using PA3 and PA4 on USART2
* PWM Audio using PB1 and TIM3 and GPT on TIM4
* PWM RGB using PA1 TIM5
* pmw3360 sensor sharing PA5-PA7 on SPI1, with B0 as CS pin
* 8KB SPI EEPROM chip sharing PA5-PA7 on SPI1 with PA4 as CS pin
* Encoder using PA10 and PA12
* SSD1306 OLED display (128x64) using PB8-PB9 on I2C1
* Keyboard Maintainer: [Drashna Jael're](https://github.com/drashna)
* Hardware Supported: [Design files](https://gitlab.com/keyboards1/dm_r_track/-/tree/master/boolean), [WeAct BlackPill (F411)](https://github.com/WeActTC/MiniSTM32F4x1), [PMW3360 Optical Sensor](https://www.tindie.com/products/jkicklighter/pmw3360-motion-sensor/)
Make example for this keyboard (after setting up your build environment):
make handwired/tractyl_manuform/5x6_right/f411:default
Flashing example for this keyboard:
make handwired/tractyl_manuform/5x6_right/f411:default:flash
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

View file

@ -142,8 +142,14 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_LOWER] = { { RGB_MOD, RGB_RMOD}, { RGB_HUD, RGB_HUI } }, [_LOWER] = { { RGB_MOD, RGB_RMOD}, { RGB_HUD, RGB_HUI } },
[_ADJUST] = { { CK_DOWN, CK_UP }, { _______, _______ } }, [_ADJUST] = { { CK_DOWN, CK_UP }, { _______, _______ } },
}; };
// clang-format on
#else #else
bool encoder_update_user(uint8_t index, bool clockwise) { bool encoder_update_user(uint8_t index, bool clockwise) {
# ifdef SWAP_HANDS_ENABLE
if (swap_hands) {
index ^= 1;
}
# endif
if (index == 0) { if (index == 0) {
tap_code_delay(clockwise ? KC_VOLD : KC_VOLU, 5); tap_code_delay(clockwise ? KC_VOLD : KC_VOLU, 5);
} else if (index == 1) { } else if (index == 1) {
@ -152,7 +158,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
return false; return false;
} }
#endif #endif
// clang-format on
#ifdef POINTING_DEVICE_ENABLE #ifdef POINTING_DEVICE_ENABLE
static uint16_t mouse_timer = 0; static uint16_t mouse_timer = 0;

View file

@ -5,7 +5,7 @@ HAPTIC_ENABLE = no
COMMAND_ENABLE = no COMMAND_ENABLE = no
TAP_DANCE_ENABLE = yes TAP_DANCE_ENABLE = yes
UNICODE_ENABLE = yes UNICODE_ENABLE = yes
OLED_ENABLE = yes OLED_ENABLE = yes
WPM_ENABLE = yes WPM_ENABLE = yes
ENCODER_ENABLE = yes ENCODER_ENABLE = yes
ENCODER_MAP_ENABLE = yes ENCODER_MAP_ENABLE = yes

View file

@ -1,8 +1,8 @@
# Drashna's Dactyl Manuform (5x6) with a right side trackball # Drashna's Tractyl Manuform (5x6) with a right side trackball
![](https://preview.redd.it/zwt91036m3y51.jpg?width=960&crop=smart&auto=webp&s=e030deb7d8285c95a1a30c69a7e7a71f750e87bb) ![](https://preview.redd.it/zwt91036m3y51.jpg?width=960&crop=smart&auto=webp&s=e030deb7d8285c95a1a30c69a7e7a71f750e87bb)
It's a Dactyl Manuform with an integrated thumb based trackball, using the pmw3360 optical sensor. It's a Tractyl Manuform with an integrated thumb based trackball, using the pmw3360 optical sensor.
It's powered by 2x Teensy++ 2.0's, using Drashna's [Teensy VBUS Hack](https://docs.qmk.fm/#/feature_split_keyboard?id=hardware-considerations-and-mods) for better detection. It's powered by 2x Teensy++ 2.0's, using Drashna's [Teensy VBUS Hack](https://docs.qmk.fm/#/feature_split_keyboard?id=hardware-considerations-and-mods) for better detection.
@ -12,10 +12,10 @@ It's powered by 2x Teensy++ 2.0's, using Drashna's [Teensy VBUS Hack](https://do
Make example for this keyboard (after setting up your build environment): Make example for this keyboard (after setting up your build environment):
make handwired/dactyl_manuform/5x6_right_trackball:default make handwired/tractyl_manuform/5x6_right:default
Flashing example for this keyboard: Flashing example for this keyboard:
make handwired/dactyl_manuform/5x6_right_trackball:default:flash make handwired/tractyl_manuform/5x6_right:default:flash
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

View file

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
// mouse config // mouse config
#ifdef MOUSEKEY_ENABLE
# ifndef MOUSEKEY_MOVE_DELTA # ifndef MOUSEKEY_MOVE_DELTA
# ifndef MK_KINETIC_SPEED # ifndef MK_KINETIC_SPEED
# define MOUSEKEY_MOVE_DELTA 5 # define MOUSEKEY_MOVE_DELTA 5
@ -59,7 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define MOUSEKEY_ACCELERATED_SPEED 3000 # define MOUSEKEY_ACCELERATED_SPEED 3000
# endif # endif
// mouse scroll config // mouse scroll config
# ifndef MOUSEKEY_WHEEL_DELAY # ifndef MOUSEKEY_WHEEL_DELAY
# define MOUSEKEY_WHEEL_DELAY 15 # define MOUSEKEY_WHEEL_DELAY 15
@ -89,7 +89,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# ifndef MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS # ifndef MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS
# define MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS 8 # define MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS 8
# endif # endif
#endif
#ifndef DEBOUNCE #ifndef DEBOUNCE
# define DEBOUNCE 5 # define DEBOUNCE 5

View file

@ -20,43 +20,40 @@
#include "drivers/sensors/pmw3360.h" #include "drivers/sensors/pmw3360.h"
kb_config_data_t kb_config; kb_config_data_t kb_config;
kb_pointer_data_t kb_pointer; kb_mouse_report_t sync_mouse_report;
void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
if (target2initiator_buffer_size == sizeof(sync_mouse_report)) {
memcpy(target2initiator_buffer, &sync_mouse_report, sizeof(sync_mouse_report));
}
sync_mouse_report.x = 0;
sync_mouse_report.y = 0;
}
void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { void kb_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(kb_config)) { if (initiator2target_buffer_size == sizeof(kb_config)) {
memcpy(&kb_config, initiator2target_buffer, sizeof(kb_config)); memcpy(&kb_config, initiator2target_buffer, sizeof(kb_config));
} }
}
void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { static uint16_t cpi = 0;
if (target2initiator_buffer_size == sizeof(kb_pointer)) { // Check if the state values are different
memcpy(target2initiator_buffer, &kb_pointer, sizeof(kb_pointer)); if (cpi != kb_config.device_cpi) {
cpi = kb_config.device_cpi;
} }
} }
void keyboard_pre_init_sync(void) { void keyboard_pre_init_sync(void) {
memset(&kb_config, 0, sizeof(kb_config)); memset(&kb_config, 0, sizeof(kb_config));
memset(&kb_pointer, 0, sizeof(kb_pointer)); memset(&sync_mouse_report, 0, sizeof(sync_mouse_report));
} }
void keyboard_post_init_kb(void) { void keyboard_post_init_sync(void) {
// Register keyboard state sync split transaction // Register keyboard state sync split transaction
transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, kb_config_sync_handler); transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, kb_config_sync_handler);
transaction_register_rpc(RPC_ID_POINTER_STATE_SYNC, kb_pointer_sync_handler); transaction_register_rpc(RPC_ID_POINTER_STATE_SYNC, kb_pointer_sync_handler);
keyboard_post_init_user();
} }
void kb_config_update(void) { void housekeeping_task_sync(void) {
if (is_keyboard_master()) {
static uint16_t cpi = 0;
if (cpi != kb_config.device_cpi) {
cpi = kb_config.device_cpi;
pmw_set_cpi(cpi);
}
}
}
void kb_config_sync(void) {
if (is_keyboard_master()) { if (is_keyboard_master()) {
// Keep track of the last state, so that we can tell if we need to propagate to slave // Keep track of the last state, so that we can tell if we need to propagate to slave
static kb_config_data_t last_kb_config; static kb_config_data_t last_kb_config;
@ -82,35 +79,6 @@ void kb_config_sync(void) {
} }
} }
void kb_pointer_sync(void) {
if (is_keyboard_master() && is_keyboard_left()) {
// Keep track of the last state, so that we can tell if we need to propagate to slave
static uint32_t last_sync = 0;
// Perform the sync if requested
if (timer_elapsed32(last_sync) >= 5) {
if (transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(kb_pointer), &kb_pointer)) {
last_sync = timer_read32();
}
}
}
}
void housekeeping_task_kb(void) {
// Update kb_config so we can send to slave
kb_config_update();
// Data sync from master to slave
kb_config_sync();
kb_pointer_sync();
}
void kb_pointer_sync_send(int8_t x, int8_t y) {
kb_pointer.mouse_x = x;
kb_pointer.mouse_y = y;
}
kb_pointer_data_t kb_pointer_sync_get(void) { return (kb_pointer_data_t){.mouse_x = kb_pointer.mouse_x, .mouse_y = kb_pointer.mouse_y}; }
void trackball_set_cpi(uint16_t cpi) { void trackball_set_cpi(uint16_t cpi) {
kb_config.device_cpi = cpi; kb_config.device_cpi = cpi;
if (!is_keyboard_left()) { if (!is_keyboard_left()) {

View file

@ -34,23 +34,21 @@ keyboard_config_t keyboard_config;
uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS; uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) #define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
bool BurstState = false; // init burst state for Trackball module bool BurstState = false; // init burst state for Trackball module
uint16_t MotionStart = 0; // Timer for accel, 0 is resting state uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) { __attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) {
mouse_report->x = x; mouse_report->x = x;
mouse_report->y = y; mouse_report->y = y;
} }
__attribute__((weak)) kb_pointer_data_t process_mouse(void) { __attribute__((weak)) void process_mouse(void) {
kb_pointer_data_t temp_data = {.mouse_x = 0, .mouse_y = 0};
report_pmw_t data = pmw_read_burst(); report_pmw_t data = pmw_read_burst();
// Reset timer if stopped moving // Reset timer if stopped moving
if (!data.isMotion) { if (!data.isMotion) {
if (MotionStart != 0) MotionStart = 0; if (MotionStart != 0) MotionStart = 0;
return temp_data; return;
} }
if (data.isOnSurface) { if (data.isOnSurface) {
// Set timer if new motion // Set timer if new motion
@ -59,8 +57,12 @@ __attribute__((weak)) kb_pointer_data_t process_mouse(void) {
MotionStart = timer_read(); MotionStart = timer_read();
} }
if (debug_mouse) { dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart); } if (debug_mouse) {
if (debug_mouse) { dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy); } dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart);
}
if (debug_mouse) {
dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy);
}
#if defined(PROFILE_LINEAR) #if defined(PROFILE_LINEAR)
float scale = float(timer_elaspsed(MotionStart)) / 1000.0; float scale = float(timer_elaspsed(MotionStart)) / 1000.0;
data.dx *= scale; data.dx *= scale;
@ -77,14 +79,15 @@ __attribute__((weak)) kb_pointer_data_t process_mouse(void) {
if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy); if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy);
// dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i)); // dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i));
temp_data.mouse_x = -data.dx; sync_mouse_report.x = -data.dx;
temp_data.mouse_y = data.dy; sync_mouse_report.y = data.dy;
} }
return temp_data;
} }
bool process_record_kb(uint16_t keycode, keyrecord_t* record) { bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
if (!process_record_user(keycode, record)) { return false; } if (!process_record_user(keycode, record)) {
return false;
}
#ifdef POINTING_DEVICE_ENABLE #ifdef POINTING_DEVICE_ENABLE
if (keycode == DPI_CONFIG && record->event.pressed) { if (keycode == DPI_CONFIG && record->event.pressed) {
@ -119,29 +122,28 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
return true; return true;
} }
__attribute__((weak)) void keyboard_pre_init_sync(void) {} __attribute__((weak)) void keyboard_pre_init_sync(void) {}
void keyboard_pre_init_kb(void) {
// Hardware Setup
void keyboard_pre_init_kb(void) {
// debug_enable = true; // debug_enable = true;
// debug_matrix = true; // debug_matrix = true;
// debug_mouse = true; // debug_mouse = true;
// debug_encoder = true; // debug_encoder = true;
/* Ground all output pins connected to ground. This provides additional
* pathways to ground. If you're messing with this, know this: driving ANY
* of these pins high will cause a short. On the MCU. Ka-blooey.
*/
// This is the debug LED. // This is the debug LED.
#if defined(DEBUG_LED_PIN) #if defined(DEBUG_LED_PIN)
setPinOutput(DEBUG_LED_PIN); setPinOutput(DEBUG_LED_PIN);
writePin(DEBUG_LED_PIN, debug_enable); writePin(DEBUG_LED_PIN, !debug_enable);
#endif #endif
keyboard_pre_init_sync(); keyboard_pre_init_sync();
keyboard_pre_init_user(); keyboard_pre_init_user();
} }
__attribute__((weak)) void keyboard_post_init_sync(void) {}
void keyboard_post_init_kb(void) {
keyboard_post_init_sync();
keyboard_post_init_user();
}
#ifdef POINTING_DEVICE_ENABLE #ifdef POINTING_DEVICE_ENABLE
void pointing_device_init(void) { void pointing_device_init(void) {
if (!is_keyboard_left()) { if (!is_keyboard_left()) {
@ -153,18 +155,18 @@ void pointing_device_init(void) {
void pointing_device_task(void) { void pointing_device_task(void) {
report_mouse_t mouse_report = pointing_device_get_report(); report_mouse_t mouse_report = pointing_device_get_report();
kb_pointer_data_t data = {.mouse_x = mouse_report.x, .mouse_y = mouse_report.y};
if (is_keyboard_left()) { if (is_keyboard_left()) {
if (is_keyboard_master()) { if (is_keyboard_master()) {
data = kb_pointer_sync_get(); transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report);
process_mouse_user(&mouse_report, data.mouse_x, data.mouse_y); process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y);
} }
} else { } else {
data = process_mouse(); process_mouse();
if (!is_keyboard_master()) { if (is_keyboard_master()) {
kb_pointer_sync_send(data.mouse_x, data.mouse_y); process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y);
} else { sync_mouse_report.x = 0;
process_mouse_user(&mouse_report, data.mouse_x, data.mouse_y); sync_mouse_report.y = 0;
} }
} }
@ -183,11 +185,13 @@ void eeconfig_init_kb(void) {
} }
__attribute__((weak)) void matrix_init_sub_kb(void) {} __attribute__((weak)) void matrix_init_sub_kb(void) {}
void matrix_init_kb(void) { void matrix_init_kb(void) {
// is safe to just read DPI setting since matrix init // is safe to just read DPI setting since matrix init
// comes before pointing device init. // comes before pointing device init.
keyboard_config.raw = eeconfig_read_kb(); keyboard_config.raw = eeconfig_read_kb();
if (keyboard_config.dpi_config > DPI_OPTION_SIZE) { eeconfig_init_kb(); } if (keyboard_config.dpi_config > DPI_OPTION_SIZE) {
eeconfig_init_kb();
}
matrix_init_sub_kb(); matrix_init_sub_kb();
matrix_init_user(); matrix_init_user();
} }
@ -198,6 +202,12 @@ void matrix_scan_kb(void) {
matrix_scan_user(); matrix_scan_user();
} }
__attribute__((weak)) void housekeeping_task_sync(void) {}
void housekeeping_task_kb(void) {
housekeeping_task_sync();
// no need for user function, is called already
}
#ifdef POINTING_DEVICE_ENABLE #ifdef POINTING_DEVICE_ENABLE
void matrix_power_up(void) { pointing_device_task(); } void matrix_power_up(void) { pointing_device_task(); }
#endif #endif

View file

@ -40,18 +40,22 @@ enum ploopy_keycodes {
}; };
typedef struct { typedef struct {
uint16_t device_cpi; uint16_t device_cpi;
} kb_config_data_t; } kb_config_data_t;
__attribute__((aligned(16))) typedef struct { __attribute__((aligned(16))) typedef struct {
int8_t mouse_x; int8_t x;
int8_t mouse_y; int8_t y;
} kb_pointer_data_t; } kb_mouse_report_t;
kb_pointer_data_t process_mouse(void); extern kb_mouse_report_t sync_mouse_report;
void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y);
void kb_pointer_sync_send(int8_t x, int8_t y); void process_mouse(void);
kb_pointer_data_t kb_pointer_sync_get(void); void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y);
void trackball_set_cpi(uint16_t cpi); void trackball_set_cpi(uint16_t cpi);
void matrix_init_sub_kb(void); void matrix_init_sub_kb(void);
void matrix_scan_sub_kb(void); void matrix_scan_sub_kb(void);
void keyboard_pre_init_sync(void);
void keyboard_post_init_sync(void);
void housekeeping_task_sync(void);