mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-31 23:21:06 +00:00
Added modifier key combination to allow keyboard shortcuts on t-deck (#3668)
* Updated kbI2cBase.cpp Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab). * Update kbI2cBase.cpp * fixed formatting issues in kbI2cBase.cpp * Removed keyboard shortcut code that doesnt work alt+t does not work on a t-deck so I removed it to avoid confusion. * Updated kbI2cBase.cpp Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab). * Update kbI2cBase.cpp * fixed formatting issues in kbI2cBase.cpp * Removed keyboard shortcut code that doesnt work alt+t does not work on a t-deck so I removed it to avoid confusion. * Changed modifier key to alt+c * Added screen brightness functionality Use modifier key with o(+) to increase brightness or i(-) to decrease. Currently there are 4 levels of brightness, (L, ML, MH, H). I would like to add a popup message to tell you the brightness. * Added checks to disable screen brightness changes on unsupported hardware * Setting the brightness code to work on only applicable devices * Added "function symbol" display to bottom right corner of screen. Now shows when mute is active or modifier key is pressed. Also fixed some other minor issues. * commented out a log * Reworked how modifier functions worked, added I wasn’t happy with my previous implementation, and I think it would have caused issues with other devices. This should work on all devices. * Added back the function I moved causing issue with versions * Fixed the version conflicts, everything seems to work fine now --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
This commit is contained in:
@@ -180,11 +180,75 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
(this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) {
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||
}
|
||||
// pass the pressed key
|
||||
// LOG_DEBUG("Canned message ANYKEY (%x)\n", event->kbchar);
|
||||
this->payload = event->kbchar;
|
||||
this->lastTouchMillis = millis();
|
||||
validEvent = true;
|
||||
|
||||
validEvent = false; // If key is normal than it will be set to true.
|
||||
|
||||
// Run modifier key code below, (doesnt inturrupt typing or reset to start screen page)
|
||||
switch (event->kbchar) {
|
||||
case 0x11: // make screen brighter
|
||||
if (screen)
|
||||
screen->increaseBrightness();
|
||||
LOG_DEBUG("increasing Screen Brightness\n");
|
||||
break;
|
||||
case 0x12: // make screen dimmer
|
||||
if (screen)
|
||||
screen->decreaseBrightness();
|
||||
LOG_DEBUG("Decreasing Screen Brightness\n");
|
||||
break;
|
||||
case 0xf1: // draw modifier (function) symbal
|
||||
if (screen)
|
||||
screen->setFunctionSymbal("Fn");
|
||||
break;
|
||||
case 0xf2: // remove modifier (function) symbal
|
||||
if (screen)
|
||||
screen->removeFunctionSymbal("Fn");
|
||||
break;
|
||||
// mute (switch off/toggle) external notifications on fn+m
|
||||
case 0xac:
|
||||
if (moduleConfig.external_notification.enabled == true) {
|
||||
if (externalNotificationModule->getMute()) {
|
||||
externalNotificationModule->setMute(false);
|
||||
showTemporaryMessage("Notifications \nEnabled");
|
||||
if (screen)
|
||||
screen->removeFunctionSymbal("M"); // remove the mute symbol from the bottom right corner
|
||||
} else {
|
||||
externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop
|
||||
externalNotificationModule->setMute(true);
|
||||
showTemporaryMessage("Notifications \nDisabled");
|
||||
if (screen)
|
||||
screen->setFunctionSymbal("M"); // add the mute symbol to the bottom right corner
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x9e: // toggle GPS like triple press does
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
if (gps != nullptr) {
|
||||
gps->toggleGpsMode();
|
||||
}
|
||||
if (screen)
|
||||
screen->forceDisplay();
|
||||
showTemporaryMessage("GPS Toggled");
|
||||
#endif
|
||||
break;
|
||||
case 0xaf: // fn+space send network ping like double press does
|
||||
service.refreshLocalMeshNode();
|
||||
if (service.trySendPosition(NODENUM_BROADCAST, true)) {
|
||||
showTemporaryMessage("Position \nUpdate Sent");
|
||||
} else {
|
||||
showTemporaryMessage("Node Info \nUpdate Sent");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// pass the pressed key
|
||||
// LOG_DEBUG("Canned message ANYKEY (%x)\n", event->kbchar);
|
||||
this->payload = event->kbchar;
|
||||
this->lastTouchMillis = millis();
|
||||
validEvent = true;
|
||||
break;
|
||||
}
|
||||
if (screen && (event->kbchar != 0xf1)) {
|
||||
screen->removeFunctionSymbal("Fn"); // remove modifier (function) symbal
|
||||
}
|
||||
}
|
||||
if (event->inputEvent == static_cast<char>(MATRIXKEY)) {
|
||||
LOG_DEBUG("Canned message event Matrix key pressed\n");
|
||||
@@ -390,8 +454,9 @@ int32_t CannedMessageModule::runOnce()
|
||||
}
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
||||
e.frameChanged = true;
|
||||
switch (this->payload) {
|
||||
case 0x08: // backspace
|
||||
switch (this->payload) { // code below all trigger the freetext window (where you type to send a message) or reset the
|
||||
// display back to the default window
|
||||
case 0x08: // backspace
|
||||
if (this->freetext.length() > 0) {
|
||||
if (this->cursor == this->freetext.length()) {
|
||||
this->freetext = this->freetext.substring(0, this->freetext.length() - 1);
|
||||
@@ -403,7 +468,6 @@ int32_t CannedMessageModule::runOnce()
|
||||
}
|
||||
break;
|
||||
case 0x09: // tab
|
||||
case 0x91: // alt+t for T-Deck that doesn't have a tab key
|
||||
if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL) {
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
} else if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NODE) {
|
||||
@@ -416,7 +480,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
case 0xb7: // right
|
||||
// already handled above
|
||||
break;
|
||||
// handle fn+s for shutdown
|
||||
// handle fn+s for shutdown
|
||||
case 0x9b:
|
||||
if (screen)
|
||||
screen->startShutdownScreen();
|
||||
@@ -430,37 +494,6 @@ int32_t CannedMessageModule::runOnce()
|
||||
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
|
||||
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||
break;
|
||||
case 0x9e: // toggle GPS like triple press does
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
if (gps != nullptr) {
|
||||
gps->toggleGpsMode();
|
||||
}
|
||||
if (screen)
|
||||
screen->forceDisplay();
|
||||
showTemporaryMessage("GPS Toggled");
|
||||
#endif
|
||||
break;
|
||||
// mute (switch off/toggle) external notifications on fn+m
|
||||
case 0xac:
|
||||
if (moduleConfig.external_notification.enabled == true) {
|
||||
if (externalNotificationModule->getMute()) {
|
||||
externalNotificationModule->setMute(false);
|
||||
showTemporaryMessage("Notifications \nEnabled");
|
||||
} else {
|
||||
externalNotificationModule->stopNow(); // this will turn off all GPIO and sounds and idle the loop
|
||||
externalNotificationModule->setMute(true);
|
||||
showTemporaryMessage("Notifications \nDisabled");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xaf: // fn+space send network ping like double press does
|
||||
service.refreshLocalMeshNode();
|
||||
if (service.trySendPosition(NODENUM_BROADCAST, true)) {
|
||||
showTemporaryMessage("Position \nUpdate Sent");
|
||||
} else {
|
||||
showTemporaryMessage("Node Info \nUpdate Sent");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (this->cursor == this->freetext.length()) {
|
||||
this->freetext += this->payload;
|
||||
@@ -476,6 +509,8 @@ int32_t CannedMessageModule::runOnce()
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (screen)
|
||||
screen->removeFunctionSymbal("Fn");
|
||||
}
|
||||
|
||||
this->lastTouchMillis = millis();
|
||||
@@ -787,4 +822,4 @@ String CannedMessageModule::drawWithCursor(String text, int cursor)
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user