-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHoldInteraction.cpp
More file actions
53 lines (45 loc) · 1018 Bytes
/
HoldInteraction.cpp
File metadata and controls
53 lines (45 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "app/HoldInteraction.h"
namespace app
{
HoldInteractionAction applyHoldEvent(HoldInteractionState &state, HoldEvent event)
{
HoldInteractionAction action;
switch (event)
{
case HoldEvent::PressStarted:
state.active = true;
state.armed = false;
state.posted = false;
state.overlayDrawn = false;
action.resetOverlayProgress = true;
return action;
case HoldEvent::LongPressArmed:
if (state.active)
{
state.armed = true;
}
return action;
case HoldEvent::PressReleased:
if (state.active && state.armed && !state.posted)
{
state.posted = true;
action.postLongPress = true;
}
action.clearOverlay = state.overlayDrawn;
state.active = false;
state.armed = false;
state.overlayDrawn = false;
return action;
case HoldEvent::LongPress:
default:
return action;
}
}
void markHoldOverlayDrawn(HoldInteractionState &state)
{
if (state.active)
{
state.overlayDrawn = true;
}
}
} // namespace app