lenix 1.8.12 → 1.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/control.ts +103 -102
- package/package.json +1 -1
- package/shared/types.ts +3 -3
package/client/control.ts
CHANGED
|
@@ -13,119 +13,122 @@ const EVENTS = {
|
|
|
13
13
|
hold: IsControlPressed,
|
|
14
14
|
release: IsControlJustReleased,
|
|
15
15
|
released: IsControlReleased,
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
disabledPress: IsDisabledControlJustPressed,
|
|
18
|
+
disabledHold: IsDisabledControlPressed,
|
|
19
|
+
disabledRelease: IsDisabledControlJustReleased,
|
|
20
|
+
disabledReleased: IsDisabledControlReleased,
|
|
21
|
+
|
|
17
22
|
disable: DisableControlAction,
|
|
18
23
|
enable: EnableControlAction,
|
|
24
|
+
disableAll: DisableAllControlActions,
|
|
25
|
+
enableAll: EnableAllControlActions,
|
|
19
26
|
}
|
|
20
27
|
export const TYPES = {
|
|
21
28
|
player: 0,
|
|
22
29
|
camera: 1,
|
|
23
30
|
frontend: 2,
|
|
24
31
|
} as const
|
|
32
|
+
// TODO: add [PAUSE, END, SNAPSHOT, 0, i, j, o, LWIN, RWIN, NUMPAD[1-3], MULTIPLY, DECIMAL, DIVIDE, NUMPADEQUALS, NUMPADENTER, F[4, 13-24], NUMLOCK, SCROLL, RMENU, SEMICOLON, PLUS, SLASH, BACKSLASH, APOSTROPHE, , mouse axis, extra mouse bns, scrollwheels]
|
|
33
|
+
// NONE: [3, 5, 7, 28, 53, 65, 93, 94, 156, 193, 226, 227, 228, 230, 231, 239, 240, 247, 248, 258, 259, 260, 265, 292, 293, 294, 295]
|
|
25
34
|
export const CONTROLS = {
|
|
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
|
-
"K": [311],
|
|
106
|
-
"U": [303],
|
|
107
|
-
"F1": [288],
|
|
108
|
-
"F2": [289],
|
|
109
|
-
"F11": [344],
|
|
110
|
-
"SCROLLWHEEL BUTTON (PRESS)": [27, 348]
|
|
35
|
+
MOUSE_LEFT: [18, 24, 69, 92, 106, 122, 135, 142, 144, 176, 223, 229, 237, 257, 329, 346],
|
|
36
|
+
D: [9, 20, 35, 59, 64, 90, 134, 146, 148, 195, 218, 235, 266, 267, 278, 279, 339, 342],
|
|
37
|
+
S: [8, 31, 33, 72, 78, 88, 130, 139, 149, 151, 196, 219, 233, 268, 269, 302],
|
|
38
|
+
SPACE: [18, 22, 55, 76, 102, 143, 179, 203, 216, 255, 298, 321, 328, 353],
|
|
39
|
+
MOUSE_RIGHT: [25, 68, 70, 91, 114, 177, 222, 225, 238, 330, 331, 347],
|
|
40
|
+
E: [38, 46, 51, 54, 86, 103, 119, 153, 184, 206, 350, 351, 355, 356],
|
|
41
|
+
LCONTROL: [36, 60, 62, 132, 210, 224, 280, 281, 326, 341, 343],
|
|
42
|
+
LBRACKET: [39, 41, 43, 100, 116, 274, 275, 276, 277, 312],
|
|
43
|
+
X: [73, 105, 120, 154, 186, 252, 323, 337, 345, 354, 357],
|
|
44
|
+
LSHIFT: [21, 61, 131, 155, 209, 254, 340, 352],
|
|
45
|
+
Q: [44, 52, 85, 138, 141, 152, 205, 264],
|
|
46
|
+
W: [32, 71, 77, 87, 129, 136, 150, 232],
|
|
47
|
+
A: [34, 63, 89, 133, 147, 234, 338],
|
|
48
|
+
F: [23, 49, 75, 144, 145, 185, 251],
|
|
49
|
+
DELETE: [178, 214, 256, 296, 297],
|
|
50
|
+
RETURN: [18, 176, 191, 201, 215],
|
|
51
|
+
R: [45, 80, 140, 250, 263, 310],
|
|
52
|
+
TAB: [37, 192, 204, 211, 349],
|
|
53
|
+
NUMPAD6: [107, 109, 123, 125],
|
|
54
|
+
NUMPAD5: [110, 112, 126, 128],
|
|
55
|
+
RBRACKET: [40, 42, 197, 313],
|
|
56
|
+
ESCAPE: [177, 200, 202, 322],
|
|
57
|
+
C: [26, 79, 253, 319, 324],
|
|
58
|
+
LEFT: [174, 189, 190, 308],
|
|
59
|
+
CAPITAL: [137, 171, 217],
|
|
60
|
+
PAGEDOWN: [11, 207, 317],
|
|
61
|
+
MOUSE_MIDDLE: [27, 348],
|
|
62
|
+
UP: [27, 172, 188, 300],
|
|
63
|
+
PAGEUP: [10, 208, 316],
|
|
64
|
+
V: [0, 236, 320, 325],
|
|
65
|
+
DOWN: [173, 187, 299],
|
|
66
|
+
G: [47, 183, 58, 113],
|
|
67
|
+
H: [74, 101, 104, 304],
|
|
68
|
+
BACK: [177, 194, 202],
|
|
69
|
+
RIGHT: [175, 307],
|
|
70
|
+
SUBTRACT: [96, 315],
|
|
71
|
+
NUMPAD4: [108, 124],
|
|
72
|
+
NUMPAD8: [111, 127],
|
|
73
|
+
HOME: [212, 213],
|
|
74
|
+
Z: [20, 48],
|
|
75
|
+
B: [19, 305],
|
|
76
|
+
M: [244, 301],
|
|
77
|
+
T: [245, 309],
|
|
78
|
+
N: [249, 306],
|
|
79
|
+
LMENU: [19],
|
|
80
|
+
PERIOD: [81],
|
|
81
|
+
COMMA: [82],
|
|
82
|
+
EQUALS: [83],
|
|
83
|
+
MINUS: [84],
|
|
84
|
+
ADD: [97, 314],
|
|
85
|
+
NUMPAD7: [117],
|
|
86
|
+
NUMPAD9: [118],
|
|
87
|
+
INSERT: [121],
|
|
88
|
+
NUMPADENTER: [201],
|
|
89
|
+
GRAVE: [243],
|
|
90
|
+
1: [157],
|
|
91
|
+
2: [158],
|
|
92
|
+
6: [159],
|
|
93
|
+
3: [160],
|
|
94
|
+
7: [161],
|
|
95
|
+
8: [162],
|
|
96
|
+
9: [163],
|
|
97
|
+
4: [164],
|
|
98
|
+
5: [165],
|
|
99
|
+
L: [182],
|
|
100
|
+
P: [199],
|
|
101
|
+
Y: [246],
|
|
102
|
+
U: [303],
|
|
103
|
+
K: [311],
|
|
104
|
+
F1: [288],
|
|
105
|
+
F2: [289],
|
|
106
|
+
F3: [170],
|
|
107
|
+
F5: [166, 318, 327],
|
|
108
|
+
F6: [167],
|
|
109
|
+
F7: [168],
|
|
110
|
+
F8: [169],
|
|
111
|
+
F9: [56],
|
|
112
|
+
F10: [57],
|
|
113
|
+
F11: [344],
|
|
111
114
|
} as const
|
|
112
115
|
|
|
116
|
+
|
|
113
117
|
const binds = new Set<Bind>()
|
|
114
118
|
|
|
115
119
|
const on = ({
|
|
116
120
|
event,
|
|
117
121
|
key,
|
|
118
|
-
onEvent
|
|
122
|
+
onEvent,
|
|
119
123
|
type = 'player',
|
|
120
|
-
}:
|
|
124
|
+
}: Pick<Bind, 'key' | 'onEvent'> & {
|
|
125
|
+
event: Extract<Bind['event'], 'press' | 'hold' | 'release' | 'released' | 'disabledPress' | 'disabledHold' | 'disabledRelease' | 'disabledReleased'>
|
|
121
126
|
type?: Bind['type']
|
|
122
|
-
} & {
|
|
123
|
-
event: Exclude<Bind['event'], 'disable' | 'enable'>
|
|
124
127
|
}) => {
|
|
125
128
|
asserts(CONTROLS[key], `Could not find key<${key}>`)
|
|
126
129
|
|
|
127
130
|
const bind = {
|
|
128
|
-
event, key, onEvent
|
|
131
|
+
event, key, onEvent, type
|
|
129
132
|
}
|
|
130
133
|
binds.add(bind)
|
|
131
134
|
|
|
@@ -134,35 +137,33 @@ const on = ({
|
|
|
134
137
|
const disable = ({
|
|
135
138
|
key,
|
|
136
139
|
type = 'player',
|
|
137
|
-
}:
|
|
140
|
+
}: {
|
|
141
|
+
key: Bind['key'] | true
|
|
138
142
|
type?: Bind['type']
|
|
139
143
|
}) => {
|
|
140
|
-
asserts(CONTROLS[key], `Could not find key<${key}>`)
|
|
141
|
-
|
|
142
144
|
binds.add({
|
|
143
|
-
event: 'disable', key
|
|
145
|
+
event: key === true ? 'disableAll' : 'disable', key: 'A' /* anything */, onEvent: () => {}, type
|
|
144
146
|
})
|
|
145
147
|
}
|
|
146
148
|
const enable = ({
|
|
147
149
|
key,
|
|
148
150
|
type = 'player',
|
|
149
|
-
}:
|
|
151
|
+
}: {
|
|
152
|
+
key: Bind['key'] | true
|
|
150
153
|
type?: Bind['type']
|
|
151
154
|
}) => {
|
|
152
|
-
asserts(CONTROLS[key], `Could not find key<${key}>`)
|
|
153
|
-
|
|
154
155
|
binds.add({
|
|
155
|
-
event: 'enable', key
|
|
156
|
+
event: key === true ? 'enableAll' : 'enable', key: 'A' /* anything */, onEvent: () => {}, type
|
|
156
157
|
})
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
pool(() =>
|
|
160
|
-
for (const index of CONTROLS[key]) {
|
|
160
|
+
pool(() => {
|
|
161
|
+
for (const { event, key, onEvent: cb, type } of binds) for (const index of CONTROLS[key]) {
|
|
161
162
|
if (!EVENTS[event](TYPES[type], index, true)) continue
|
|
162
163
|
cb()
|
|
163
164
|
break
|
|
164
165
|
}
|
|
165
|
-
})
|
|
166
|
+
})
|
|
166
167
|
|
|
167
168
|
/**
|
|
168
169
|
* @beta This API is in beta. Use with caution.
|
package/package.json
CHANGED
package/shared/types.ts
CHANGED
|
@@ -3,17 +3,17 @@ import type { JsonValue } from "@lenix/lenix"
|
|
|
3
3
|
/**
|
|
4
4
|
* Three-dimensional coordinates plus heading.
|
|
5
5
|
*/
|
|
6
|
-
export type Vec4 =
|
|
6
|
+
export type Vec4 = [number, number, number, number]
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Three-dimensional coordinates.
|
|
10
10
|
*/
|
|
11
|
-
export type Vec3 =
|
|
11
|
+
export type Vec3 = [number, number, number]
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Two-dimensional coordinates.
|
|
15
15
|
*/
|
|
16
|
-
export type Vec2 =
|
|
16
|
+
export type Vec2 = [number, number, number]
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Typed event tuple containing an event id and positional parameters.
|