Skip to content

Commit

Permalink
added keyboard shortcuts for the cardputer only (pr3y#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
eadmaster committed Jul 25, 2024
1 parent bd0627d commit 1bab3ee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
32 changes: 31 additions & 1 deletion src/core/mykeyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "mykeyboard.h"
#include "powerSave.h"
#include "modules/others/TV-B-Gone.h"
#include "modules/rf/rf.h"
#include "modules/others/bad_usb.h"
#include "modules/others/webInterface.h"


/* Verifies Upper Btn to go to previous item */
Expand Down Expand Up @@ -83,6 +87,32 @@ bool checkEscPress(){
else { return false; }
}

bool checkAnyKeyPress() {
#if defined (CARDPUTER) // If any key is pressed, it'll jump the boot screen
Keyboard.update();
if(Keyboard.isPressed())
#else
if(digitalRead(SEL_BTN)==LOW) // If M5 key is pressed, it'll jump the boot screen
#endif
return true;
// else
return false;

}

void checkShortcutPress(){
// some shortctus to quickly starts apps
#if defined (CARDPUTER)
Keyboard.update();
if(Keyboard.isKeyPressed('i')) otherIRcodes();
if(Keyboard.isKeyPressed('r') || Keyboard.isKeyPressed('s')) otherRFcodes();
if(Keyboard.isKeyPressed('b')) usb_setup(); // badusb
if(Keyboard.isKeyPressed('w')) loopOptionsWebUi();
// TODO: other boards
// TODO: user-configurable
#endif
}

#ifndef STICK_C
/* Starts keyboard to type data */
String keyboard(String mytext, int maxSize, String msg) {
Expand Down Expand Up @@ -570,4 +600,4 @@ String keyboard(String mytext, int maxSize, String msg) {
}


#endif //If not STICK_C
#endif //If not STICK_C
6 changes: 5 additions & 1 deletion src/core/mykeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ bool checkPrevPress();

bool checkSelPress();

bool checkEscPress();
bool checkEscPress();

void checkShortcutPress();

bool checkAnyKeyPress();
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ void loop() {
delay(200);
}

checkShortcutPress(); // shortctus to quickly start apps without navigating the menus

if (checkPrevPress()) {
if(index==0) index = opt - 1;
else if(index>0) index--;
Expand Down

0 comments on commit 1bab3ee

Please sign in to comment.