diff options
Diffstat (limited to 'keyboards/handwired')
5 files changed, 24 insertions, 76 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h index ce35197f7..6f702bd59 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h +++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h | |||
| @@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | #define DIODE_DIRECTION COL2ROW | 31 | #define DIODE_DIRECTION COL2ROW |
| 32 | 32 | ||
| 33 | #define ROTATIONAL_TRANSFORM_ANGLE -25 | 33 | #define ROTATIONAL_TRANSFORM_ANGLE -25 |
| 34 | #define POINTING_DEVICE_INVERT_X | ||
| 34 | 35 | ||
| 35 | /* Bootmagic Lite key configuration */ | 36 | /* Bootmagic Lite key configuration */ |
| 36 | #define BOOTMAGIC_LITE_ROW 0 | 37 | #define BOOTMAGIC_LITE_ROW 0 |
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 5bfc21fd1..127595076 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c +++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c | |||
| @@ -174,7 +174,11 @@ bool tap_toggling = false; | |||
| 174 | # define TAP_CHECK TAPPING_TERM | 174 | # define TAP_CHECK TAPPING_TERM |
| 175 | # endif | 175 | # endif |
| 176 | 176 | ||
| 177 | void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) { | 177 | report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { |
| 178 | int8_t x = mouse_report.x, y = mouse_report.y; | ||
| 179 | mouse_report.x = 0; | ||
| 180 | mouse_report.y = 0; | ||
| 181 | |||
| 178 | if (x != 0 && y != 0) { | 182 | if (x != 0 && y != 0) { |
| 179 | mouse_timer = timer_read(); | 183 | mouse_timer = timer_read(); |
| 180 | # ifdef OLED_ENABLE | 184 | # ifdef OLED_ENABLE |
| @@ -185,13 +189,14 @@ void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) { | |||
| 185 | x = (x > 0 ? x * x / 16 + x : -x * x / 16 + x); | 189 | x = (x > 0 ? x * x / 16 + x : -x * x / 16 + x); |
| 186 | y = (y > 0 ? y * y / 16 + y : -y * y / 16 + y); | 190 | y = (y > 0 ? y * y / 16 + y : -y * y / 16 + y); |
| 187 | } | 191 | } |
| 188 | mouse_report->x = x; | 192 | mouse_report.x = x; |
| 189 | mouse_report->y = y; | 193 | mouse_report.y = y; |
| 190 | if (!layer_state_is(_MOUSE)) { | 194 | if (!layer_state_is(_MOUSE)) { |
| 191 | layer_on(_MOUSE); | 195 | layer_on(_MOUSE); |
| 192 | } | 196 | } |
| 193 | } | 197 | } |
| 194 | } | 198 | } |
| 199 | return mouse_report; | ||
| 195 | } | 200 | } |
| 196 | 201 | ||
| 197 | void matrix_scan_keymap(void) { | 202 | void matrix_scan_keymap(void) { |
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk index c9bc2dbb9..699e82648 100644 --- a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk +++ b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk | |||
| @@ -16,11 +16,11 @@ AUDIO_ENABLE = no # Audio output | |||
| 16 | SWAP_HANDS_ENABLE = yes | 16 | SWAP_HANDS_ENABLE = yes |
| 17 | 17 | ||
| 18 | POINTING_DEVICE_ENABLE = yes | 18 | POINTING_DEVICE_ENABLE = yes |
| 19 | POINTING_DEVICE_DRIVER = pmw3360 | ||
| 19 | MOUSE_SHARED_EP = no | 20 | MOUSE_SHARED_EP = no |
| 20 | 21 | ||
| 21 | SPLIT_KEYBOARD = yes | 22 | SPLIT_KEYBOARD = yes |
| 22 | 23 | ||
| 23 | SRC += drivers/sensors/pmw3360.c | 24 | QUANTUM_LIB_SRC += tm_sync.c |
| 24 | QUANTUM_LIB_SRC += spi_master.c tm_sync.c | ||
| 25 | 25 | ||
| 26 | DEFAULT_FOLDER = handwired/tractyl_manuform/5x6_right/teensy2pp | 26 | DEFAULT_FOLDER = handwired/tractyl_manuform/5x6_right/teensy2pp |
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c index 1cb354946..4739af1e7 100644 --- a/keyboards/handwired/tractyl_manuform/tm_sync.c +++ b/keyboards/handwired/tractyl_manuform/tm_sync.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include "tractyl_manuform.h" | 17 | #include "tractyl_manuform.h" |
| 18 | #include "transactions.h" | 18 | #include "transactions.h" |
| 19 | #include <string.h> | 19 | #include <string.h> |
| 20 | #include "drivers/sensors/pmw3360.h" | ||
| 21 | 20 | ||
| 22 | kb_config_data_t kb_config; | 21 | kb_config_data_t kb_config; |
| 23 | kb_mouse_report_t sync_mouse_report; | 22 | kb_mouse_report_t sync_mouse_report; |
| @@ -82,6 +81,6 @@ void housekeeping_task_sync(void) { | |||
| 82 | void trackball_set_cpi(uint16_t cpi) { | 81 | void trackball_set_cpi(uint16_t cpi) { |
| 83 | kb_config.device_cpi = cpi; | 82 | kb_config.device_cpi = cpi; |
| 84 | if (!is_keyboard_left()) { | 83 | if (!is_keyboard_left()) { |
| 85 | pmw_set_cpi(cpi); | 84 | pointing_device_set_cpi(cpi); |
| 86 | } | 85 | } |
| 87 | } | 86 | } |
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c index d851528ff..5f476fcc9 100644 --- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c +++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c | |||
| @@ -34,55 +34,7 @@ keyboard_config_t keyboard_config; | |||
| 34 | uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS; | 34 | uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS; |
| 35 | #define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) | 35 | #define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) |
| 36 | 36 | ||
| 37 | bool BurstState = false; // init burst state for Trackball module | ||
| 38 | uint16_t MotionStart = 0; // Timer for accel, 0 is resting state | ||
| 39 | 37 | ||
| 40 | __attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) { | ||
| 41 | mouse_report->x = x; | ||
| 42 | mouse_report->y = y; | ||
| 43 | } | ||
| 44 | |||
| 45 | __attribute__((weak)) void process_mouse(void) { | ||
| 46 | report_pmw_t data = pmw_read_burst(); | ||
| 47 | // Reset timer if stopped moving | ||
| 48 | if (!data.isMotion) { | ||
| 49 | if (MotionStart != 0) MotionStart = 0; | ||
| 50 | return; | ||
| 51 | } | ||
| 52 | |||
| 53 | if (data.isOnSurface) { | ||
| 54 | // Set timer if new motion | ||
| 55 | if (MotionStart == 0) { | ||
| 56 | if (debug_mouse) dprintf("Starting motion.\n"); | ||
| 57 | MotionStart = timer_read(); | ||
| 58 | } | ||
| 59 | |||
| 60 | if (debug_mouse) { | ||
| 61 | dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart); | ||
| 62 | } | ||
| 63 | if (debug_mouse) { | ||
| 64 | dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy); | ||
| 65 | } | ||
| 66 | #if defined(PROFILE_LINEAR) | ||
| 67 | float scale = float(timer_elaspsed(MotionStart)) / 1000.0; | ||
| 68 | data.dx *= scale; | ||
| 69 | data.dy *= scale; | ||
| 70 | #elif defined(PROFILE_INVERSE) | ||
| 71 | // TODO | ||
| 72 | #else | ||
| 73 | // no post processing | ||
| 74 | #endif | ||
| 75 | |||
| 76 | // Wrap to HID size | ||
| 77 | data.dx = constrain(data.dx, -127, 127); | ||
| 78 | data.dy = constrain(data.dy, -127, 127); | ||
| 79 | if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy); | ||
| 80 | // dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i)); | ||
| 81 | |||
| 82 | sync_mouse_report.x = -data.dx; | ||
| 83 | sync_mouse_report.y = data.dy; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | 38 | ||
| 87 | bool process_record_kb(uint16_t keycode, keyrecord_t* record) { | 39 | bool process_record_kb(uint16_t keycode, keyrecord_t* record) { |
| 88 | if (!process_record_user(keycode, record)) { | 40 | if (!process_record_user(keycode, record)) { |
| @@ -109,11 +61,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { | |||
| 109 | #ifndef MOUSEKEY_ENABLE | 61 | #ifndef MOUSEKEY_ENABLE |
| 110 | if (IS_MOUSEKEY_BUTTON(keycode)) { | 62 | if (IS_MOUSEKEY_BUTTON(keycode)) { |
| 111 | report_mouse_t currentReport = pointing_device_get_report(); | 63 | report_mouse_t currentReport = pointing_device_get_report(); |
| 112 | if (record->event.pressed) { | 64 | currentReport.buttons = pointing_device_handle_buttons(currentReport.buttons, record->event.pressed, keycode - KC_MS_BTN1); |
| 113 | currentReport.buttons |= 1 << (keycode - KC_MS_BTN1); | ||
| 114 | } else { | ||
| 115 | currentReport.buttons &= ~(1 << (keycode - KC_MS_BTN1)); | ||
| 116 | } | ||
| 117 | pointing_device_set_report(currentReport); | 65 | pointing_device_set_report(currentReport); |
| 118 | pointing_device_send(); | 66 | pointing_device_send(); |
| 119 | } | 67 | } |
| @@ -145,33 +93,28 @@ void keyboard_post_init_kb(void) { | |||
| 145 | } | 93 | } |
| 146 | 94 | ||
| 147 | #ifdef POINTING_DEVICE_ENABLE | 95 | #ifdef POINTING_DEVICE_ENABLE |
| 148 | void pointing_device_init(void) { | 96 | void pointing_device_init_kb(void) { |
| 149 | if (!is_keyboard_left()) { | ||
| 150 | // initialize ball sensor | ||
| 151 | pmw_spi_init(); | ||
| 152 | } | ||
| 153 | trackball_set_cpi(dpi_array[keyboard_config.dpi_config]); | 97 | trackball_set_cpi(dpi_array[keyboard_config.dpi_config]); |
| 98 | pointing_device_init_user(); | ||
| 154 | } | 99 | } |
| 155 | 100 | ||
| 156 | void pointing_device_task(void) { | 101 | report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { |
| 157 | report_mouse_t mouse_report = pointing_device_get_report(); | ||
| 158 | |||
| 159 | if (is_keyboard_left()) { | 102 | if (is_keyboard_left()) { |
| 160 | if (is_keyboard_master()) { | 103 | if (is_keyboard_master()) { |
| 161 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report); | 104 | transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report); |
| 162 | process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y); | 105 | mouse_report.x = sync_mouse_report.x; |
| 106 | mouse_report.y = sync_mouse_report.y; | ||
| 107 | pointing_device_task_user(mouse_report); | ||
| 163 | } | 108 | } |
| 164 | } else { | 109 | } else { |
| 165 | process_mouse(); | ||
| 166 | if (is_keyboard_master()) { | 110 | if (is_keyboard_master()) { |
| 167 | process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y); | 111 | pointing_device_task_user(mouse_report); |
| 168 | sync_mouse_report.x = 0; | 112 | } else { |
| 169 | sync_mouse_report.y = 0; | 113 | sync_mouse_report.x = mouse_report.x; |
| 114 | sync_mouse_report.y = mouse_report.y; | ||
| 170 | } | 115 | } |
| 171 | } | 116 | } |
| 172 | 117 | return mouse_report; | |
| 173 | pointing_device_set_report(mouse_report); | ||
| 174 | pointing_device_send(); | ||
| 175 | } | 118 | } |
| 176 | #endif | 119 | #endif |
| 177 | 120 | ||
