MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / InputHandler

Function InputHandler

boards/marauder-v4og/interface.cpp:75–144  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

73** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
74**********************************************************************/
75void InputHandler(void) {
76 static unsigned long tm = 0;
77 if (launcherMillis() - tm > 200 || LongPress) {
78 if (touch.touched()) {
79 auto t = touch.getPointScaled();
80 auto t2 = touch.getPointRaw();
81 launcherConsolePrintf("\nRAW: Touch Pressed on x=%d, y=%d, rot: %d", t2.x, t2.y, rotation);
82 launcherConsolePrintf("\nBEF: Touch Pressed on x=%d, y=%d, rot: %d", t.x, t.y, rotation);
83 if (rotation == 3) {
84 t.y = (tftHeight + 20) - t.y;
85 t.x = tftWidth - t.x;
86 }
87 if (rotation == 0) {
88 int tmp = t.x;
89 t.x = tftWidth - t.y;
90 t.y = tmp;
91 }
92 if (rotation == 2) {
93 int tmp = t.x;
94 t.x = t.y;
95 t.y = (tftHeight + 20) - tmp;
96 }
97 launcherConsolePrintf("\nAFT: Touch Pressed on x=%d, y=%d, rot: %d\n", t.x, t.y, rotation);
98 tm = launcherMillis();
99 if (!wakeUpScreen()) AnyKeyPress = true;
100 else return;
101
102 // Touch point global variable
103 touchPoint.x = t.x;
104 touchPoint.y = t.y;
105 touchPoint.pressed = true;
106 touchHeatMap(touchPoint);
107 } else touchPoint.pressed = false;
108 }
109
110#ifdef WAVESENTRY
111 static int posDifference = 0;
112 static int lastPos = 0;
113 bool sel = !BTN_ACT;
114
115 int newPos = encoder->getPosition();
116 if (newPos != lastPos) {
117 posDifference += (newPos - lastPos);
118 lastPos = newPos;
119 }
120
121 if (launcherMillis() - tm < 200 && !LongPress) return;
122
123 sel = launcherGpioRead(ENCODER_KEY);
124
125 if (posDifference != 0 || sel == BTN_ACT) {
126 if (!wakeUpScreen()) AnyKeyPress = true;
127 else return;
128 }
129 if (posDifference > 0) {
130 PrevPress = true;
131 posDifference--;
132 }

Callers

nothing calls this directly

Calls 8

launcherMillisFunction · 0.85
launcherConsolePrintfFunction · 0.85
wakeUpScreenFunction · 0.85
touchHeatMapFunction · 0.85
launcherGpioReadFunction · 0.85
getPointRawMethod · 0.80
touchedMethod · 0.45
getPointScaledMethod · 0.45

Tested by

no test coverage detected