From ef2b368057427db3133437c1f3bb863f0f0af81a Mon Sep 17 00:00:00 2001 From: bullwinkle3000 <91431084+bullwinkle3000@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:22:42 -0500 Subject: [PATCH] OLED with trackball will display DPI and pointing device mode. --- .../trackball/6x7_wyld_track/info.json | 64 +++++------ .../6x7_wyld_track/keymaps/vial/keymap.c | 101 ++++++++---------- .../6x7_wyld_track/keymaps/vial/vial.json | 63 ++++------- .../wylderbuilds/trackball/trackball.c | 45 +++++--- .../wylderbuilds/trackball/trackball.h | 11 +- 5 files changed, 141 insertions(+), 143 deletions(-) diff --git a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/info.json b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/info.json index 68e701e3589..c733f6b335a 100644 --- a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/info.json +++ b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/info.json @@ -179,6 +179,16 @@ "x": 7, "y": 2 }, + { + "label": "6,1", + "x": 8.5, + "y": 2 + }, + { + "label": "13,3", + "x": 10.5, + "y": 2 + }, { "label": "9,0", "x": 12, @@ -390,54 +400,44 @@ "y": 5 }, { - "label": "13,0", - "x": 12.25, + "label": "6,4", + "x": 6.75, "y": 5.25 }, { - "label": "13,1", - "x": 12.25, - "y": 6.5 - }, - { - "label": "13,2", - "x": 11.25, - "y": 7.75 + "label": "6,5", + "x": 7.75, + "y": 5.25 }, { - "label": "13,3", - "x": 12.25, - "y": 7.75 + "label": "6,6", + "x": 8.75, + "y": 5.25 }, { - "label": "5,5", - "x": 6.75, - "y": 4.5 + "label": "13,0", + "x": 10.25, + "y": 5.25 }, { - "label": "5,6", - "x": 7.75, - "y": 4.5 + "label": "13,1", + "x": 11.25, + "y": 5.25 }, { - "label": "6,5", - "x": 4.5, - "y": 8.5 + "label": "13,2", + "x": 12.25, + "y": 5.25 }, { - "label": "6,6", - "x": 5.5, - "y": 8.5 + "label": "6,2", + "x": 7.75, + "y": 6.25 }, { "label": "6,3", - "x": 5.25, - "y": 9.5 - }, - { - "label": "6,4", - "x": 6.25, - "y": 9.5 + "x": 8.75, + "y": 6.25 } ] } diff --git a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/keymap.c b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/keymap.c index bfff86feac3..795715f9113 100644 --- a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/keymap.c +++ b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/keymap.c @@ -2,6 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H #include "6x7_wyld_track.h" +//#include +#include enum custom_layer { _QWERTY, _LOWER, @@ -19,11 +21,14 @@ enum wyld_keycodes { WYLD_DPI_RESET }; +//char[] wyld_dpi_setting = ""; +//char[] wyld_mouse_mode = ""; + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_6x7( KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10, KC_F11, KC_F12 , _______, DRGSCRL, KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_LBRC , KC_RBRC, - SNIPING, KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_HOME, KC_MUTE, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_QUOT , KC_BACKSLASH, + SNIPING, KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_MUTE, KC_HOME, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_QUOT , KC_BACKSLASH, KC_BTN3, KC_LSFT , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L ,KC_SCLN, KC_LSFT , DRGSCRL, KC_BTN1, KC_LCTL , KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT,KC_SLSH, KC_LCTL , KC_BTN1, KC_LBRC,KC_RBRC, KC_PLUS, KC_EQL, @@ -35,9 +40,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_LOWER] = LAYOUT_6x7( KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 ,KC_F10 ,KC_F11 ,KC_F12 , _______, _______, 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_HOME, KC_MUTE, KC_RBRC, KC_P7 , KC_P8 , KC_P9 ,_______,KC_PLUS, _______, + _______, _______,_______,_______,_______,_______,KC_LBRC, KC_MUTE, KC_HOME, 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, _______, - WYLD_DPI_DOWN,WYLD_DPI_UP,WYLD_DPI_RESET,_______,_______,SNIPING,DRGSCRL, _______, KC_P1 , KC_P2 , KC_P3 ,KC_EQL ,KC_UNDS, QK_BOOT, + DPI_RMOD,DPI_MOD,DPI_RST,_______,_______,SNIPING,DRGSCRL, _______, KC_P1 , KC_P2 , KC_P3 ,KC_EQL ,KC_UNDS, QK_BOOT, _______,KC_PSCR, _______, KC_P0, _______, KC_BTN1, KC_BTN2, _______, _______, _______, KC_DEL, KC_BTN3 @@ -47,7 +52,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_RAISE] = LAYOUT_6x7( _______,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_NUM,KC_INS ,KC_SCRL,KC_MUTE, _______, - _______,_______,KC_LEFT,KC_UP ,KC_DOWN,KC_RGHT,KC_LPRN, KC_HOME, KC_MUTE, KC_RPRN,KC_MPRV,KC_MPLY,KC_MNXT,_______,KC_VOLU, _______, + _______,_______,KC_LEFT,KC_UP ,KC_DOWN,KC_RGHT,KC_LPRN, KC_MUTE, KC_HOME, KC_RPRN,KC_MPRV,KC_MPLY,KC_MNXT,_______,KC_VOLU, _______, _______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,KC_VOLD, _______, QK_BOOT,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______,_______,_______, _______, _______,_______, KC_EQL ,_______, @@ -57,7 +62,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_MOUSE] = LAYOUT_6x7( _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, - _______,_______,_______,_______,_______,_______, _______, KC_HOME, KC_MUTE, _______,_______,_______,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______, _______, KC_MUTE, KC_HOME, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,SNIPING,DRGSCRL, _______,_______,_______,_______,_______,_______, _______, _______, _______, _______ ,_______, @@ -67,7 +72,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [4] = LAYOUT_6x7( _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, - _______,_______,_______,_______,_______,_______, _______,KC_HOME, KC_MUTE,_______,_______,_______,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______, _______,KC_MUTE, KC_HOME,_______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______,_______, _______, _______, _______, _______ ,_______, @@ -104,35 +109,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { set_auto_mouse_enable(!get_auto_mouse_enable()); } return false; // Skip all further processing of this key - case WYLD_DPI_UP: - if (record->event.pressed) { - increase_dpi(); - } - return false; - case WYLD_DPI_DOWN: - if (record->event.pressed) { - decrease_dpi(); - } - return false; - case WYLD_DPI_RESET: - if (record->event.pressed) { - reset_dpi(); - } - return false; - default: - return true; // Process all other keycodes normally } + return true; } #endif // ENCODERS #ifdef ENCODER_MAP_ENABLE const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { - [_QWERTY] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) }, - [_LOWER] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_RAISE] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_MOUSE] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [4] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) } + [_QWERTY] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) }, + [_LOWER] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) }, + [_RAISE] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) }, + [_MOUSE] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) }, + [4] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN) } }; //#endif #endif @@ -216,7 +205,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) { if (is_keyboard_left()) { return OLED_ROTATION_270; } - return OLED_ROTATION_0; + return OLED_ROTATION_270; } static const char PROGMEM wylderbuilds[] = { @@ -255,38 +244,29 @@ static const char PROGMEM wylderbuilds[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static void render_wylderbuilds(void) { - oled_write_raw_P(wylderbuilds, sizeof(wylderbuilds)); -} +//static void render_wylderbuilds(void) { +// oled_write_raw_P(wylderbuilds, sizeof(wylderbuilds)); +//} + +static char layer_names[5][8] = { + " BASE\n", + "LOWER\n", + "RAISE\n", + "MOUSE\n", + " XTRA\n" + }; bool oled_task_user(void) { - oled_set_cursor(0, 3); + char* layer_name = layer_names[get_highest_layer(layer_state)]; + if (is_keyboard_left()) { // oled_write_P(PSTR("Layer\n"), false); + oled_set_cursor(0, 3); + oled_write_P(PSTR(layer_name), false); - switch (get_highest_layer(layer_state)) { - case _QWERTY: - oled_write_P(PSTR(" BASE\n"), false); - break; - case _LOWER: - oled_write_P(PSTR("LOWER\n"), false); - break; - case _RAISE: - oled_write_P(PSTR("RAISE\n"), false); - break; - case _MOUSE: - oled_write_P(PSTR("MOUSE\n"), false); - break; - case 4: - oled_write_P(PSTR("XTRA\n"), false); - break; - default: - // Or use the write_ln shortcut over adding '\n' to the end of your string - oled_write_ln_P(PSTR("Undefined"), false); - } - oled_set_cursor(2, 7); + oled_set_cursor(2, 6); oled_write_P(PSTR("WPM "), false); - oled_set_cursor(1, 8); + oled_set_cursor(2, 7); oled_write(get_u8_str(get_current_wpm(), ' '), false); // Host Keyboard LED Status @@ -298,9 +278,20 @@ bool oled_task_user(void) { oled_write_P(led_state.scroll_lock ? PSTR("SCRLK \n") : PSTR(" \n"), false); } else { // write WPM to right OLED +#ifdef POINTING_DEVICE_ENABLE + char* mode = get_mouse_mode_string(); + uint16_t dpi = get_current_dpi(); + oled_set_cursor(2, 3); + oled_write_P(PSTR("DPI "), false); + oled_set_cursor(0, 5); + oled_write_P(PSTR(get_u16_str(dpi, ' ')), false); + oled_set_cursor(0, 9); + oled_write(PSTR(mode), false); +#else oled_set_cursor(0, 0); render_wylderbuilds(); oled_scroll_left(); +#endif } return false; diff --git a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/vial.json b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/vial.json index a8c6116dff0..b6c0ad29e48 100644 --- a/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/vial.json +++ b/keyboards/handwired/wylderbuilds/trackball/6x7_wyld_track/keymaps/vial/vial.json @@ -48,9 +48,10 @@ "1,4", "1,5", "1,6", - { - "x": 4 - }, + "0,0\n\n\n\n\n\n\n\n\ne", + "0,1\n\n\n\n\n\n\n\n\ne", + "1,0\n\n\n\n\n\n\n\n\ne", + "1,1\n\n\n\n\n\n\n\n\ne", "8,0", "8,1", "8,2", @@ -84,7 +85,15 @@ "2,5", "2,6", { - "x": 4 + "x": 0.5 + }, + "6,1", + { + "x": 1 + }, + "13,3", + { + "x": 0.5 }, "9,0", { @@ -189,50 +198,24 @@ [ { "y": -0.75, - "x": 12.25 - }, - "13,0" - ], - [ - { - "y": 0.25, - "x": 12.25 - }, - "13,1" - ], - [ - { - "y": 0.25, - "x": 11.25 - }, - "13,2", - "13,3" - ], - [ - { - "r": 7, - "y": -4.25, "x": 6.75 }, - "5,5", - "5,6" - ], - [ + "6,4", + "6,5", + "6,6", { - "r": -15, - "y": 3, - "x": 4.5 + "x": 0.5 }, - "6,5", - "6,6" + "13,0", + "13,1", + "13,2" ], [ { - "r": -13, - "x": 5.25 + "x": 7.75 }, - "6,3", - "6,4" + "6,2", + "6,3" ] ] } diff --git a/keyboards/handwired/wylderbuilds/trackball/trackball.c b/keyboards/handwired/wylderbuilds/trackball/trackball.c index 8be262cbaba..5aed02a4780 100644 --- a/keyboards/handwired/wylderbuilds/trackball/trackball.c +++ b/keyboards/handwired/wylderbuilds/trackball/trackball.c @@ -16,6 +16,7 @@ #include "trackball.h" #include "transactions.h" +#include #include #include "print.h" @@ -55,6 +56,9 @@ # define CHARYBDIS_POINTER_ACCELERATION_FACTOR 24 # endif // !CHARYBDIS_POINTER_ACCELERATION_FACTOR +# ifndef CHARYBDIS_MAX_DEFAULT_DPI_MULTIPLIER +# define CHARYBDIS_MAX_DEFAULT_DPI_MULTIPLIER 5 +# endif // !CHARYBDIS_POINTER_ACCELERATION_FACTOR typedef union { uint8_t raw; struct { @@ -118,6 +122,8 @@ static void step_pointer_default_dpi(charybdis_config_t* config, bool forward) { config->pointer_default_dpi += forward ? 1 : -1; if (config->pointer_default_dpi < 1) { config->pointer_default_dpi = 1; + } else if (config->pointer_default_dpi >= CHARYBDIS_MAX_DEFAULT_DPI_MULTIPLIER) { + config->pointer_default_dpi = CHARYBDIS_MAX_DEFAULT_DPI_MULTIPLIER; } maybe_update_pointing_device_cpi(config); } @@ -136,21 +142,10 @@ static void step_pointer_sniping_dpi(charybdis_config_t* config, bool forward) { maybe_update_pointing_device_cpi(config); } -void increase_dpi(void) { - step_pointer_default_dpi(&g_charybdis_config, true); -} - -void decrease_dpi(void) { - step_pointer_default_dpi(&g_charybdis_config, false); -} - -static void set_default_pointer_dpi(charybdis_config_t* config, uint8_t new_value) { - config->pointer_default_dpi = new_value; - maybe_update_pointing_device_cpi(config); -} void reset_dpi(void) { - set_default_pointer_dpi(&g_charybdis_config, (uint8_t) CHARYBDIS_MINIMUM_DEFAULT_DPI); + g_charybdis_config.pointer_default_dpi = 1; + write_charybdis_config_to_eeprom(&g_charybdis_config); } uint16_t charybdis_get_pointer_default_dpi(void) { return get_pointer_default_dpi(&g_charybdis_config); } @@ -316,6 +311,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { charybdis_cycle_pointer_default_dpi(/* forward= */ has_shift_mod()); } break; + case POINTER_DEFAULT_DPI_RESET: + if (record->event.pressed) { + reset_dpi(); + } + break; case POINTER_SNIPING_DPI_FORWARD: if (record->event.pressed) { // Step backward if shifted, forward otherwise. @@ -382,6 +382,25 @@ void keyboard_post_init_kb(void) { keyboard_post_init_user(); } + +uint16_t get_current_dpi(void) { + if (g_charybdis_config.is_sniping_enabled) { + return get_pointer_sniping_dpi(&g_charybdis_config); + } + return get_pointer_default_dpi(&g_charybdis_config); +} + + +char* get_mouse_mode_string(void) { + if (g_charybdis_config.is_dragscroll_enabled) { + return "DRAG "; + } + if (g_charybdis_config.is_sniping_enabled) { + return "SNIPE"; + } + return "POINT"; +} + void housekeeping_task_kb(void) { if (is_keyboard_master()) { // Keep track of the last state, so that we can tell if we need to propagate to slave diff --git a/keyboards/handwired/wylderbuilds/trackball/trackball.h b/keyboards/handwired/wylderbuilds/trackball/trackball.h index ea033a5c427..39aedb4641a 100644 --- a/keyboards/handwired/wylderbuilds/trackball/trackball.h +++ b/keyboards/handwired/wylderbuilds/trackball/trackball.h @@ -17,6 +17,7 @@ #pragma once #include "quantum.h" +#include //#warning ">>> PREPROCESSOR CHECKING trackball.h" @@ -24,6 +25,7 @@ enum charybdis_keycodes { POINTER_DEFAULT_DPI_FORWARD = QK_KB_0, POINTER_DEFAULT_DPI_REVERSE, + POINTER_DEFAULT_DPI_RESET, POINTER_SNIPING_DPI_FORWARD, POINTER_SNIPING_DPI_REVERSE, SNIPING_MODE, @@ -34,6 +36,7 @@ enum charybdis_keycodes { # define CHARYBDIS_SAFE_RANGE KEYMAP_SAFE_RANGE # define DPI_MOD POINTER_DEFAULT_DPI_FORWARD # define DPI_RMOD POINTER_DEFAULT_DPI_REVERSE +# define DPI_RST POINTER_DEFAULT_DPI_RESET # define S_D_MOD POINTER_SNIPING_DPI_FORWARD # define S_D_RMOD POINTER_SNIPING_DPI_REVERSE # define SNIPING SNIPING_MODE @@ -111,12 +114,14 @@ void check_drag_scroll(report_mouse_t* mouse_report); */ void charybdis_set_pointer_dragscroll_enabled(bool enable); -void increase_dpi(void); - -void decrease_dpi(void); +void set_default_pointer_dpi(void); void reset_dpi(void); +uint16_t get_current_dpi(void); + +char* get_mouse_mode_string(void); + #endif // POINTING_DEVICE_ENABLE void matrix_init_sub_kb(void);