MCPcopy Create free account
hub / github.com/BruceDevices/firmware / InputHandler

Function InputHandler

boards/m5stack-cardputer/interface.cpp:158–447  ·  view source on GitHub ↗

** Function: InputHandler ** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress **********************************************************************/

Source from the content-addressed store, hash-verified

156** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
157**********************************************************************/
158void InputHandler(void) {
159 static unsigned long tm = 0;
160 static unsigned long nextRepeatTime = 0;
161 static unsigned long prevRepeatTime = 0;
162 static unsigned long upRepeatTime = 0;
163 static unsigned long downRepeatTime = 0;
164
165 static bool sel = false;
166 static bool prev = false;
167 static bool next = false;
168 static bool up = false;
169 static bool down = false;
170 static bool esc = false;
171 static bool del = false;
172 static bool gui = false;
173 static bool alt = false;
174 static bool ctrl = false;
175
176 bool arrow_up = false;
177 bool arrow_dw = false;
178 bool arrow_ry = false;
179 bool arrow_le = false;
180 if (!UseTCA8418 && millis() - tm < 200 && !LongPress) return;
181
182 if (digitalRead(0) == LOW) { // GPIO0 button, shoulder button
183 tm = millis();
184 if (!wakeUpScreen()) yield();
185 else return;
186 SelPress = true;
187 AnyKeyPress = true;
188 }
189
190 if (UseTCA8418) {
191 bool keyEventHandled = false;
192 bool nextPulse = false;
193 bool prevPulse = false;
194 bool upPulse = false;
195 bool downPulse = false;
196 bool delPulse = false;
197 bool keyPulse = false;
198 keyStroke key;
199
200 if (kb_interrupt || digitalRead(11) == LOW) {
201 if (!kb_interrupt && digitalRead(11) == LOW) {
202 detachInterrupt(digitalPinToInterrupt(11));
203 attachInterruptArg(digitalPinToInterrupt(11), gpio_isr_handler, nullptr, CHANGE);
204 Serial.println("Forcing keyboard interrupt, Restoring Interruptions.");
205 kb_interrupt = true;
206 }
207
208 while (tca.available() > 0) {
209 int keyEvent = tca.getEvent();
210 bool pressed = (keyEvent & 0x80); // Bit 7: 1 Pressed, 0 Released
211 uint8_t value = keyEvent & 0x7F; // Bits 0-6: key value
212
213 uint8_t row, col;
214 mapRawKeyToPhysical(value, row, col);
215 if (row >= 4 || col >= 14) continue;

Callers

nothing calls this directly

Calls 12

millisFunction · 0.85
wakeUpScreenFunction · 0.85
mapRawKeyToPhysicalFunction · 0.85
handleSpecialKeysFunction · 0.70
getKeyCharFunction · 0.70
printlnMethod · 0.45
availableMethod · 0.45
ClearMethod · 0.45
writeRegisterMethod · 0.45
readRegisterMethod · 0.45
updateMethod · 0.45
isPressedMethod · 0.45

Tested by

no test coverage detected