@antha/input 0.0.5 → 0.0.7
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.
|
@@ -31,7 +31,8 @@ export declare enum MenuNavBinding {
|
|
|
31
31
|
/** Navigate to the next section in a menu. */
|
|
32
32
|
MenuSectionNext = "menu-section-next",
|
|
33
33
|
/** Navigate to the previous section in a menu. */
|
|
34
|
-
MenuSectionPrevious = "menu-section-previous"
|
|
34
|
+
MenuSectionPrevious = "menu-section-previous",
|
|
35
|
+
OpenPauseMenu = "open-pause-menu"
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Default menu nav bindings for {@link AnthaMenuNavMod}.
|
|
@@ -3,7 +3,7 @@ import { check } from '@augment-vir/assert';
|
|
|
3
3
|
import { getObjectTypedEntries, getObjectTypedValues } from '@augment-vir/common';
|
|
4
4
|
import { convertDuration } from 'date-vir';
|
|
5
5
|
import { NavController, NavDirection, NavValue } from 'device-navigation';
|
|
6
|
-
import {
|
|
6
|
+
import { KnownInput } from 'gamepad-type';
|
|
7
7
|
import { InputDirection } from '../raw-inputs/raw-input.js';
|
|
8
8
|
import { AnyGamepad, } from './player-bindings.js';
|
|
9
9
|
export { nav, navAttribute, NavController } from 'device-navigation';
|
|
@@ -38,6 +38,7 @@ export var MenuNavBinding;
|
|
|
38
38
|
MenuNavBinding["MenuSectionNext"] = "menu-section-next";
|
|
39
39
|
/** Navigate to the previous section in a menu. */
|
|
40
40
|
MenuNavBinding["MenuSectionPrevious"] = "menu-section-previous";
|
|
41
|
+
MenuNavBinding["OpenPauseMenu"] = "open-pause-menu";
|
|
41
42
|
})(MenuNavBinding || (MenuNavBinding = {}));
|
|
42
43
|
/**
|
|
43
44
|
* Default menu nav bindings for {@link AnthaMenuNavMod}.
|
|
@@ -49,7 +50,7 @@ export const defaultMenuNavBindings = {
|
|
|
49
50
|
{
|
|
50
51
|
deviceKey: AnyGamepad,
|
|
51
52
|
direction: InputDirection.Positive,
|
|
52
|
-
inputName:
|
|
53
|
+
inputName: KnownInput.DPadLeft,
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
deviceKey: 'keyboard',
|
|
@@ -71,7 +72,7 @@ export const defaultMenuNavBindings = {
|
|
|
71
72
|
{
|
|
72
73
|
deviceKey: AnyGamepad,
|
|
73
74
|
direction: InputDirection.Positive,
|
|
74
|
-
inputName:
|
|
75
|
+
inputName: KnownInput.DPadRight,
|
|
75
76
|
},
|
|
76
77
|
{
|
|
77
78
|
deviceKey: 'keyboard',
|
|
@@ -93,7 +94,7 @@ export const defaultMenuNavBindings = {
|
|
|
93
94
|
{
|
|
94
95
|
deviceKey: AnyGamepad,
|
|
95
96
|
direction: InputDirection.Positive,
|
|
96
|
-
inputName:
|
|
97
|
+
inputName: KnownInput.DPadUp,
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
100
|
deviceKey: 'keyboard',
|
|
@@ -115,7 +116,7 @@ export const defaultMenuNavBindings = {
|
|
|
115
116
|
{
|
|
116
117
|
deviceKey: AnyGamepad,
|
|
117
118
|
direction: InputDirection.Positive,
|
|
118
|
-
inputName:
|
|
119
|
+
inputName: KnownInput.DPadDown,
|
|
119
120
|
},
|
|
120
121
|
{
|
|
121
122
|
deviceKey: 'keyboard',
|
|
@@ -152,13 +153,7 @@ export const defaultMenuNavBindings = {
|
|
|
152
153
|
{
|
|
153
154
|
deviceKey: AnyGamepad,
|
|
154
155
|
direction: InputDirection.Positive,
|
|
155
|
-
|
|
156
|
-
inputName: 'X',
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
deviceKey: AnyGamepad,
|
|
160
|
-
direction: InputDirection.Positive,
|
|
161
|
-
inputName: 'A',
|
|
156
|
+
inputName: KnownInput.FaceAccept,
|
|
162
157
|
},
|
|
163
158
|
],
|
|
164
159
|
[MenuNavBinding.MenuExit]: [
|
|
@@ -170,13 +165,7 @@ export const defaultMenuNavBindings = {
|
|
|
170
165
|
{
|
|
171
166
|
deviceKey: AnyGamepad,
|
|
172
167
|
direction: InputDirection.Positive,
|
|
173
|
-
|
|
174
|
-
inputName: 'O',
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
deviceKey: AnyGamepad,
|
|
178
|
-
direction: InputDirection.Positive,
|
|
179
|
-
inputName: 'B',
|
|
168
|
+
inputName: KnownInput.FaceCancel,
|
|
180
169
|
},
|
|
181
170
|
],
|
|
182
171
|
[MenuNavBinding.MenuSectionNext]: [
|
|
@@ -193,7 +182,7 @@ export const defaultMenuNavBindings = {
|
|
|
193
182
|
{
|
|
194
183
|
deviceKey: AnyGamepad,
|
|
195
184
|
direction: InputDirection.Positive,
|
|
196
|
-
inputName:
|
|
185
|
+
inputName: KnownInput.R1,
|
|
197
186
|
},
|
|
198
187
|
],
|
|
199
188
|
[MenuNavBinding.MenuSectionPrevious]: [
|
|
@@ -210,7 +199,19 @@ export const defaultMenuNavBindings = {
|
|
|
210
199
|
{
|
|
211
200
|
deviceKey: AnyGamepad,
|
|
212
201
|
direction: InputDirection.Positive,
|
|
213
|
-
inputName:
|
|
202
|
+
inputName: KnownInput.L1,
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
[MenuNavBinding.OpenPauseMenu]: [
|
|
206
|
+
{
|
|
207
|
+
deviceKey: 'keyboard',
|
|
208
|
+
direction: InputDirection.Positive,
|
|
209
|
+
inputName: 'button-Escape',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
deviceKey: AnyGamepad,
|
|
213
|
+
direction: InputDirection.Positive,
|
|
214
|
+
inputName: KnownInput.Start,
|
|
214
215
|
},
|
|
215
216
|
],
|
|
216
217
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineAnthaMod } from '@antha/engine';
|
|
2
|
+
import { check } from '@augment-vir/assert';
|
|
2
3
|
import { mapObject, } from '@augment-vir/common';
|
|
3
4
|
import { html } from 'element-vir';
|
|
4
|
-
import { defaultGamepadLayouts, defaultGamepadModelMap, findMatchingGamepadLayout, findMatchingGamepadModel, } from 'gamepad-type';
|
|
5
|
+
import { defaultGamepadLayouts, defaultGamepadModelMap, findMatchingGamepadLayout, findMatchingGamepadModel, modelInputNameOverrides, } from 'gamepad-type';
|
|
5
6
|
import { InputDeviceHandler, isGamepadDeviceKey, } from 'input-device-handler';
|
|
6
7
|
import { AnthaRawInputDebug } from './antha-raw-input-debug.element.js';
|
|
7
8
|
import { calculateInputDirection, mapToSimpleDevicesMap, } from './raw-input.js';
|
|
@@ -82,6 +83,10 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
82
83
|
})
|
|
83
84
|
: undefined;
|
|
84
85
|
const mappedInputName = layout?.inputMappings[currentInput.inputName];
|
|
86
|
+
const modelInputName = getModelInputNameOverride({
|
|
87
|
+
mappedInputName,
|
|
88
|
+
gamepadModel: model?.gamepadModel,
|
|
89
|
+
});
|
|
85
90
|
const rawInput = {
|
|
86
91
|
mapped: {
|
|
87
92
|
deviceName: model?.gamepadModel || device.deviceName,
|
|
@@ -99,6 +104,9 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
99
104
|
if (mappedInputName) {
|
|
100
105
|
deviceInputs[mappedInputName] = rawInput;
|
|
101
106
|
}
|
|
107
|
+
if (modelInputName) {
|
|
108
|
+
deviceInputs[modelInputName] = rawInput;
|
|
109
|
+
}
|
|
102
110
|
deviceInputs[currentInput.inputName] = rawInput;
|
|
103
111
|
});
|
|
104
112
|
return {
|
|
@@ -111,3 +119,14 @@ export function readRawInputs(state, { msSinceLastExecute, }) {
|
|
|
111
119
|
currentDevices: mapToSimpleDevicesMap(currentDevices),
|
|
112
120
|
};
|
|
113
121
|
}
|
|
122
|
+
function getModelInputNameOverride({ mappedInputName, gamepadModel, }) {
|
|
123
|
+
if (!mappedInputName ||
|
|
124
|
+
!gamepadModel ||
|
|
125
|
+
!check.isKeyOf(gamepadModel, modelInputNameOverrides)) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const inputNameOverrides = modelInputNameOverrides[gamepadModel];
|
|
129
|
+
return check.isKeyOf(mappedInputName, inputNameOverrides)
|
|
130
|
+
? inputNameOverrides[mappedInputName]
|
|
131
|
+
: undefined;
|
|
132
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@augment-vir/common": "^31.73.1",
|
|
38
38
|
"date-vir": "^8.5.0",
|
|
39
39
|
"device-navigation": "^4.7.2",
|
|
40
|
-
"gamepad-type": "^2.0
|
|
40
|
+
"gamepad-type": "^2.1.0",
|
|
41
41
|
"input-device-handler": "^9.0.3",
|
|
42
42
|
"object-shape-tester": "^6.14.0",
|
|
43
43
|
"type-fest": "^5.7.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"istanbul-smart-text-reporter": "^1.1.5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@antha/engine": "^0.0.
|
|
55
|
+
"@antha/engine": "^0.0.7",
|
|
56
56
|
"element-vir": ">=26"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|