Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

modify cardputer input for standalone mode

Geofb510b41e593
diff --git a/src/Inputs/CardputerInput.cpp b/src/Inputs/CardputerInput.cpp
index a934f345..a3b293b5 100644
--- a/src/Inputs/CardputerInput.cpp
+++ b/src/Inputs/CardputerInput.cpp
@@ -1,13 +1,22 @@
#ifdef DEVICE_CARDPUTER
-
#include "CardputerInput.h"
+
char CardputerInput::handler() {
while(true) {
// Update keyboard state
M5Cardputer.update();
+ if (M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_UP)) {
+ delay(50);
+ return CARDPUTER_SPECIAL_ARROW_UP;
+ }
+ if (M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_DOWN)) {
+ delay(50);
+ return CARDPUTER_SPECIAL_ARROW_DOWN;
+ }
+
if (!M5Cardputer.Keyboard.isChange()) {
continue;
}
@@ -18,21 +27,11 @@ char CardputerInput::handler() {
Keyboard_Class::KeysState status = M5Cardputer.Keyboard.keysState();
- if (status.enter) { // go to next menu
- return KEY_OK;
- }
- if (status.del) {
- return KEY_DEL;
- }
-
- if(M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_LEFT)) { // go back to previous menu
- return KEY_ARROW_LEFT;
- }
-
- if(M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_RIGHT)) { // go to next menu
- return KEY_ARROW_RIGHT;
- }
-
+ if (status.fn && M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_UP)) return KEY_ARROW_UP;
+ if (status.fn && M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_DOWN)) return KEY_ARROW_DOWN;
+ if (status.enter) return KEY_OK;
+ if (status.del) return KEY_DEL;
+
for (auto c : status.word) {
// Issue with %, the only key that requires 2 inputs to display
if (c == '%') {
@@ -61,39 +60,39 @@ void CardputerInput::waitPress() {
char CardputerInput::readChar() {
M5Cardputer.update();
-
- if (!M5Cardputer.Keyboard.isChange()) {
- return KEY_NONE;
+
+ // Special arrows for scrolling, can be long pressed
+ if (M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_UP)) {
+ delay(50); // debounce
+ return CARDPUTER_SPECIAL_ARROW_UP;
}
-
- if (!M5Cardputer.Keyboard.isPressed()) {
- return KEY_NONE;
+ if (M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_DOWN)) {
+ delay(50); // debounce
+ return CARDPUTER_SPECIAL_ARROW_DOWN;
}
+ // State change
+ if (!M5Cardputer.Keyboard.isChange()) return KEY_NONE;
+ if (!M5Cardputer.Keyboard.isPressed()) return KEY_NONE;
+
Keyboard_Class::KeysState status = M5Cardputer.Keyboard.keysState();
-
- if (status.enter) {
- return KEY_OK;
- }
- if (status.del) {
- return KEY_DEL;
- }
- if(M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_LEFT)) { // go back to previous menu
- return KEY_ARROW_LEFT;
- }
-
- if(M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_RIGHT)) { // go to next menu
- return KEY_ARROW_RIGHT;
- }
+ if (status.fn && M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_UP)) return KEY_ARROW_UP;
+ if (status.fn && M5Cardputer.Keyboard.isKeyPressed(KEY_ARROW_DOWN)) return KEY_ARROW_DOWN;
+ if (status.enter) return KEY_OK;
+ if (status.del) return KEY_DEL;
for (auto c : status.word) {
+ delay(50); // debounce
+
// Issue with %, the only key that requires 2 inputs to display
if (c == '%') {
return '5';
}
return c; // retourner le premier char saisi
}
+
+ return KEY_NONE;
}
#endif