Numworks Epsilon
1.4.1
Graphing Calculator Operating System
events_modifier.cpp
Go to the documentation of this file.
1
#include <
ion.h
>
2
#include <
assert.h
>
3
4
namespace
Ion
{
5
namespace
Events {
6
7
static
ShiftAlphaStatus
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
8
9
ShiftAlphaStatus
shiftAlphaStatus
() {
10
return
sShiftAlphaStatus;
11
}
12
13
bool
isShiftActive
() {
14
return
sShiftAlphaStatus ==
ShiftAlphaStatus::Shift
|| sShiftAlphaStatus ==
ShiftAlphaStatus::ShiftAlpha
|| sShiftAlphaStatus ==
ShiftAlphaStatus::ShiftAlphaLock
;
15
}
16
17
bool
isAlphaActive
() {
18
return
sShiftAlphaStatus ==
ShiftAlphaStatus::Alpha
|| sShiftAlphaStatus ==
ShiftAlphaStatus::ShiftAlpha
|| sShiftAlphaStatus ==
ShiftAlphaStatus::AlphaLock
|| sShiftAlphaStatus ==
ShiftAlphaStatus::ShiftAlphaLock
;
19
;
20
}
21
22
void
setShiftAlphaStatus
(
ShiftAlphaStatus
s) {
23
sShiftAlphaStatus = s;
24
}
25
26
void
updateModifiersFromEvent
(Event e) {
27
assert
(e.isKeyboardEvent());
28
switch
(sShiftAlphaStatus) {
29
case
ShiftAlphaStatus::Default
:
30
if
(e ==
Shift
) {
31
sShiftAlphaStatus =
ShiftAlphaStatus::Shift
;
32
}
else
if
(e ==
Alpha
) {
33
sShiftAlphaStatus =
ShiftAlphaStatus::Alpha
;
34
}
35
break
;
36
case
ShiftAlphaStatus::Shift
:
37
if
(e ==
Shift
) {
38
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
39
}
else
if
(e ==
Alpha
) {
40
sShiftAlphaStatus =
ShiftAlphaStatus::ShiftAlpha
;
41
}
else
{
42
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
43
}
44
break
;
45
case
ShiftAlphaStatus::Alpha
:
46
if
(e ==
Shift
) {
47
sShiftAlphaStatus =
ShiftAlphaStatus::ShiftAlpha
;
48
}
else
if
(e ==
Alpha
) {
49
sShiftAlphaStatus =
ShiftAlphaStatus::AlphaLock
;
50
}
else
{
51
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
52
}
53
break
;
54
case
ShiftAlphaStatus::ShiftAlpha
:
55
if
(e ==
Shift
) {
56
sShiftAlphaStatus =
ShiftAlphaStatus::Alpha
;
57
}
else
if
(e ==
Alpha
) {
58
sShiftAlphaStatus =
ShiftAlphaStatus::ShiftAlphaLock
;
59
}
else
{
60
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
61
}
62
break
;
63
case
ShiftAlphaStatus::AlphaLock
:
64
if
(e ==
Shift
) {
65
sShiftAlphaStatus =
ShiftAlphaStatus::ShiftAlphaLock
;
66
}
else
if
(e ==
Alpha
) {
67
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
68
}
69
break
;
70
case
ShiftAlphaStatus::ShiftAlphaLock
:
71
if
(e ==
Shift
) {
72
sShiftAlphaStatus =
ShiftAlphaStatus::AlphaLock
;
73
}
else
if
(e ==
Alpha
) {
74
sShiftAlphaStatus =
ShiftAlphaStatus::Default
;
75
}
76
break
;
77
}
78
}
79
80
}
81
}
assert
#define assert(e)
Definition:
assert.h:9
Ion::Events::ShiftAlphaStatus
ShiftAlphaStatus
Definition:
events.h:41
ion.h
Ion::Events::ShiftAlphaStatus::ShiftAlpha
Ion::Events::ShiftAlphaStatus::ShiftAlphaLock
Ion::Events::ShiftAlphaStatus::Default
Ion::Events::updateModifiersFromEvent
void updateModifiersFromEvent(Event e)
Definition:
events_modifier.cpp:21
assert.h
Ion::Events::shiftAlphaStatus
ShiftAlphaStatus shiftAlphaStatus()
Definition:
events_modifier.cpp:6
Ion::Events::setShiftAlphaStatus
void setShiftAlphaStatus(ShiftAlphaStatus s)
Definition:
events_modifier.cpp:10
Ion::Events::isAlphaActive
bool isAlphaActive()
Definition:
events_modifier.cpp:17
Ion::Events::isShiftActive
bool isShiftActive()
Definition:
events_modifier.cpp:13
Ion::Events::ShiftAlphaStatus::Alpha
Ion::Events::ShiftAlphaStatus::Shift
Ion::Events::ShiftAlphaStatus::AlphaLock
Ion::Events::Alpha
constexpr Event Alpha
Definition:
events.h:72
Ion
Definition:
backlight.h:6
Ion::Events::Shift
constexpr Event Shift
Definition:
events.h:71
epsilon
ion
src
shared
events_modifier.cpp
Generated by
1.8.14