Skip to content

Commit

Permalink
feat: rotary encoder macro support
Browse files Browse the repository at this point in the history
  • Loading branch information
DriftKingTW committed Dec 17, 2024
1 parent 306dd44 commit a16d617
Showing 1 changed file with 74 additions and 12 deletions.
86 changes: 74 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,26 +624,88 @@ void encoderTask(void *pvParameters) {

if (direction.equals("CCW")) {
resetIdle();
// USB mode
if (isUsbMode && !isOutputLocked) {
usbKeyboard.release(onboardRotaryEncoders[0].rotaryCCW);
usbKeyboard.write(onboardRotaryEncoders[0].rotaryCCW);
if (onboardRotaryEncoders[0].rotaryCCWInfo.startsWith(
"MACRO_")) {
size_t index =
onboardRotaryEncoders[0]
.rotaryCCWInfo
.substring(6, sizeof(onboardRotaryEncoders[0]
.rotaryCCWInfo) -
1)
.toInt();
macroPress(macroMap[index]);
} else {
usbKeyboard.release(onboardRotaryEncoders[0].rotaryCCW);
usbKeyboard.write(onboardRotaryEncoders[0].rotaryCCW);
}
// BLE mode
} else if (!isOutputLocked) {
bleKeyboard.release(onboardRotaryEncoders[0].rotaryCCW);
bleKeyboard.write(onboardRotaryEncoders[0].rotaryCCW);
if (onboardRotaryEncoders[0].rotaryCCWInfo.startsWith(
"MACRO_")) {
size_t index =
onboardRotaryEncoders[0]
.rotaryCCWInfo
.substring(6, sizeof(onboardRotaryEncoders[0]
.rotaryCCWInfo) -
1)
.toInt();
macroPress(macroMap[index]);
} else {
bleKeyboard.release(onboardRotaryEncoders[0].rotaryCCW);
bleKeyboard.write(onboardRotaryEncoders[0].rotaryCCW);
}
}
if (!onboardRotaryEncoders[0].rotaryCCWInfo.startsWith(
"MACRO_")) {
updateKeyInfo = true;
currentKeyInfo = onboardRotaryEncoders[0].rotaryCCWInfo;
}
updateKeyInfo = true;
currentKeyInfo = onboardRotaryEncoders[0].rotaryCCWInfo;
} else if (direction.equals("CW")) {
resetIdle();
// USB mode
if (isUsbMode && !isOutputLocked) {
usbKeyboard.release(onboardRotaryEncoders[0].rotaryCW);
usbKeyboard.write(onboardRotaryEncoders[0].rotaryCW);
if (onboardRotaryEncoders[0].rotaryCWInfo.startsWith(
"MACRO_")) {
size_t index =
onboardRotaryEncoders[0]
.rotaryCWInfo
.substring(
6,
sizeof(
onboardRotaryEncoders[0].rotaryCWInfo) -
1)
.toInt();
macroPress(macroMap[index]);
} else {
usbKeyboard.release(onboardRotaryEncoders[0].rotaryCW);
usbKeyboard.write(onboardRotaryEncoders[0].rotaryCW);
}
// BLE mode
} else if (!isOutputLocked) {
bleKeyboard.release(onboardRotaryEncoders[0].rotaryCW);
bleKeyboard.write(onboardRotaryEncoders[0].rotaryCW);
if (onboardRotaryEncoders[0].rotaryCWInfo.startsWith(
"MACRO_")) {
size_t index =
onboardRotaryEncoders[0]
.rotaryCWInfo
.substring(
6,
sizeof(
onboardRotaryEncoders[0].rotaryCWInfo) -
1)
.toInt();
macroPress(macroMap[index]);
} else {
bleKeyboard.release(onboardRotaryEncoders[0].rotaryCW);
bleKeyboard.write(onboardRotaryEncoders[0].rotaryCW);
}
}
if (!onboardRotaryEncoders[0].rotaryCWInfo.startsWith(
"MACRO_")) {
updateKeyInfo = true;
currentKeyInfo = onboardRotaryEncoders[0].rotaryCWInfo;
}
updateKeyInfo = true;
currentKeyInfo = onboardRotaryEncoders[0].rotaryCWInfo;
}
}

Expand Down

0 comments on commit a16d617

Please sign in to comment.