Adjust qvex lynepad mouse keys to have on the fly accelleration changes as well as adjusted key layout that's more efficient and more usable

This commit is contained in:
kemonine 2020-11-13 13:56:43 -05:00
parent 2fc3dbc208
commit cf8237e523
9 changed files with 1395 additions and 1202 deletions

View file

@ -16,7 +16,8 @@
#pragma once #pragma once
// place overrides here #define TAPPING_TERM 200
#undef RGBLIGHT_ANIMATIONS #undef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LAYERS #define RGBLIGHT_LAYERS
@ -29,3 +30,4 @@
#define MOUSEKEY_WHEEL_INTERVAL 50 #define MOUSEKEY_WHEEL_INTERVAL 50
#define MOUSEKEY_WHEEL_TIME_TO_MAX 20 #define MOUSEKEY_WHEEL_TIME_TO_MAX 20
#define MOUSEKEY_WHEEL_MAX_SPEED 10 #define MOUSEKEY_WHEEL_MAX_SPEED 10
#define MK_COMBINED

View file

@ -15,6 +15,44 @@
*/ */
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
enum {
ACCEL_0 = 0,
ACCEL_1 = 1,
ACCEL_2 = 2,
};
static uint8_t acceleration_level = ACCEL_0;
void change_accel(void) {
acceleration_level++;
if (acceleration_level > ACCEL_2) {
acceleration_level = ACCEL_0;
}
}
// Custom key codes
enum {
ACCEL = SAFE_RANGE,
};
// Tap Dance declarations
enum {
TD_LAYER_BOOT,
};
void dance_layer_boot_finished(qk_tap_dance_state_t *state, void *user_data) {
if (state->count == 1) {
layer_on(1);
} else {
reset_keyboard();
}
}
// Tap Dance definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// Tap once for Escape, twice for Caps Lock
[TD_LAYER_BOOT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_layer_boot_finished, NULL),
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap (Base Layer) Default Layer /* Keymap (Base Layer) Default Layer
* |----------------------------| * |----------------------------|
@ -26,7 +64,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_Lynepad( [0] = LAYOUT_Lynepad(
LCTL(LALT(KC_TAB)), KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1, LCTL(LALT(KC_TAB)), KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1,
LGUI(KC_DOWN), KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, LGUI(KC_DOWN), KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT,
KC_MS_BTN3, TO(1), TO(2) ACCEL, TD(TD_LAYER_BOOT), KC_ESC
), ),
[1] = LAYOUT_Lynepad( [1] = LAYOUT_Lynepad(
LCTL(LALT(KC_2)), LCTL(KC_BSPACE), LSFT(KC_X), LSFT(KC_P), LCTL(LALT(KC_2)), LCTL(KC_BSPACE), LSFT(KC_X), LSFT(KC_P),
@ -80,6 +118,40 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return state; return state;
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case ACCEL:
if (record->event.pressed) {
switch(acceleration_level) {
case ACCEL_0:
register_code16(KC_ACL0);
break;
case ACCEL_1:
register_code16(KC_ACL1);
break;
case ACCEL_2:
register_code16(KC_ACL2);
break;
}
} else {
switch(acceleration_level) {
case ACCEL_0:
unregister_code16(KC_ACL0);
break;
case ACCEL_1:
unregister_code16(KC_ACL1);
break;
case ACCEL_2:
unregister_code16(KC_ACL2);
break;
}
}
return false; // Skip all further processing of this key
default:
return true; // Process all other keycodes normally
}
}
// Standard encoder functionality // Standard encoder functionality
void encoder_update_user(uint8_t index, bool clockwise) { void encoder_update_user(uint8_t index, bool clockwise) {
// Process encoder rotational movements // Process encoder rotational movements
@ -168,19 +240,15 @@ extern int16_t enc2RightPrev;
void matrix_scan_user(void) { void matrix_scan_user(void) {
if (enc1Center != enc1CenterPrev) { if (enc1Center != enc1CenterPrev) {
if (enc1Center < ENC_TILT_THRESHOLD) { if (enc1Center < ENC_TILT_THRESHOLD) {
register_code16(KC_ESC); if (layer_state_is(0)) {
change_accel();
} }
else {
unregister_code16(KC_ESC);
} }
} }
if (enc2Center != enc2CenterPrev) { if (enc2Center != enc2CenterPrev) {
if (enc2Center < ENC_TILT_THRESHOLD) { if (enc2Center < ENC_TILT_THRESHOLD) {
} }
else { else {
if (layer_state_is(0)) {
reset_keyboard();
}
} }
/* /*
* Encoder sets ALL values when center is pressed so bail out at this point\ * Encoder sets ALL values when center is pressed so bail out at this point\

View file

@ -34,9 +34,9 @@
"y": -0.5, "y": -0.5,
"a": 7 "a": 7
}, },
"Mouse Btn 3", "Accel",
"Layer 1", "Layer 1\n\n\n\nBoot",
"Layer 2" "Esc"
], ],
[ [
{ {
@ -46,6 +46,6 @@
"w": 2, "w": 2,
"h": 2 "h": 2
}, },
"Esc\n\n\n\n\n\n\n\n\n<i class='fa fa-retweet'></i> Wheel" "Accel Mode\n\n\n\n\n\n\n\n\n<i class='fa fa-retweet'></i> Wheel"
] ]
] ]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes

View file

@ -16,7 +16,8 @@
#pragma once #pragma once
// place overrides here #define TAPPING_TERM 200
#undef RGBLIGHT_ANIMATIONS #undef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LAYERS #define RGBLIGHT_LAYERS
@ -29,3 +30,4 @@
#define MOUSEKEY_WHEEL_INTERVAL 50 #define MOUSEKEY_WHEEL_INTERVAL 50
#define MOUSEKEY_WHEEL_TIME_TO_MAX 20 #define MOUSEKEY_WHEEL_TIME_TO_MAX 20
#define MOUSEKEY_WHEEL_MAX_SPEED 10 #define MOUSEKEY_WHEEL_MAX_SPEED 10
#define MK_COMBINED

View file

@ -15,6 +15,44 @@
*/ */
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
enum {
ACCEL_0 = 0,
ACCEL_1 = 1,
ACCEL_2 = 2,
};
static uint8_t acceleration_level = ACCEL_0;
void change_accel(void) {
acceleration_level++;
if (acceleration_level > ACCEL_2) {
acceleration_level = ACCEL_0;
}
}
// Custom key codes
enum {
ACCEL = SAFE_RANGE,
};
// Tap Dance declarations
enum {
TD_LAYER_BOOT,
};
void dance_layer_boot_finished(qk_tap_dance_state_t *state, void *user_data) {
if (state->count == 1) {
layer_on(1);
} else {
reset_keyboard();
}
}
// Tap Dance definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// Tap once for Escape, twice for Caps Lock
[TD_LAYER_BOOT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_layer_boot_finished, NULL),
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap (Base Layer) Default Layer /* Keymap (Base Layer) Default Layer
* |----------------------------| * |----------------------------|
@ -26,7 +64,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_Lynepad( [0] = LAYOUT_Lynepad(
LCTL(LALT(KC_TAB)), KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1, LCTL(LALT(KC_TAB)), KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1,
LGUI(KC_DOWN), KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, LGUI(KC_DOWN), KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT,
KC_MS_BTN3, TO(1), TO(2) ACCEL, TD(TD_LAYER_BOOT), KC_ESC
), ),
[1] = LAYOUT_Lynepad( [1] = LAYOUT_Lynepad(
LCTL(LALT(KC_2)), LCTL(KC_BSPACE), LSFT(KC_X), LSFT(KC_P), LCTL(LALT(KC_2)), LCTL(KC_BSPACE), LSFT(KC_X), LSFT(KC_P),
@ -80,6 +118,40 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return state; return state;
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case ACCEL:
if (record->event.pressed) {
switch(acceleration_level) {
case ACCEL_0:
register_code16(KC_ACL0);
break;
case ACCEL_1:
register_code16(KC_ACL1);
break;
case ACCEL_2:
register_code16(KC_ACL2);
break;
}
} else {
switch(acceleration_level) {
case ACCEL_0:
unregister_code16(KC_ACL0);
break;
case ACCEL_1:
unregister_code16(KC_ACL1);
break;
case ACCEL_2:
unregister_code16(KC_ACL2);
break;
}
}
return false; // Skip all further processing of this key
default:
return true; // Process all other keycodes normally
}
}
// Standard encoder functionality // Standard encoder functionality
void encoder_update_user(uint8_t index, bool clockwise) { void encoder_update_user(uint8_t index, bool clockwise) {
// Process encoder rotational movements // Process encoder rotational movements
@ -168,19 +240,15 @@ extern int16_t enc2RightPrev;
void matrix_scan_user(void) { void matrix_scan_user(void) {
if (enc1Center != enc1CenterPrev) { if (enc1Center != enc1CenterPrev) {
if (enc1Center < ENC_TILT_THRESHOLD) { if (enc1Center < ENC_TILT_THRESHOLD) {
register_code16(KC_ESC); if (layer_state_is(0)) {
change_accel();
} }
else {
unregister_code16(KC_ESC);
} }
} }
if (enc2Center != enc2CenterPrev) { if (enc2Center != enc2CenterPrev) {
if (enc2Center < ENC_TILT_THRESHOLD) { if (enc2Center < ENC_TILT_THRESHOLD) {
} }
else { else {
if (layer_state_is(0)) {
reset_keyboard();
}
} }
/* /*
* Encoder sets ALL values when center is pressed so bail out at this point\ * Encoder sets ALL values when center is pressed so bail out at this point\

View file

@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes