@antha/input 0.0.8 → 0.1.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.
- package/README.md +51 -1
- package/dist/bindings/antha-menu-nav.mod.js +1 -1
- package/dist/elements/antha-keyboard.element.d.ts +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/raw-inputs/antha-read-raw-input.mod.d.ts +1 -1
- package/dist/raw-inputs/antha-read-raw-input.mod.js +1 -1
- package/package.json +15 -16
package/README.md
CHANGED
|
@@ -1,9 +1,59 @@
|
|
|
1
1
|
# @antha/input
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mods that read keyboard and gamepad input, then translate it into named player actions.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm i @antha/input
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
<!-- example-link: src/readme-examples/reading-input-bindings.example.ts -->
|
|
14
|
+
|
|
15
|
+
```TypeScript
|
|
16
|
+
import {AnthaEngine, defineAnthaMod} from '@antha/engine';
|
|
17
|
+
import {
|
|
18
|
+
type AnthaInputBindingsModState,
|
|
19
|
+
createAnthaInputBindingsMod,
|
|
20
|
+
createAnthaReadRawInputMod,
|
|
21
|
+
InputDirection,
|
|
22
|
+
} from '@antha/input';
|
|
23
|
+
|
|
24
|
+
enum GameAction {
|
|
25
|
+
Jump = 'jump',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type GameState = AnthaInputBindingsModState<GameAction>;
|
|
29
|
+
|
|
30
|
+
const engine = new AnthaEngine<GameState>({
|
|
31
|
+
initState: {
|
|
32
|
+
bindingAssignments: {
|
|
33
|
+
'1': {
|
|
34
|
+
[GameAction.Jump]: [
|
|
35
|
+
{
|
|
36
|
+
deviceKey: 'keyboard',
|
|
37
|
+
direction: InputDirection.Positive,
|
|
38
|
+
inputName: 'button-Space',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
mods: [
|
|
45
|
+
createAnthaReadRawInputMod(),
|
|
46
|
+
createAnthaInputBindingsMod<GameAction>(),
|
|
47
|
+
defineAnthaMod<GameState>({
|
|
48
|
+
modName: 'game-logic',
|
|
49
|
+
execute({state}) {
|
|
50
|
+
const jump = state.activeBindings?.['1']?.[GameAction.Jump];
|
|
51
|
+
|
|
52
|
+
return jump?.value ? `Jump strength: ${jump.value}` : undefined;
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
engine.startLoop();
|
|
59
|
+
```
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineAnthaMod } from '@antha/engine';
|
|
2
|
+
import { KnownInput } from '@antha/gamepad-type';
|
|
2
3
|
import { check } from '@augment-vir/assert';
|
|
3
4
|
import { getObjectTypedEntries, getObjectTypedValues } from '@augment-vir/common';
|
|
4
5
|
import { convertDuration } from 'date-vir';
|
|
5
6
|
import { NavController, NavDirection, NavValue } from 'device-navigation';
|
|
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';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
1
|
+
import { type PartialWithUndefined, type RequireExactlyOne } from '@augment-vir/common';
|
|
2
2
|
import { type NavController } from 'device-navigation';
|
|
3
|
-
import { type RequireExactlyOne } from 'type-fest';
|
|
4
3
|
/**
|
|
5
4
|
* Keypress details emitted by the `keyPress` event from {@link AnthaKeyboard}.
|
|
6
5
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export * from './elements/antha-keyboard.element.js';
|
|
|
7
7
|
export * from './raw-inputs/antha-raw-input-debug.element.js';
|
|
8
8
|
export * from './raw-inputs/antha-read-raw-input.mod.js';
|
|
9
9
|
export * from './raw-inputs/raw-input.js';
|
|
10
|
-
export * from 'gamepad-type';
|
|
10
|
+
export * from '@antha/gamepad-type';
|
|
11
11
|
export * from 'input-device-handler';
|
package/dist/index.js
CHANGED
|
@@ -7,5 +7,5 @@ export * from './elements/antha-keyboard.element.js';
|
|
|
7
7
|
export * from './raw-inputs/antha-raw-input-debug.element.js';
|
|
8
8
|
export * from './raw-inputs/antha-read-raw-input.mod.js';
|
|
9
9
|
export * from './raw-inputs/raw-input.js';
|
|
10
|
-
export * from 'gamepad-type';
|
|
10
|
+
export * from '@antha/gamepad-type';
|
|
11
11
|
export * from 'input-device-handler';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type GamepadBrandMap, type GamepadLayout, type GamepadModelMap } from '@antha/gamepad-type';
|
|
1
2
|
import { type PartialWithUndefined, type SelectFrom, type SetRequired } from '@augment-vir/common';
|
|
2
|
-
import { type GamepadBrandMap, type GamepadLayout, type GamepadModelMap } from 'gamepad-type';
|
|
3
3
|
import { InputDeviceHandler, type InputDeviceHandlerOptions, type InputDeviceKey } from 'input-device-handler';
|
|
4
4
|
import { type RawInput, type RawInputs, type SimpleInputDevicesMap } from './raw-input.js';
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineAnthaMod } from '@antha/engine';
|
|
2
|
+
import { defaultGamepadLayouts, defaultGamepadModelMap, findMatchingGamepadLayout, findMatchingGamepadModel, modelInputNameOverrides, } from '@antha/gamepad-type';
|
|
2
3
|
import { check } from '@augment-vir/assert';
|
|
3
4
|
import { mapObject, } from '@augment-vir/common';
|
|
4
5
|
import { html } from 'element-vir';
|
|
5
|
-
import { defaultGamepadLayouts, defaultGamepadModelMap, findMatchingGamepadLayout, findMatchingGamepadModel, modelInputNameOverrides, } from 'gamepad-type';
|
|
6
6
|
import { InputDeviceHandler, isGamepadDeviceKey, } from 'input-device-handler';
|
|
7
7
|
import { AnthaRawInputDebug } from './antha-raw-input-debug.element.js';
|
|
8
8
|
import { calculateInputDirection, mapToSimpleDevicesMap, } from './raw-input.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -33,26 +33,25 @@
|
|
|
33
33
|
"test:docs": "virmator docs check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@augment-vir/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"input-device-handler": "^9.0.
|
|
42
|
-
"object-shape-tester": "^6.14.
|
|
43
|
-
"
|
|
44
|
-
"vira": "^31.24.1"
|
|
36
|
+
"@antha/gamepad-type": "^0.1.1",
|
|
37
|
+
"@augment-vir/assert": "^32.2.2",
|
|
38
|
+
"@augment-vir/common": "^32.2.2",
|
|
39
|
+
"date-vir": "^9.0.0",
|
|
40
|
+
"device-navigation": "^4.7.3",
|
|
41
|
+
"input-device-handler": "^9.0.4",
|
|
42
|
+
"object-shape-tester": "^6.14.1",
|
|
43
|
+
"vira": "^31.29.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@augment-vir/test": "^
|
|
48
|
-
"@web/dev-server-esbuild": "^
|
|
49
|
-
"@web/test-runner": "^0.
|
|
50
|
-
"@web/test-runner-playwright": "^0.
|
|
51
|
-
"element-vir": "^26.17.
|
|
46
|
+
"@augment-vir/test": "^32.2.2",
|
|
47
|
+
"@web/dev-server-esbuild": "^2.0.0",
|
|
48
|
+
"@web/test-runner": "^1.0.0",
|
|
49
|
+
"@web/test-runner-playwright": "^1.0.0",
|
|
50
|
+
"element-vir": "^26.17.3",
|
|
52
51
|
"istanbul-smart-text-reporter": "^1.1.5"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
|
-
"@antha/engine": "^0.
|
|
54
|
+
"@antha/engine": "^0.1.1",
|
|
56
55
|
"element-vir": ">=26"
|
|
57
56
|
},
|
|
58
57
|
"engines": {
|