@antha/input 0.9.0 → 0.10.0
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.
|
@@ -65,6 +65,7 @@ export function createAnthaInputBindingsMod(options = {}) {
|
|
|
65
65
|
const gamepadInputDeviceKeys = getEnumValues(GamepadInputDeviceKey);
|
|
66
66
|
function filterRawInput(entry, binding) {
|
|
67
67
|
return (entry?.direction === binding.direction &&
|
|
68
|
+
!entry.isIgnoredByConsumer &&
|
|
68
69
|
(binding.gamepadBrand ? binding.gamepadBrand === entry.mapped.gamepadBrand : true));
|
|
69
70
|
}
|
|
70
71
|
function readPlayerBindings({ bindingsMap, activeBindingsMap, rawInputs, msSinceLastExecute, gamepadKeyMap, }) {
|
|
@@ -20,6 +20,7 @@ export type AnthaReadRawInputModOptions = PartialWithUndefined<{
|
|
|
20
20
|
*/
|
|
21
21
|
deviceHandlerOptions: Omit<InputDeviceHandlerOptions, 'startLoopImmediately'>;
|
|
22
22
|
debugRawInputs: AnthaReadRawInputModState['debugRawInputs'];
|
|
23
|
+
startRawInputConsumer: AnthaReadRawInputModState['rawInputConsumer'];
|
|
23
24
|
}>;
|
|
24
25
|
/**
|
|
25
26
|
* All state used by and set by `createAnthaReadRawInputMod`.
|
|
@@ -29,6 +30,8 @@ export type AnthaReadRawInputModOptions = PartialWithUndefined<{
|
|
|
29
30
|
export type AnthaReadRawInputModState = {
|
|
30
31
|
deviceHandler: Pick<InputDeviceHandler, 'readAllDevices'>;
|
|
31
32
|
rawInputs: RawInputs;
|
|
33
|
+
/** Identifies the part of the game that owns newly started raw inputs. */
|
|
34
|
+
rawInputConsumer: string | undefined;
|
|
32
35
|
currentInputDevices: SimpleInputDevicesMap;
|
|
33
36
|
/** The engine time when a timed input lock expires. */
|
|
34
37
|
inputDisableEndsAt: EngineTime | undefined;
|
|
@@ -78,6 +81,7 @@ export type AnthaReadRawInputMod = ReturnType<typeof createAnthaReadRawInputMod>
|
|
|
78
81
|
*/
|
|
79
82
|
export declare function readRawInputs(state: SetRequired<SelectFrom<Partial<AnthaReadRawInputModState>, {
|
|
80
83
|
rawInputs: true;
|
|
84
|
+
rawInputConsumer: true;
|
|
81
85
|
deviceHandler: true;
|
|
82
86
|
gamepadLayouts: true;
|
|
83
87
|
gamepadBrandMap: true;
|
|
@@ -17,6 +17,7 @@ export function createAnthaReadRawInputMod(options = {}) {
|
|
|
17
17
|
initState: {
|
|
18
18
|
debugRawInputs: !!options.debugRawInputs,
|
|
19
19
|
inputDisableEndsAt: undefined,
|
|
20
|
+
rawInputConsumer: options.startRawInputConsumer,
|
|
20
21
|
},
|
|
21
22
|
execute({ engine, state, msSinceLastExecute }) {
|
|
22
23
|
if (state.inputDisableEndsAt != undefined &&
|
|
@@ -71,6 +72,9 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
71
72
|
const previousRawInput = potentialPreviousRawInput?.direction === direction
|
|
72
73
|
? potentialPreviousRawInput
|
|
73
74
|
: undefined;
|
|
75
|
+
const consumedBy = previousRawInput
|
|
76
|
+
? previousRawInput.consumedBy
|
|
77
|
+
: state.rawInputConsumer;
|
|
74
78
|
const duration = {
|
|
75
79
|
milliseconds: previousRawInput
|
|
76
80
|
? Math.round(previousRawInput.duration.milliseconds + msSinceLastExecute)
|
|
@@ -100,7 +104,7 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
100
104
|
gamepadModel: model?.gamepadModel,
|
|
101
105
|
});
|
|
102
106
|
const rawInput = {
|
|
103
|
-
consumedBy
|
|
107
|
+
consumedBy,
|
|
104
108
|
mapped: {
|
|
105
109
|
deviceName: model?.gamepadModel || device.deviceName,
|
|
106
110
|
gamepadBrand: model?.gamepadBrand,
|
|
@@ -113,6 +117,9 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
113
117
|
duration,
|
|
114
118
|
inputName: currentInput.inputName,
|
|
115
119
|
inputValue: currentInput.inputValue,
|
|
120
|
+
isIgnoredByConsumer: !!state.rawInputConsumer &&
|
|
121
|
+
!!consumedBy &&
|
|
122
|
+
consumedBy !== state.rawInputConsumer,
|
|
116
123
|
};
|
|
117
124
|
if (mappedInputName) {
|
|
118
125
|
deviceInputs[mappedInputName] = rawInput;
|
|
@@ -26,6 +26,8 @@ export declare function calculateInputDirection(inputValue: number): InputDirect
|
|
|
26
26
|
export type RawInput = Omit<InputValueWrapper<InputDeviceKey, any>, 'details'> & {
|
|
27
27
|
/** An identifier set by a game when it claims this input. */
|
|
28
28
|
consumedBy: string | undefined;
|
|
29
|
+
/** True when this input belongs to a different raw input consumer. */
|
|
30
|
+
isIgnoredByConsumer: boolean;
|
|
29
31
|
mapped: SelectFrom<InputValueWrapper<InputDeviceKey, any>, {
|
|
30
32
|
/**
|
|
31
33
|
* `deviceName` is mapped by `gamepadModelMap`. If no mapping exists, this will always
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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.
|
|
36
|
+
"@antha/gamepad-type": "^0.10.0",
|
|
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.
|
|
54
|
+
"@antha/engine": "^0.10.0",
|
|
55
55
|
"element-vir": ">=26"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|