forked from eanders-ms/microcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessibility.ts
More file actions
154 lines (134 loc) · 3.96 KB
/
Copy pathaccessibility.ts
File metadata and controls
154 lines (134 loc) · 3.96 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
namespace accessibility {
/**
* Notifies web application about the current content.
*/
//% shim=TD_ID
export function setLiveContent(accessibilityMessage: accessibilityMessage) {
let serializedMessage = JSON.stringify({"type" : accessibilityMessage.type, "details" : accessibilityMessage.details})
control.simmessages.send(
"accessibility",
Buffer.fromUTF8(serializedMessage || "")
)
}
const liveStrings: { [id: string]: string } = {
//hud: "head over display",
//insertion_point: "empty tile",
//when: "add tile",
//do: "add tile",
S1: "always",
S2: "press",
S3: "accelerometer",
S4: "timer",
S5: "light",
S6: "temp",
S7: "radio receive",
S8: "microphone",
// filters for TID_SENSOR_PRESS
F0: "touch pin 0",
F1: "touch pin 1",
F2: "touch pin 2",
F3: "button A",
F4: "button B",
F5: "button A + B",
// F6
F7: "logo",
F8: "value 1",
F9: "value 2",
F10: "value 3",
F11: "value 4",
F12: "value 5",
F13: "1/4 second",
F14: "1 second",
F18: "1 random second",
F19: "5 seconds",
F15: "loud",
F16: "quiet",
F17: "accelerometer",
F17_shake: "shake",
F17_freefall: "freefall",
F17_tilt_up: "tilt up",
F17_tilt_down: "tilt down",
F17_tilt_left: "tilt left",
F17_tilt_right: "tilt right",
A1: "switch page",
A2: "sound emoji",
A3: "microphone",
A4: "music",
A5: "paint",
A6: "radio send",
A7: "random number",
M1: "page 1",
M2: "page 2",
M3: "page 3",
M4: "page 4",
M5: "page 5",
M6: "value 1",
M7: "value 2",
M8: "value 3",
M9: "value 4",
M10: "value 5",
M11: "on",
M12: "off",
M15: "LEDs",
M18: "music",
M19giggle: "giggle",
M19happy: "happy",
M19hello: "hello",
M19mysterious: "mysterious",
M19sad: "sad",
M19slide: "slide",
M19soaring: "soaring",
M19spring: "spring",
M19twinkle: "twinkle",
M19yawn: "yawn",
N0: "new program",
}
export function ariaToTooltip(ariaId: string) {
const s = (liveStrings[ariaId] || "").replace("_", " ")
return s.toUpperCase()
}
export interface accessibilityMessageDetals {
name: string
values: string[]
}
export interface accessibilityMessage {
type: string
details: accessibilityMessageDetals[]
}
export class textAccessibilityMessage implements accessibilityMessage {
private value: string
type: "text"
details: accessibilityMessageDetals[]
constructor(text: string) {
this.value = text
this.type = "text"
this.details = [{ name: "message", values: [this.value]}]
}
}
export class tileAccessibilityMessage implements accessibilityMessage {
private tileId: string
type: "tile"
details: accessibilityMessageDetals[]
constructor(tileId: string) {
this.tileId = tileId
this.type = "tile"
this.details = [{ name: "tileId", values: [this.tileId]}]
}
}
export class ruleAccessibilityMessage implements accessibilityMessage {
private dos: string[]
private whens: string[]
type: "rule"
details: accessibilityMessageDetals[]
constructor(dos: string[], whens: string[]) {
this.dos = dos
this.whens = whens
this.type = "rule";
this.details =
[
{ name: "whens", values: this.whens },
{ name: "dos", values: this.dos }
]
}
}
}