encoder works
This commit is contained in:
parent
78c2197d15
commit
22ffbeb99b
@ -83,3 +83,38 @@ bool oled_task_kb(void) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The encoder_update_user is a function.
|
||||||
|
* It'll be called by QMK every time you turn the encoder.
|
||||||
|
*
|
||||||
|
* The index parameter tells you which encoder was turned. If you only have
|
||||||
|
* one encoder, the index will always be zero.
|
||||||
|
*
|
||||||
|
* The clockwise parameter tells you the direction of the encoder. It'll be
|
||||||
|
* true when you turned the encoder clockwise, and false otherwise.
|
||||||
|
*/
|
||||||
|
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||||
|
/* With an if statement we can check which encoder was turned. */
|
||||||
|
if (index == 0) { /* First encoder */
|
||||||
|
/* And with another if statement we can check the direction. */
|
||||||
|
if (clockwise) {
|
||||||
|
/* This is where the actual magic happens: this bit of code taps on the
|
||||||
|
Page Down key. You can do anything QMK allows you to do here.
|
||||||
|
You'll want to replace these lines with the things you want your
|
||||||
|
encoders to do. */
|
||||||
|
tap_code(KC_PGDN);
|
||||||
|
} else {
|
||||||
|
/* And likewise for the other direction, this time Page Down is pressed. */
|
||||||
|
tap_code(KC_PGUP);
|
||||||
|
}
|
||||||
|
/* You can copy the code and change the index for every encoder you have. Most
|
||||||
|
keyboards will only have two, so this piece of code will suffice. */
|
||||||
|
} else if (index == 1) { /* Second encoder */
|
||||||
|
if (clockwise) {
|
||||||
|
tap_code(KC_UP);
|
||||||
|
} else {
|
||||||
|
tap_code(KC_DOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user