diff options
author | Drashna Jaelre <drashna@live.com> | 2021-11-28 23:41:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-28 23:41:59 -0800 |
commit | 5b5b36421a7c887aad5bf5faef06dcf133d64f15 (patch) | |
tree | 166ec88bd74110261682d82cd1a4ee43ab0802be /keyboards/handwired/tractyl_manuform | |
parent | 4ee33f1ffd921d4691207c5c3ab8c12742ddc12d (diff) |
[Keymap] Unicode and cursor sync - drashna keymap (#15328)
Diffstat (limited to 'keyboards/handwired/tractyl_manuform')
8 files changed, 113 insertions, 37 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h index 6f702bd59e..d7618912f7 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h +++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h @@ -51,3 +51,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define NO_ACTION_FUNCTION #define OLED_DISPLAY_128X64 + +#define POINTING_DEVICE_TASK_THROTTLE +#define POINTING_DEVICE_RIGHT diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/f411/rules.mk index d6f972b468..0a4fbee0e5 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/rules.mk +++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/rules.mk @@ -6,7 +6,7 @@ BOOTLOADER = stm32-dfu KEYBOARD_SHARED_EP = yes CONSOLE_ENABLE = yes -MOUSE_SHARED_EP = no +MOUSE_SHARED_EP = yes EEPROM_DRIVER = spi WS2812_DRIVER = pwm diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h index 577b709bb5..85ddef103a 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h +++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h @@ -19,3 +19,4 @@ #define TRACKBALL_DPI_OPTIONS { 1200, 1800, 2600, 3400 } #define DEBOUNCE 45 +#define ENCODER_DEFAULT_POS 0x3 diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c index 3de8bcf108..f893a8cc41 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c +++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c @@ -125,7 +125,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______ ), [_ADJUST] = LAYOUT_5x6_right_wrapper( - KC_MAKE, ___________________BLANK___________________, _________________ADJUST_R1_________________, KC_RST, + KC_MAKE, KC_WIDE,KC_AUSSIE,KC_SCRIPT,KC_ZALGO,KC_NOMODE, KC_NOMODE,KC_BLOCKS,KC_REGIONAL,_______,_______, KC_RST, VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST, KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS, UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY, @@ -407,9 +407,9 @@ void oled_driver_render_logo_left(void) { render_kitty(); oled_set_cursor(6, 0); - oled_write_P(PSTR(" Tractyl "), true); + oled_write_P(PSTR(" Tractyl "), false); oled_set_cursor(6, 1); - oled_write_P(PSTR(" Manuform "), true); + oled_write_P(PSTR(" Manuform "), false); oled_set_cursor(6, 2); # if defined(WPM_ENABLE) render_wpm(1); diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk index 699e826485..1c615a7838 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk +++ b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk @@ -17,7 +17,7 @@ SWAP_HANDS_ENABLE = yes POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = pmw3360 -MOUSE_SHARED_EP = no +MOUSE_SHARED_EP = yes SPLIT_KEYBOARD = yes diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c index 4739af1e76..733f09a22e 100644 --- a/keyboards/handwired/tractyl_manuform/tm_sync.c +++ b/keyboards/handwired/tractyl_manuform/tm_sync.c @@ -14,19 +14,29 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "tractyl_manuform.h" +#include QMK_KEYBOARD_H +#include "pointing_device.h" #include "transactions.h" #include <string.h> +#ifdef MOUSEKEY_ENABLE +# include "mousekey.h" +#endif -kb_config_data_t kb_config; -kb_mouse_report_t sync_mouse_report; +// typedef struct { +// uint16_t device_cpi; +// } kb_config_data_t; + +kb_config_data_t kb_config; +static report_mouse_t shared_mouse_report; +extern const pointing_device_driver_t pointing_device_driver; 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; + shared_mouse_report = pointing_device_driver.get_report(shared_mouse_report); + memcpy(target2initiator_buffer, &shared_mouse_report, sizeof(report_mouse_t)); + shared_mouse_report.x = 0; + shared_mouse_report.y = 0; + shared_mouse_report.h = 0; + shared_mouse_report.v = 0; } void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { @@ -38,12 +48,15 @@ void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* in // Check if the state values are different if (cpi != kb_config.device_cpi) { cpi = kb_config.device_cpi; + if (!is_keyboard_left()) { + pointing_device_set_cpi(cpi); + } } } void keyboard_pre_init_sync(void) { memset(&kb_config, 0, sizeof(kb_config)); - memset(&sync_mouse_report, 0, sizeof(sync_mouse_report)); + memset(&shared_mouse_report, 0, sizeof(shared_mouse_report)); } void keyboard_post_init_sync(void) { @@ -84,3 +97,83 @@ void trackball_set_cpi(uint16_t cpi) { pointing_device_set_cpi(cpi); } } + +void pointing_device_task(void) { + if (!is_keyboard_master()) { + return; + } + +#if defined(POINTING_DEVICE_TASK_THROTTLE) + static uint32_t last_exec = 0; + if (timer_elapsed32(last_exec) < 1) { + return; + } + last_exec = timer_read32(); +#endif + + report_mouse_t local_report = pointing_device_get_report(); + + // Gather report info +#ifdef POINTING_DEVICE_MOTION_PIN + if (!readPin(POINTING_DEVICE_MOTION_PIN)) +#endif +#if defined(POINTING_DEVICE_COMBINED) + local_report = pointing_device_driver.get_report(local_report); + transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &shared_mouse_report); + local_report.x = local_report.x | shared_mouse_report.x; + local_report.y = local_report.y | shared_mouse_report.y; + local_report.h = local_report.h | shared_mouse_report.h; + local_report.v = local_report.v | shared_mouse_report.v; +#elif defined(POINTING_DEVICE_LEFT) + if (is_keyboard_left()) { + local_report = pointing_device_driver.get_report(local_report); + } else { + transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report); + } +#elif defined(POINTING_DEVICE_RIGHT) + if (!is_keyboard_left()) { + local_report = pointing_device_driver.get_report(local_report); + } else { + transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report); + } +#else +# error "You need to define the side(s) the pointing device is on. POINTING_DEVICE_COMBINED / POINTING_DEVICE_LEFT / POINTING_DEVICE_RIGHT" +#endif + + // Support rotation of the sensor data +#if defined(POINTING_DEVICE_ROTATION_90) || defined(POINTING_DEVICE_ROTATION_180) || defined(POINTING_DEVICE_ROTATION_270) + int8_t x = local_report.x, y = local_report.y; +# if defined(POINTING_DEVICE_ROTATION_90) + local_report.x = y; + local_report.y = -x; +# elif defined(POINTING_DEVICE_ROTATION_180) + local_report.x = -x; + local_report.y = -y; +# elif defined(POINTING_DEVICE_ROTATION_270) + local_report.x = -y; + local_report.y = x; +# else +# error "How the heck did you get here?!" +# endif +#endif + // Support Inverting the X and Y Axises +#if defined(POINTING_DEVICE_INVERT_X) + local_report.x = -local_report.x; +#endif +#if defined(POINTING_DEVICE_INVERT_Y) + local_report.y = -local_report.y; +#endif + + // allow kb to intercept and modify report + local_report = pointing_device_task_kb(local_report); + // combine with mouse report to ensure that the combined is sent correctly +#ifdef MOUSEKEY_ENABLE + report_mouse_t mousekey_report = mousekey_get_report(); + local_report.buttons = local_report.buttons | mousekey_report.buttons; +#endif +#if defined(POINTING_DEVICE_COMBINED) + local_report.buttons = local_report.buttons | shared_mouse_report.buttons; +#endif + pointing_device_set_report(local_report); + pointing_device_send(); +} diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c index 5f476fcc98..4b36fab54f 100644 --- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c +++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c @@ -99,20 +99,8 @@ void pointing_device_init_kb(void) { } report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { - if (is_keyboard_left()) { - if (is_keyboard_master()) { - transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report); - mouse_report.x = sync_mouse_report.x; - mouse_report.y = sync_mouse_report.y; - pointing_device_task_user(mouse_report); - } - } else { - if (is_keyboard_master()) { - pointing_device_task_user(mouse_report); - } else { - sync_mouse_report.x = mouse_report.x; - sync_mouse_report.y = mouse_report.y; - } + if (is_keyboard_master()) { + mouse_report = pointing_device_task_user(mouse_report); } return mouse_report; } diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h index f6a6c07520..6aa40fc18b 100644 --- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h +++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h @@ -43,15 +43,6 @@ typedef struct { uint16_t device_cpi; } kb_config_data_t; -__attribute__((aligned(16))) typedef struct { - int8_t x; - int8_t y; -} kb_mouse_report_t; - -extern kb_mouse_report_t sync_mouse_report; - -void process_mouse(void); -void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y); void trackball_set_cpi(uint16_t cpi); void matrix_init_sub_kb(void); void matrix_scan_sub_kb(void); |