forked from mirrors/qmk_firmware
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
7c4a012509
10 changed files with 46 additions and 80 deletions
|
@ -67,6 +67,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||||
|
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[MAC_FN] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
|
||||||
|
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[WIN_FN] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
|
|
1
keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk
Normal file
1
keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ENCODER_MAP_ENABLE = yes
|
|
@ -67,46 +67,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||||
#define ENCODERS 1
|
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
static uint8_t encoder_state[ENCODERS] = {0};
|
[MAC_FN] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
|
||||||
static keypos_t encoder_cw[ENCODERS] = {{ 8, 5 }};
|
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
static keypos_t encoder_ccw[ENCODERS] = {{ 7, 5 }};
|
[WIN_FN] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) },
|
||||||
|
|
||||||
void encoder_action_unregister(void) {
|
|
||||||
for (int index = 0; index < ENCODERS; ++index) {
|
|
||||||
if (encoder_state[index]) {
|
|
||||||
keyevent_t encoder_event = (keyevent_t) {
|
|
||||||
.key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index],
|
|
||||||
.pressed = false,
|
|
||||||
.time = (timer_read() | 1)
|
|
||||||
};
|
};
|
||||||
encoder_state[index] = 0;
|
|
||||||
action_exec(encoder_event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void encoder_action_register(uint8_t index, bool clockwise) {
|
|
||||||
keyevent_t encoder_event = (keyevent_t) {
|
|
||||||
.key = clockwise ? encoder_cw[index] : encoder_ccw[index],
|
|
||||||
.pressed = true,
|
|
||||||
.time = (timer_read() | 1)
|
|
||||||
};
|
|
||||||
encoder_state[index] = (clockwise ^ 1) | (clockwise << 1);
|
|
||||||
action_exec(encoder_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
encoder_action_unregister();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
|
||||||
encoder_action_register(index, clockwise);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
VIA_ENABLE = yes
|
VIA_ENABLE = yes
|
||||||
MOUSEKEY_ENABLE = no
|
ENCODER_MAP_ENABLE = yes
|
|
@ -72,6 +72,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||||
|
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[_FN1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
[_FN2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
[_FN3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KC_MISSION_CONTROL:
|
case KC_MISSION_CONTROL:
|
||||||
|
|
1
keyboards/keychron/q2/rev_0111/keymaps/default/rules.mk
Normal file
1
keyboards/keychron/q2/rev_0111/keymaps/default/rules.mk
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ENCODER_MAP_ENABLE = yes
|
|
@ -72,46 +72,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||||
#define ENCODERS 1
|
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
static uint8_t encoder_state[ENCODERS] = {0};
|
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
static keypos_t encoder_cw[ENCODERS] = {{ 8, 4 }};
|
[_FN1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
static keypos_t encoder_ccw[ENCODERS] = {{ 7, 4 }};
|
[_FN2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
[_FN3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
void encoder_action_register(uint8_t index, bool clockwise) {
|
|
||||||
keyevent_t encoder_event = (keyevent_t) {
|
|
||||||
.key = clockwise ? encoder_cw[index] : encoder_ccw[index],
|
|
||||||
.pressed = true,
|
|
||||||
.time = (timer_read() | 1)
|
|
||||||
};
|
};
|
||||||
encoder_state[index] = (clockwise ^ 1) | (clockwise << 1);
|
|
||||||
action_exec(encoder_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void encoder_action_unregister(void) {
|
|
||||||
for (int index = 0; index < ENCODERS; ++index) {
|
|
||||||
if (encoder_state[index]) {
|
|
||||||
keyevent_t encoder_event = (keyevent_t) {
|
|
||||||
.key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index],
|
|
||||||
.pressed = false,
|
|
||||||
.time = (timer_read() | 1)
|
|
||||||
};
|
|
||||||
encoder_state[index] = 0;
|
|
||||||
action_exec(encoder_event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
encoder_action_unregister();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
|
||||||
encoder_action_register(index, clockwise);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
VIA_ENABLE = yes
|
VIA_ENABLE = yes
|
||||||
MOUSEKEY_ENABLE = no
|
ENCODER_MAP_ENABLE = yes
|
|
@ -72,6 +72,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(ENCODER_MAP_ENABLE)
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||||
|
[MAC_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[WIN_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||||
|
[_FN1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
[_FN2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
[_FN3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KC_MISSION_CONTROL:
|
case KC_MISSION_CONTROL:
|
||||||
|
|
1
keyboards/keychron/q2/rev_0113/keymaps/default/rules.mk
Normal file
1
keyboards/keychron/q2/rev_0113/keymaps/default/rules.mk
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ENCODER_MAP_ENABLE = yes
|
Loading…
Reference in a new issue