@antha/input 0.6.0 → 0.6.1
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type EngineTime } from '@antha/engine';
|
|
1
2
|
import { type GamepadBrandMap, type GamepadLayout, type GamepadModelMap } from '@antha/gamepad-type';
|
|
2
3
|
import { type PartialWithUndefined, type SelectFrom, type SetRequired } from '@augment-vir/common';
|
|
3
4
|
import { InputDeviceHandler, type InputDeviceHandlerOptions, type InputDeviceKey } from 'input-device-handler';
|
|
@@ -29,8 +30,8 @@ export type AnthaReadRawInputModState = {
|
|
|
29
30
|
deviceHandler: Pick<InputDeviceHandler, 'readAllDevices'>;
|
|
30
31
|
rawInputs: RawInputs;
|
|
31
32
|
currentInputDevices: SimpleInputDevicesMap;
|
|
32
|
-
/**
|
|
33
|
-
|
|
33
|
+
/** The engine time when a timed input lock expires. */
|
|
34
|
+
inputDisableEndsAt: EngineTime | undefined;
|
|
34
35
|
/**
|
|
35
36
|
* If no model map is provided, the built-in defaults from
|
|
36
37
|
* [gamepad-type](https://www.npmjs.com/package/gamepad-type) are used. If a model map is
|
|
@@ -16,8 +16,13 @@ export function createAnthaReadRawInputMod(options = {}) {
|
|
|
16
16
|
modName: 'antha-read-raw-input',
|
|
17
17
|
initState: {
|
|
18
18
|
debugRawInputs: !!options.debugRawInputs,
|
|
19
|
+
inputDisableEndsAt: undefined,
|
|
19
20
|
},
|
|
20
|
-
execute({ state, msSinceLastExecute }) {
|
|
21
|
+
execute({ engine, state, msSinceLastExecute }) {
|
|
22
|
+
if (state.inputDisableEndsAt != undefined &&
|
|
23
|
+
state.inputDisableEndsAt <= engine.totalMs) {
|
|
24
|
+
state.inputDisableEndsAt = undefined;
|
|
25
|
+
}
|
|
21
26
|
if (!state.deviceHandler) {
|
|
22
27
|
state.deviceHandler =
|
|
23
28
|
options.deviceHandler ||
|
|
@@ -26,17 +31,17 @@ export function createAnthaReadRawInputMod(options = {}) {
|
|
|
26
31
|
startLoopImmediately: false,
|
|
27
32
|
});
|
|
28
33
|
}
|
|
29
|
-
if (state.
|
|
30
|
-
state.rawInputs = {};
|
|
31
|
-
state.currentInputDevices = {};
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
+
if (state.inputDisableEndsAt == undefined) {
|
|
34
35
|
const { currentDevices, rawInputs } = readRawInputs(state, {
|
|
35
36
|
msSinceLastExecute,
|
|
36
37
|
});
|
|
37
38
|
state.rawInputs = rawInputs;
|
|
38
39
|
state.currentInputDevices = currentDevices;
|
|
39
40
|
}
|
|
41
|
+
else {
|
|
42
|
+
state.rawInputs = {};
|
|
43
|
+
state.currentInputDevices = {};
|
|
44
|
+
}
|
|
40
45
|
if (state.debugRawInputs) {
|
|
41
46
|
return html `
|
|
42
47
|
<${AnthaRawInputDebug.assign({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:docs": "virmator docs check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@antha/gamepad-type": "^0.6.
|
|
36
|
+
"@antha/gamepad-type": "^0.6.1",
|
|
37
37
|
"@augment-vir/assert": "^32.2.3",
|
|
38
38
|
"@augment-vir/common": "^32.2.3",
|
|
39
39
|
"date-vir": "^9.1.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"istanbul-smart-text-reporter": "^1.1.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@antha/engine": "^0.6.
|
|
54
|
+
"@antha/engine": "^0.6.1",
|
|
55
55
|
"element-vir": ">=26"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|