forked from madddi/go-vnc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
keys.go
247 lines (240 loc) · 2.66 KB
/
keys.go
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
// Package keys provides constants for all the keyboard inputs.
package keys
import "fmt"
// Key represents a VNC key press.
type Key uint32
//go:generate stringer -type=Key
// Keys is a slice of Key values.
type Keys []Key
var keymap = map[rune]Key{
'-': Minus,
'0': Digit0,
'1': Digit1,
'2': Digit2,
'3': Digit3,
'4': Digit4,
'5': Digit5,
'6': Digit6,
'7': Digit7,
'8': Digit8,
'9': Digit9,
}
// IntToKeys returns Keys that represent the key presses required to type an int.
func IntToKeys(v int) Keys {
k := Keys{}
for _, c := range fmt.Sprintf("%d", v) {
k = append(k, keymap[c])
}
return k
}
// Latin 1 (byte 3 = 0)
// ISO/IEC 8859-1 = Unicode U+0020..U+00FF
const (
Space Key = iota + 0x0020
Exclaim // exclamation mark
QuoteDbl
NumberSign
Dollar
Percent
Ampersand
Apostrophe
ParenLeft
ParenRight
Asterisk
Plus
Comma
Minus
Period
Slash
Digit0
Digit1
Digit2
Digit3
Digit4
Digit5
Digit6
Digit7
Digit8
Digit9
Colon
Semicolon
Less
Equal
Greater
Question
At
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
BracketLeft
Backslash
BracketRight
AsciiCircum
Underscore
Grave
SmallA
SmallB
SmallC
SmallD
SmallE
SmallF
SmallG
SmallH
SmallI
SmallJ
SmallK
SmallL
SmallM
SmallN
SmallO
SmallP
SmallQ
SmallR
SmallS
SmallT
SmallU
SmallV
SmallW
SmallX
SmallY
SmallZ
BraceLeft
Bar
BraceRight
AsciiTilde
)
const (
BackSpace Key = iota + 0xff08
Tab
Linefeed
Clear
_
Return
)
const (
Pause Key = iota + 0xff13
ScrollLock
SysReq
Escape Key = 0xff1b
Delete Key = 0xffff
)
const ( // Cursor control & motion.
Home Key = iota + 0xff50
Left
Up
Right
Down
PageUp
PageDown
End
Begin
)
const ( // Misc functions.
Select Key = 0xff60
Print
Execute
Insert
Undo
Redo
Menu
Find
Cancel
Help
Break
ModeSwitch Key = 0xff7e
NumLock Key = 0xff7f
)
const ( // Keypad functions.
KeypadSpace Key = 0xff80
KeypadTab Key = 0xff89
KeypadEnter Key = 0xff8d
)
const ( // Keypad functions cont.
KeypadF1 Key = iota + 0xff91
KeypadF2
KeypadF3
KeypadF4
KeypadHome
KeypadLeft
KeypadUp
KeypadRight
KeypadDown
KeypadPrior
KeypadPageUp
KeypadNext
KeypadPageDown
KeypadEnd
KeypadBegin
KeypadInsert
KeypadDelete
KeypadMultiply
KeypadAdd
KeypadSeparator
KeypadSubtract
KeypadDecimal
KeypadDivide
Keypad0
Keypad1
Keypad2
Keypad3
Keypad4
Keypad5
Keypad6
Keypad7
Keypad8
Keypad9
KeypadEqual Key = 0xffbd
)
const (
F1 Key = iota + 0xffbe
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
)
const (
ShiftLeft Key = iota + 0xffe1
ShiftRight
ControlLeft
ControlRight
CapsLock
ShiftLock
MetaLeft
MetaRight
AltLeft
AltRight
SuperLeft
SuperRight
HyperLeft
HyperRight
)