From 7a08b9d374dfcf9d872738af44b231862064b96f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 22 Jan 2021 08:23:03 -0800 Subject: [Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master --- .../5x6_right_trackball/5x6_right_trackball.c | 4 +- .../dactyl_manuform/5x6_right_trackball/config.h | 4 + .../5x6_right_trackball/keymaps/default/config.h | 7 +- .../5x6_right_trackball/keymaps/default/keymap.c | 48 +----- .../5x6_right_trackball/keymaps/default/rules.mk | 4 + .../5x6_right_trackball/keymaps/drashna/config.h | 14 ++ .../5x6_right_trackball/keymaps/drashna/keymap.c | 3 +- .../5x6_right_trackball/keymaps/drashna/rules.mk | 11 +- .../5x6_right_trackball/pointer_transport.c | 164 +++++++++++++++++++-- 9 files changed, 188 insertions(+), 71 deletions(-) create mode 100644 keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/rules.mk (limited to 'keyboards/handwired') diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/5x6_right_trackball.c b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/5x6_right_trackball.c index c40e4173da..d931fd940d 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/5x6_right_trackball.c +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/5x6_right_trackball.c @@ -142,7 +142,7 @@ void pointing_device_init(void) { trackball_set_cpi(dpi_array[keyboard_config.dpi_config]); } -static bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) { +static bool has_report_changed(report_mouse_t new, report_mouse_t old) { return (new.buttons != old.buttons) || (new.x && new.x != old.x) || (new.y && new.y != old.y) || @@ -186,7 +186,7 @@ void pointing_device_send(void) { mouseReport.x = 0; mouseReport.y = 0; process_mouse_user(&mouseReport, x, y); - if (has_mouse_report_changed(mouseReport, old_report)) { + if (has_report_changed(mouseReport, old_report)) { host_mouse_send(&mouseReport); } } else { diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h index 147f126006..6d89314a2c 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h @@ -65,3 +65,7 @@ along with this program. If not, see . #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 #define DYNAMIC_KEYMAP_LAYER_COUNT 16 + +/* serial.c configuration for split keyboard */ +#undef SOFT_SERIAL_PIN +#define SOFT_SERIAL_PIN D2 diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/config.h b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/config.h index 4e35d4c4fc..5bad6bcab3 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/config.h +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/config.h @@ -19,9 +19,4 @@ #pragma once -#define USE_SERIAL - -#define MASTER_LEFT -// #define MASTER_RIGHT -//#define EE_HANDS -// Rows are doubled-up +#include "../drashna/config.h" diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/keymap.c b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/keymap.c index 7550b1fd8a..037f59af85 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/keymap.c +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/keymap.c @@ -14,50 +14,4 @@ * along with this program. If not, see . */ -#include QMK_KEYBOARD_H - - -#define _QWERTY 0 -#define _LOWER 1 -#define _RAISE 2 - -#define RAISE MO(_RAISE) -#define LOWER MO(_LOWER) - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - - [_QWERTY] = LAYOUT_5x6_right_trackball( - KC_ESC , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 ,KC_BSPC, - KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P ,KC_MINS, - KC_LSFT, KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L ,KC_SCLN,KC_QUOT, - KC_LCTL, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M ,KC_COMM,KC_DOT ,KC_SLSH,KC_BSLASH, - KC_LBRC,KC_RBRC, KC_EQL, - RAISE,KC_SPC, LOWER, - KC_TAB,KC_HOME, KC_END, KC_DEL, - KC_BSPC, KC_GRV, KC_LGUI, KC_LALT - ), - - [_LOWER] = LAYOUT_5x6_right_trackball( - - KC_TILD,KC_EXLM, KC_AT ,KC_HASH,KC_DLR ,KC_PERC, KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_DEL, - _______,_______,_______,_______,_______,KC_LBRC, KC_RBRC, KC_P7 , KC_P8 , KC_P9 ,_______,KC_PLUS, - _______,KC_HOME,KC_PGUP,KC_PGDN,KC_END ,KC_LPRN, KC_RPRN, KC_P4 , KC_P5 , KC_P6 ,KC_MINS,KC_PIPE, - _______,_______,_______,_______,_______,_______, _______, KC_P1 , KC_P2 , KC_P3 ,KC_EQL ,KC_UNDS, - _______,KC_PSCR, KC_P0, - _______,_______, _______, - _______,_______, _______,_______, - _______,_______, _______,_______ - - ), - - [_RAISE] = LAYOUT_5x6_right_trackball( - KC_F12 , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 ,KC_F10 ,KC_F11 , - _______,_______,_______,_______,_______,KC_LBRC, KC_RBRC,_______,KC_NLCK,KC_INS ,KC_SLCK,KC_MUTE, - _______,KC_LEFT,KC_UP ,KC_DOWN,KC_RGHT,KC_LPRN, KC_RPRN,KC_MPRV,KC_MPLY,KC_MNXT,_______,KC_VOLU, - _______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,KC_VOLD, - _______,_______, _______, - _______,_______, _______, - _______,_______, _______,_______, - _______,_______, _______,_______ - ), -}; +// placeholder diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/rules.mk b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/rules.mk new file mode 100644 index 0000000000..457cda5b0a --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/default/rules.mk @@ -0,0 +1,4 @@ +USER_NAME := drashna +SRC += ../drashna/keymap.c + +include $(KEYBOARD_PATH_1)/keymaps/drashna/rules.mk diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/config.h b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/config.h index 78dff38967..73bf32b25e 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/config.h +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/config.h @@ -17,6 +17,8 @@ #pragma once // #define USE_I2C +#define SELECT_SOFT_SERIAL_SPEED 0 +#define SERIAL_USE_MULTI_TRANSACTION #define EE_HANDS #define TRACKBALL_DPI_OPTIONS \ @@ -24,5 +26,17 @@ #define RGBLIGHT_EFFECT_TWINKLE_LIFE 50 #define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1/63 +#define RGBLIGHT_MAX_BRIGHTNESS 100 + +#undef DEBOUNCE +#define DEBOUNCE 10 #define SOLENOID_PIN F1 +#define SOLENOID_DEFAULT_DWELL 8 + +#define OLED_DISPLAY_128X64 +#define OLED_TIMEOUT 0 +#define OLED_BRIGHTNESS 100 +#define SPLIT_MODS_ENABLE + +#define MK_KINETIC_SPEED diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c index ca9733b6e3..f8803edb9c 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c @@ -17,7 +17,6 @@ #include "drashna.h" #define TG_DBLO TG(_DIABLO) -#define _MOUSE _MEDIA // clang-format off @@ -172,7 +171,7 @@ void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { } void matrix_scan_keymap(void) { - if (timer_elapsed(mouse_timer) > 750 && layer_state_is(_MOUSE) && !mouse_keycode_tracker) { + if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker) { layer_off(_MOUSE); } } diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/rules.mk b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/rules.mk index 2e3e9607c0..be584e8c4d 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/rules.mk +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/rules.mk @@ -1,2 +1,9 @@ -RGBLIGHT_STARTUP_ANIMATION = yes -HAPTIC_ENABLE = SOLENOID +RGBLIGHT_STARTUP_ANIMATION = yes +HAPTIC_ENABLE = SOLENOID +COMMAND_ENABLE = no +AUDIO_ENABLE = yes +TAP_DANCE_ENABLE = yes +UNICODE_ENABLE = yes +OLED_DRIVER_ENABLE = yes + +# DEBOUNCE_TYPE = sym_eager_pk diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/pointer_transport.c b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/pointer_transport.c index 003468c828..20216a21dd 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/pointer_transport.c +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/pointer_transport.c @@ -41,6 +41,10 @@ static uint16_t device_cpi = 0; static int8_t split_mouse_x = 0, split_mouse_y = 0; #endif +#ifdef OLED_DRIVER_ENABLE +# include "oled_driver.h" +#endif + #if defined(USE_I2C) # include "i2c_master.h" @@ -48,7 +52,16 @@ static int8_t split_mouse_x = 0, split_mouse_y = 0; typedef struct _I2C_slave_buffer_t { matrix_row_t smatrix[ROWS_PER_HAND]; - uint8_t backlight_level; +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods; + uint8_t weak_mods; +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods; +# endif +# endif +# ifdef BACKLIGHT_ENABLE + uint8_t backlight_level; +# endif # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) rgblight_syncinfo_t rgblight_sync; # endif @@ -58,9 +71,12 @@ typedef struct _I2C_slave_buffer_t { # ifdef WPM_ENABLE uint8_t current_wpm; # endif - int8_t mouse_x; - int8_t mouse_y; - uint16_t device_cpi; + int8_t mouse_x; + int8_t mouse_y; + uint16_t device_cpi; + bool oled_on; + layer_state_t t_layer_state; + layer_state_t t_default_layer_state; } I2C_slave_buffer_t; static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; @@ -68,11 +84,19 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re # define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level) # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, mmatrix) +# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) +# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) +# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) +# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) # define I2C_MOUSE_X_START offsetof(I2C_slave_buffer_t, mouse_x) # define I2C_MOUSE_Y_START offsetof(I2C_slave_buffer_t, mouse_y) # define I2C_MOUSE_DPI_START offsetof(I2C_slave_buffer_t, device_cpi) +# define I2C_OLED_ON_START offsetof(I2C_slave_buffent, oled_on) +# define I2C_LAYER_STATE_START offsetof(I2C_slave_buffent, t_layer_state) +# define I2C_DEFAULT_LAYER_STATE_START offsetof(I2C_slave_buffent, t_default_layer_state) + # define TIMEOUT 100 # ifndef SLAVE_I2C_ADDRESS @@ -127,13 +151,58 @@ bool transport_master(matrix_row_t matrix[]) { pointing_device_set_report(temp_report); if (device_cpi != i2c_buffer->device_cpi) { - if(i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_DPI_START, (void *)&device_cpi, sizeof(device_cpi), TIMEOUT) >= 0) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_DPI_START, (void *)&device_cpi, sizeof(device_cpi), TIMEOUT) >= 0) { i2c_buffer->device_cpi = device_cpi } } } # endif +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods = get_mods(); + if (real_mods != i2c_buffer->real_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_REAL_MODS_START, (void *)&real_mods, sizeof(real_mods), TIMEOUT) >= 0) { + i2c_buffer->real_mods = real_mods; + } + } + + uint8_t weak_mods = get_weak_mods(); + if (weak_mods != i2c_buffer->weak_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WEAK_MODS_START, (void *)&weak_mods, sizeof(weak_mods), TIMEOUT) >= 0) { + i2c_buffer->weak_mods = weak_mods; + } + } + +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods = get_oneshot_mods(); + if (oneshot_mods != i2c_buffer->oneshot_mods) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_ONESHOT_MODS_START, (void *)&oneshot_mods, sizeof(oneshot_mods), TIMEOUT) >= 0) { + i2c_buffer->oneshot_mods = oneshot_mods; + } + } +# endif +# endif + + if (layer_state != i2c_buffer->t_layer_state) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&layer_state, sizeof(layer_state), TIMEOUT) >= 0) { + i2c_buffer->t_layer_state = layer_state; + } + } + + if (default_layer_state != i2c_buffer->t_default_layer_state) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_DEFAULT_LAYER_STATE_START, (void *)&default_layer_state, sizeof(default_layer_state), TIMEOUT) >= 0) { + i2c_buffer->t_default_layer_state = default_layer_state; + } + } + +# ifdef OLED_DRIVER_ENABLE + if (is_oled_on() != i2c_buffer->oled_on) { + if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&is_oled_on(), sizeof(bool), TIMEOUT) >= 0) { + i2c_buffer->oled_on = is_oled_on(); + } + } +# endif + return true; } @@ -176,6 +245,29 @@ void transport_slave(matrix_row_t matrix[]) { } # endif + +# ifdef SPLIT_MODS_ENABLE + set_mods(i2c_buffer->real_mods); + set_weak_mods(i2c_buffer->weak_mods); +# ifndef NO_ACTION_ONESHOT + set_oneshot_mods(i2c_buffer->oneshot_mods); +# endif +# endif + + if (layer_state != i2c_buffer->t_layer_state) { + layer_state_set(i2c_buffer->t_layer_state); + } + if (default_layer_state != i2c_buffer->t_default_layer_state) { + default_layer_state_set(i2c_buffer->t_default_layer_state); + } + +# ifdef OLED_DRIVER_ENABLE + if (i2c_buffer->oled_on) { + oled_on(); + } else { + oled_off(); + } +# endif } void transport_master_init(void) { i2c_init(); } @@ -190,20 +282,33 @@ typedef struct _Serial_s2m_buffer_t { // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack matrix_row_t smatrix[ROWS_PER_HAND]; # ifdef ENCODER_ENABLE - uint8_t encoder_state[NUMBER_OF_ENCODERS]; + uint8_t encoder_state[NUMBER_OF_ENCODERS]; # endif - int8_t mouse_x; - int8_t mouse_y; + int8_t mouse_x; + int8_t mouse_y; } Serial_s2m_buffer_t; typedef struct _Serial_m2s_buffer_t { +# ifdef SPLIT_MODS_ENABLE + uint8_t real_mods; + uint8_t weak_mods; +# ifndef NO_ACTION_ONESHOT + uint8_t oneshot_mods; +# endif +# endif +# ifndef DISABLE_SYNC_TIMER + uint32_t sync_timer; +# endif # ifdef BACKLIGHT_ENABLE - uint8_t backlight_level; + uint8_t backlight_level; # endif # ifdef WPM_ENABLE - uint8_t current_wpm; + uint8_t current_wpm; # endif - uint16_t device_cpi; + uint16_t device_cpi; + bool oled_on; + layer_state_t t_layer_state; + layer_state_t t_default_layer_state; } Serial_m2s_buffer_t; # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) @@ -308,7 +413,15 @@ bool transport_master(matrix_row_t matrix[]) { # ifdef WPM_ENABLE // Write wpm to slave - serial_m2s_buffer.current_wpm = get_current_wpm(); + serial_m2s_buffer.current_wpm = get_current_wpm(); +# endif + +# ifdef SPLIT_MODS_ENABLE + serial_m2s_buffer.real_mods = get_mods(); + serial_m2s_buffer.weak_mods = get_weak_mods(); +# ifndef NO_ACTION_ONESHOT + serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); +# endif # endif # ifdef POINTING_DEVICE_ENABLE @@ -321,6 +434,12 @@ bool transport_master(matrix_row_t matrix[]) { } # endif + serial_m2s_buffer.t_layer_state = layer_state; + serial_m2s_buffer.t_default_layer_state = default_layer_state; +# ifdef OLED_DRIVER_ENABLE + serial_m2s_buffer.oled_on = is_oled_on(); +# endif + return true; } @@ -344,6 +463,14 @@ void transport_slave(matrix_row_t matrix[]) { set_current_wpm(serial_m2s_buffer.current_wpm); # endif +# ifdef SPLIT_MODS_ENABLE + set_mods(serial_m2s_buffer.real_mods); + set_weak_mods(serial_m2s_buffer.weak_mods); +# ifndef NO_ACTION_ONESHOT + set_oneshot_mods(serial_m2s_buffer.oneshot_mods); +# endif +# endif + # ifdef POINTING_DEVICE_ENABLE if (!is_keyboard_left()) { static uint16_t cpi; @@ -354,7 +481,20 @@ void transport_slave(matrix_row_t matrix[]) { serial_s2m_buffer.mouse_x = split_mouse_x; serial_s2m_buffer.mouse_y = split_mouse_y; } +# endif + if (layer_state != serial_m2s_buffer.t_layer_state) { + layer_state_set(serial_m2s_buffer.t_layer_state); + } + if (default_layer_state != serial_m2s_buffer.t_default_layer_state) { + default_layer_set(serial_m2s_buffer.t_default_layer_state); + } +# ifdef OLED_DRIVER_ENABLE + if (serial_m2s_buffer.oled_on) { + oled_on(); + } else { + oled_off(); + } # endif } -- cgit v1.2.3