summaryrefslogtreecommitdiffstats
path: root/keyboards/keychron/q1
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-10-07 05:33:01 +0000
committerQMK Bot <hello@qmk.fm>2022-10-07 05:33:01 +0000
commit7c4a0125095bb78bfa322c599cdddfd3704acf17 (patch)
treeb1075a0ec018e6130bb86475ef250a8e4add83dc /keyboards/keychron/q1
parentc9d66bee707c8573b74dad45a1a457b172b249a2 (diff)
parentca2f9e4c8f483da93d7c082b4640832912bec76a (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/keychron/q1')
-rw-r--r--keyboards/keychron/q1/rev_0101/keymaps/default/keymap.c8
-rw-r--r--keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk1
-rw-r--r--keyboards/keychron/q1/rev_0101/keymaps/via/keymap.c45
-rw-r--r--keyboards/keychron/q1/rev_0101/keymaps/via/rules.mk2
4 files changed, 16 insertions, 40 deletions
diff --git a/keyboards/keychron/q1/rev_0101/keymaps/default/keymap.c b/keyboards/keychron/q1/rev_0101/keymaps/default/keymap.c
index 92806bf9fe..1038c1680d 100644
--- a/keyboards/keychron/q1/rev_0101/keymaps/default/keymap.c
+++ b/keyboards/keychron/q1/rev_0101/keymaps/default/keymap.c
@@ -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)
};
+#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) {
switch (keycode) {
diff --git a/keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk b/keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk
new file mode 100644
index 0000000000..a40474b4d5
--- /dev/null
+++ b/keyboards/keychron/q1/rev_0101/keymaps/default/rules.mk
@@ -0,0 +1 @@
+ENCODER_MAP_ENABLE = yes \ No newline at end of file
diff --git a/keyboards/keychron/q1/rev_0101/keymaps/via/keymap.c b/keyboards/keychron/q1/rev_0101/keymaps/via/keymap.c
index ad053648e5..2579b52fa4 100644
--- a/keyboards/keychron/q1/rev_0101/keymaps/via/keymap.c
+++ b/keyboards/keychron/q1/rev_0101/keymaps/via/keymap.c
@@ -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)
};
-#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
-
-#define ENCODERS 1
-static uint8_t encoder_state[ENCODERS] = {0};
-static keypos_t encoder_cw[ENCODERS] = {{ 8, 5 }};
-static keypos_t encoder_ccw[ENCODERS] = {{ 7, 5 }};
-
-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;
+#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) {
diff --git a/keyboards/keychron/q1/rev_0101/keymaps/via/rules.mk b/keyboards/keychron/q1/rev_0101/keymaps/via/rules.mk
index bee21da528..4253f570f0 100644
--- a/keyboards/keychron/q1/rev_0101/keymaps/via/rules.mk
+++ b/keyboards/keychron/q1/rev_0101/keymaps/via/rules.mk
@@ -1,2 +1,2 @@
VIA_ENABLE = yes
-MOUSEKEY_ENABLE = no \ No newline at end of file
+ENCODER_MAP_ENABLE = yes \ No newline at end of file