@antha/input 0.0.5 → 0.0.6

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.
@@ -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 { PredefinedGamepadBrand } from 'gamepad-type';
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';
@@ -49,7 +49,7 @@ export const defaultMenuNavBindings = {
49
49
  {
50
50
  deviceKey: AnyGamepad,
51
51
  direction: InputDirection.Positive,
52
- inputName: 'd-pad-left',
52
+ inputName: KnownInput.DPadLeft,
53
53
  },
54
54
  {
55
55
  deviceKey: 'keyboard',
@@ -71,7 +71,7 @@ export const defaultMenuNavBindings = {
71
71
  {
72
72
  deviceKey: AnyGamepad,
73
73
  direction: InputDirection.Positive,
74
- inputName: 'd-pad-right',
74
+ inputName: KnownInput.DPadRight,
75
75
  },
76
76
  {
77
77
  deviceKey: 'keyboard',
@@ -93,7 +93,7 @@ export const defaultMenuNavBindings = {
93
93
  {
94
94
  deviceKey: AnyGamepad,
95
95
  direction: InputDirection.Positive,
96
- inputName: 'd-pad-up',
96
+ inputName: KnownInput.DPadUp,
97
97
  },
98
98
  {
99
99
  deviceKey: 'keyboard',
@@ -115,7 +115,7 @@ export const defaultMenuNavBindings = {
115
115
  {
116
116
  deviceKey: AnyGamepad,
117
117
  direction: InputDirection.Positive,
118
- inputName: 'd-pad-down',
118
+ inputName: KnownInput.DPadDown,
119
119
  },
120
120
  {
121
121
  deviceKey: 'keyboard',
@@ -152,13 +152,7 @@ export const defaultMenuNavBindings = {
152
152
  {
153
153
  deviceKey: AnyGamepad,
154
154
  direction: InputDirection.Positive,
155
- gamepadBrand: PredefinedGamepadBrand.Sony,
156
- inputName: 'X',
157
- },
158
- {
159
- deviceKey: AnyGamepad,
160
- direction: InputDirection.Positive,
161
- inputName: 'A',
155
+ inputName: KnownInput.FaceAccept,
162
156
  },
163
157
  ],
164
158
  [MenuNavBinding.MenuExit]: [
@@ -170,13 +164,7 @@ export const defaultMenuNavBindings = {
170
164
  {
171
165
  deviceKey: AnyGamepad,
172
166
  direction: InputDirection.Positive,
173
- gamepadBrand: PredefinedGamepadBrand.Sony,
174
- inputName: 'O',
175
- },
176
- {
177
- deviceKey: AnyGamepad,
178
- direction: InputDirection.Positive,
179
- inputName: 'B',
167
+ inputName: KnownInput.FaceCancel,
180
168
  },
181
169
  ],
182
170
  [MenuNavBinding.MenuSectionNext]: [
@@ -193,7 +181,7 @@ export const defaultMenuNavBindings = {
193
181
  {
194
182
  deviceKey: AnyGamepad,
195
183
  direction: InputDirection.Positive,
196
- inputName: 'R1',
184
+ inputName: KnownInput.R1,
197
185
  },
198
186
  ],
199
187
  [MenuNavBinding.MenuSectionPrevious]: [
@@ -210,7 +198,7 @@ export const defaultMenuNavBindings = {
210
198
  {
211
199
  deviceKey: AnyGamepad,
212
200
  direction: InputDirection.Positive,
213
- inputName: 'L1',
201
+ inputName: KnownInput.L1,
214
202
  },
215
203
  ],
216
204
  };
@@ -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.5",
3
+ "version": "0.0.6",
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.2",
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.5",
55
+ "@antha/engine": "^0.0.6",
56
56
  "element-vir": ">=26"
57
57
  },
58
58
  "engines": {