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 | |
| parent | 4ee33f1ffd921d4691207c5c3ab8c12742ddc12d (diff) | |
| download | qmk_firmware-5b5b36421a7c887aad5bf5faef06dcf133d64f15.tar.gz qmk_firmware-5b5b36421a7c887aad5bf5faef06dcf133d64f15.zip | |
[Keymap] Unicode and cursor sync - drashna keymap (#15328)
Diffstat (limited to 'keyboards/handwired')
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 6f702bd59..d7618912f 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/>. | |||
| 51 | #define NO_ACTION_FUNCTION | 51 | #define NO_ACTION_FUNCTION |
| 52 | 52 | ||
| 53 | #define OLED_DISPLAY_128X64 | 53 | #define OLED_DISPLAY_128X64 |
| 54 | |||
| 55 | #define POINTING_DEVICE_TASK_THROTTLE | ||
| 56 | #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 d6f972b46..0a4fbee0e 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 | |||
| 6 | 6 | ||
| 7 | KEYBOARD_SHARED_EP = yes | 7 | KEYBOARD_SHARED_EP = yes |
| 8 | CONSOLE_ENABLE = yes | 8 | CONSOLE_ENABLE = yes |
| 9 | MOUSE_SHARED_EP = no | 9 | MOUSE_SHARED_EP = yes |
| 10 | 10 | ||
| 11 | EEPROM_DRIVER = spi | 11 | EEPROM_DRIVER = spi |
| 12 | WS2812_DRIVER = pwm | 12 | 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 577b709bb..85ddef103 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 @@ | |||
| 19 | #define TRACKBALL_DPI_OPTIONS { 1200, 1800, 2600, 3400 } | 19 | #define TRACKBALL_DPI_OPTIONS { 1200, 1800, 2600, 3400 } |
| 20 | 20 | ||
| 21 | #define DEBOUNCE 45 | 21 | #define DEBOUNCE 45 |
| 22 | #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 3de8bcf10..f893a8cc4 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] = { | |||
| 125 | _______, _______, _______, _______ | 125 | _______, _______, _______, _______ |
| 126 | ), | 126 | ), |
| 127 | [_ADJUST] = LAYOUT_5x6_right_wrapper( | 127 | [_ADJUST] = LAYOUT_5x6_right_wrapper( |
| 128 | KC_MAKE, ___________________BLANK___________________, _________________ADJUST_R1_________________, KC_RST, | 128 | KC_MAKE, KC_WIDE,KC_AUSSIE,KC_SCRIPT,KC_ZALGO,KC_NOMODE, KC_NOMODE,KC_BLOCKS,KC_REGIONAL,_______,_______, KC_RST, |
| 129 | VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST, | 129 | VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST, |
| 130 | KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS, | 130 | KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS, |
| 131 | UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY, | 131 | UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY, |
| @@ -407,9 +407,9 @@ void oled_driver_render_logo_left(void) { | |||
| 407 | render_kitty(); | 407 | render_kitty(); |
| 408 | 408 | ||
| 409 | oled_set_cursor(6, 0); | 409 | oled_set_cursor(6, 0); |
| 410 | oled_write_P(PSTR(" Tractyl "), true); | 410 | oled_write_P(PSTR(" Tractyl "), false); |
| 411 | oled_set_cursor(6, 1); | 411 | oled_set_cursor(6, 1); |
| 412 | oled_write_P(PSTR(" Manuform "), true); | 412 | oled_write_P(PSTR(" Manuform "), false); |
| 413 | oled_set_cursor(6, 2); | 413 | oled_set_cursor(6, 2); |
| 414 | # if defined(WPM_ENABLE) | 414 | # if defined(WPM_ENABLE) |
| 415 | render_wpm(1); | 415 | render_wpm(1); |
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk index 699e82648..1c615a783 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 | |||
| 17 | 17 | ||
| 18 | POINTING_DEVICE_ENABLE = yes | 18 | POINTING_DEVICE_ENABLE = yes |
| 19 | POINTING_DEVICE_DRIVER = pmw3360 | 19 | POINTING_DEVICE_DRIVER = pmw3360 |
| 20 | MOUSE_SHARED_EP = no | 20 | MOUSE_SHARED_EP = yes |
| 21 | 21 | ||
| 22 | SPLIT_KEYBOARD = yes | 22 | SPLIT_KEYBOARD = yes |
| 23 | 23 | ||
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c index 4739af1e7..733f09a22 100644 --- a/keyboards/handwired/tractyl_manuform/tm_sync.c +++ b/keyboards/handwired/tractyl_manuform/tm_sync.c | |||
| @@ -14,19 +14,29 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "tractyl_manuform.h" | 17 | #include QMK_KEYBOARD_H |
| 18 | #include "pointing_device.h" | ||
| 18 | #include "transactions.h" | 19 | #include "transactions.h" |
| 19 | #include <string.h> | 20 | #include <string.h> |
| 21 | #ifdef MOUSEKEY_ENABLE | ||
| 22 | # include "mousekey.h" | ||
| 23 | #endif | ||
| 20 | 24 | ||
| 21 | kb_config_data_t kb_config; | 25 | // typedef struct { |
| 22 | kb_mouse_report_t sync_mouse_report; | 26 | // uint16_t device_cpi; |
| 27 | // } kb_config_data_t; | ||
| 28 | |||
| 29 | kb_config_data_t kb_config; | ||
| 30 | static report_mouse_t shared_mouse_report; | ||
| 31 | extern const pointing_device_driver_t pointing_device_driver; | ||
| 23 | 32 | ||
| 24 | void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { | 33 | void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { |
| 25 | if (target2initiator_buffer_size == sizeof(sync_mouse_report)) { | 34 | shared_mouse_report = pointing_device_driver.get_report(shared_mouse_report); |
| 26 | memcpy(target2initiator_buffer, &sync_mouse_report, sizeof(sync_mouse_report)); | 35 | memcpy(target2initiator_buffer, &shared_mouse_report, sizeof(report_mouse_t)); |
| 27 | } | 36 | shared_mouse_report.x = 0; |
| 28 | sync_mouse_report.x = 0; | 37 | shared_mouse_report.y = 0; |
| 29 | sync_mouse_report.y = 0; | 38 | shared_mouse_report.h = 0; |
| 39 | shared_mouse_report.v = 0; | ||
| 30 | } | 40 | } |
| 31 | 41 | ||
| 32 | void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { | 42 | 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 | |||
| 38 | // Check if the state values are different | 48 | // Check if the state values are different |
| 39 | if (cpi != kb_config.device_cpi) { | 49 | if (cpi != kb_config.device_cpi) { |
| 40 | cpi = kb_config.device_cpi; | 50 | cpi = kb_config.device_cpi; |
| 51 | if (!is_keyboard_left()) { | ||
| 52 | pointing_device_set_cpi(cpi); | ||
| 53 | } | ||
| 41 | } | 54 | } |
| 42 | } | 55 | } |
| 43 | 56 | ||
| 44 | void keyboard_pre_init_sync(void) { | 57 | void keyboard_pre_init_sync(void) { |
| 45 | memset(&kb_config, 0, sizeof(kb_config)); | 58 | memset(&kb_config, 0, sizeof(kb_config)); |
| 46 | memset(&sync_mouse_report, 0, sizeof(sync_mouse_report)); | 59 | memset(&shared_mouse_report, 0, sizeof(shared_mouse_report)); |
| 47 | } | 60 | } |
| 48 | 61 | ||
| 49 | void keyboard_post_init_sync(void) { | 62 | void keyboard_post_init_sync(void) { |
| @@ -84,3 +97,83 @@ void trackball_set_cpi(uint16_t cpi) { | |||
| 84 | pointing_device_set_cpi(cpi); | 97 | pointing_device_set_cpi(cpi); |
| 85 | } | 98 | } |
| 86 | } | 99 | } |
| 100 | |||
| 101 | void pointing_device_task(void) { | ||
| 102 | if (!is_keyboard_master()) { | ||
| 103 | return; | ||
| 104 | } | ||
| 105 | |||
| 106 | #if defined(POINTING_DEVICE_TASK_THROTTLE) | ||
| 107 | static uint32_t last_exec = 0; | ||
| 108 | if (timer_elapsed32(last_exec) < 1) { | ||
| 109 | return; | ||
| 110 | } | ||
| 111 | last_exec = timer_read32(); | ||
| 112 | #endif | ||
| 113 | |||
| 114 | report_mouse_t local_report = pointing_device_get_report(); | ||
| 115 | |||
| 116 | // Gather report info | ||
| 117 | #ifdef POINTING_DEVICE_MOTION_PIN | ||
| 118 | if (!readPin(POINTING_DEVICE_MOTION_PIN)) | ||
| 119 | #endif | ||
| 120 | #if defined(POINTING_DEVICE_COMBINED) | ||
| 121 | local_report = pointing_device_driver.get_report(local_report); | ||
| 122 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &shared_mouse_report); | ||
| 123 | local_report.x = local_report.x | shared_mouse_report.x; | ||
| 124 | local_report.y = local_report.y | shared_mouse_report.y; | ||
| 125 | local_report.h = local_report.h | shared_mouse_report.h; | ||
| 126 | local_report.v = local_report.v | shared_mouse_report.v; | ||
| 127 | #elif defined(POINTING_DEVICE_LEFT) | ||
| 128 | if (is_keyboard_left()) { | ||
| 129 | local_report = pointing_device_driver.get_report(local_report); | ||
| 130 | } else { | ||
| 131 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report); | ||
| 132 | } | ||
| 133 | #elif defined(POINTING_DEVICE_RIGHT) | ||
| 134 | if (!is_keyboard_left()) { | ||
| 135 | local_report = pointing_device_driver.get_report(local_report); | ||
| 136 | } else { | ||
| 137 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report); | ||
| 138 | } | ||
| 139 | #else | ||
| 140 | # error "You need to define the side(s) the pointing device is on. POINTING_DEVICE_COMBINED / POINTING_DEVICE_LEFT / POINTING_DEVICE_RIGHT" | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // Support rotation of the sensor data | ||
| 144 | #if defined(POINTING_DEVICE_ROTATION_90) || defined(POINTING_DEVICE_ROTATION_180) || defined(POINTING_DEVICE_ROTATION_270) | ||
| 145 | int8_t x = local_report.x, y = local_report.y; | ||
| 146 | # if defined(POINTING_DEVICE_ROTATION_90) | ||
| 147 | local_report.x = y; | ||
| 148 | local_report.y = -x; | ||
| 149 | # elif defined(POINTING_DEVICE_ROTATION_180) | ||
| 150 | local_report.x = -x; | ||
| 151 | local_report.y = -y; | ||
| 152 | # elif defined(POINTING_DEVICE_ROTATION_270) | ||
| 153 | local_report.x = -y; | ||
| 154 | local_report.y = x; | ||
| 155 | # else | ||
| 156 | # error "How the heck did you get here?!" | ||
| 157 | # endif | ||
| 158 | #endif | ||
| 159 | // Support Inverting the X and Y Axises | ||
| 160 | #if defined(POINTING_DEVICE_INVERT_X) | ||
| 161 | local_report.x = -local_report.x; | ||
| 162 | #endif | ||
| 163 | #if defined(POINTING_DEVICE_INVERT_Y) | ||
| 164 | local_report.y = -local_report.y; | ||
| 165 | #endif | ||
| 166 | |||
| 167 | // allow kb to intercept and modify report | ||
| 168 | local_report = pointing_device_task_kb(local_report); | ||
| 169 | // combine with mouse report to ensure that the combined is sent correctly | ||
| 170 | #ifdef MOUSEKEY_ENABLE | ||
| 171 | report_mouse_t mousekey_report = mousekey_get_report(); | ||
| 172 | local_report.buttons = local_report.buttons | mousekey_report.buttons; | ||
| 173 | #endif | ||
| 174 | #if defined(POINTING_DEVICE_COMBINED) | ||
| 175 | local_report.buttons = local_report.buttons | shared_mouse_report.buttons; | ||
| 176 | #endif | ||
| 177 | pointing_device_set_report(local_report); | ||
| 178 | pointing_device_send(); | ||
| 179 | } | ||
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c index 5f476fcc9..4b36fab54 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) { | |||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { | 101 | report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { |
| 102 | if (is_keyboard_left()) { | 102 | if (is_keyboard_master()) { |
| 103 | if (is_keyboard_master()) { | 103 | mouse_report = pointing_device_task_user(mouse_report); |
| 104 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report); | ||
| 105 | mouse_report.x = sync_mouse_report.x; | ||
| 106 | mouse_report.y = sync_mouse_report.y; | ||
| 107 | pointing_device_task_user(mouse_report); | ||
| 108 | } | ||
| 109 | } else { | ||
| 110 | if (is_keyboard_master()) { | ||
| 111 | pointing_device_task_user(mouse_report); | ||
| 112 | } else { | ||
| 113 | sync_mouse_report.x = mouse_report.x; | ||
| 114 | sync_mouse_report.y = mouse_report.y; | ||
| 115 | } | ||
| 116 | } | 104 | } |
| 117 | return mouse_report; | 105 | return mouse_report; |
| 118 | } | 106 | } |
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h index f6a6c0752..6aa40fc18 100644 --- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h +++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h | |||
| @@ -43,15 +43,6 @@ typedef struct { | |||
| 43 | uint16_t device_cpi; | 43 | uint16_t device_cpi; |
| 44 | } kb_config_data_t; | 44 | } kb_config_data_t; |
| 45 | 45 | ||
| 46 | __attribute__((aligned(16))) typedef struct { | ||
| 47 | int8_t x; | ||
| 48 | int8_t y; | ||
| 49 | } kb_mouse_report_t; | ||
| 50 | |||
| 51 | extern kb_mouse_report_t sync_mouse_report; | ||
| 52 | |||
| 53 | void process_mouse(void); | ||
| 54 | void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y); | ||
| 55 | void trackball_set_cpi(uint16_t cpi); | 46 | void trackball_set_cpi(uint16_t cpi); |
| 56 | void matrix_init_sub_kb(void); | 47 | void matrix_init_sub_kb(void); |
| 57 | void matrix_scan_sub_kb(void); | 48 | void matrix_scan_sub_kb(void); |
