@benev/tact 0.1.0-2 → 0.1.0-4
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 +205 -133
- package/package.json +8 -7
- package/s/core/{port → bindings}/action.ts +15 -5
- package/s/core/bindings/parts/defaults.ts +31 -0
- package/s/core/{port/resolution → bindings/parts}/lens-algo.ts +23 -20
- package/s/core/bindings/resolver.ts +96 -0
- package/s/core/bindings/sample-map.ts +25 -0
- package/s/core/bindings/types.ts +45 -42
- package/s/core/core.test.ts +46 -34
- package/s/core/devices/auto-gamepads.ts +8 -0
- package/s/core/devices/device.ts +12 -0
- package/s/core/devices/infra/group.ts +24 -0
- package/s/core/devices/infra/sampler.ts +22 -0
- package/s/core/devices/standard/gamepad.ts +83 -0
- package/s/core/{controllers → devices}/standard/index.ts +2 -1
- package/s/core/devices/standard/keyboard.ts +31 -0
- package/s/core/{controllers → devices}/standard/pointer.ts +18 -20
- package/s/core/devices/standard/primary.ts +20 -0
- package/s/core/devices/standard/stick.ts +27 -0
- package/s/core/{controllers/standard/virtual-gamepad.ts → devices/standard/vpad.ts} +9 -9
- package/s/core/{controllers → devices}/types.ts +0 -1
- package/s/core/hub/hub.ts +78 -62
- package/s/core/hub/meta-bindings.ts +23 -0
- package/s/core/hub/parts/connected.ts +15 -0
- package/s/core/hub/port.ts +26 -0
- package/s/core/hub/types.ts +13 -0
- package/s/core/index.ts +13 -13
- package/s/core/testing/testing.ts +22 -17
- package/s/deck/deck.ts +77 -0
- package/s/deck/index.ts +14 -0
- package/s/deck/parts/catalog.ts +58 -0
- package/s/deck/parts/db.ts +66 -0
- package/s/deck/parts/device-skins/device-icons.ts +38 -0
- package/s/deck/parts/device-skins/device-skin.ts +29 -0
- package/s/deck/parts/local-storage-kv.ts +8 -0
- package/s/deck/parts/merge-bindings.ts +21 -0
- package/s/deck/parts/overlay-visibility.ts +49 -0
- package/s/deck/views/deck-overlay/component.ts +48 -0
- package/s/deck/views/deck-overlay/style.css.ts +112 -0
- package/s/deck/views/framework.ts +14 -0
- package/s/demo/game/game.ts +85 -0
- package/s/demo/game/parts/agent.ts +10 -0
- package/s/demo/game/parts/game-bindings.ts +20 -0
- package/s/demo/game/parts/logic.ts +24 -0
- package/s/demo/game/parts/player.ts +32 -0
- package/s/demo/game/parts/renderer.ts +113 -0
- package/s/demo/game/parts/state.ts +24 -0
- package/s/demo/game/parts/virtual-device.ts +13 -0
- package/s/demo/main.bundle.ts +6 -12
- package/s/demo/main.css +30 -2
- package/s/demo/ui/tact-demo/component.ts +13 -0
- package/s/demo/ui/tact-demo/style.css.ts +4 -0
- package/s/demo/ui/theater/styles.css.ts +57 -0
- package/s/demo/ui/theater/view.ts +53 -0
- package/s/demo/ui/theater/virtual/style.css.ts +43 -0
- package/s/demo/ui/theater/virtual/view.ts +31 -0
- package/s/demo/ui/utils/loader.ts +5 -0
- package/s/index.html.ts +16 -6
- package/s/index.ts +3 -1
- package/s/nubs/components.ts +14 -0
- package/s/nubs/index.ts +6 -0
- package/s/nubs/lookpad/component.ts +45 -0
- package/s/nubs/stick/component.ts +115 -0
- package/s/nubs/stick/style.css.ts +70 -0
- package/s/nubs/{virtual-gamepad/view.ts → vpad/component.ts} +21 -11
- package/s/nubs/{virtual-gamepad → vpad}/styles.css.ts +1 -0
- package/s/utils/circular-clamp.ts +15 -0
- package/s/utils/dispensers.ts +20 -0
- package/s/utils/split-axis.ts +10 -2
- package/x/core/{port → bindings}/action.d.ts +3 -1
- package/x/core/{port → bindings}/action.js +13 -5
- package/x/core/bindings/action.js.map +1 -0
- package/x/core/bindings/parts/defaults.d.ts +3 -0
- package/x/core/bindings/parts/defaults.js +25 -0
- package/x/core/bindings/parts/defaults.js.map +1 -0
- package/x/core/bindings/parts/is-pressed.js.map +1 -0
- package/x/core/bindings/parts/lens-algo.d.ts +2 -0
- package/x/core/{port/resolution → bindings/parts}/lens-algo.js +18 -11
- package/x/core/bindings/parts/lens-algo.js.map +1 -0
- package/x/core/bindings/resolver.d.ts +9 -0
- package/x/core/bindings/resolver.js +89 -0
- package/x/core/bindings/resolver.js.map +1 -0
- package/x/core/bindings/sample-map.d.ts +7 -0
- package/x/core/bindings/sample-map.js +22 -0
- package/x/core/bindings/sample-map.js.map +1 -0
- package/x/core/bindings/types.d.ts +34 -38
- package/x/core/bindings/types.js +0 -1
- package/x/core/bindings/types.js.map +1 -1
- package/x/core/core.test.d.ts +5 -4
- package/x/core/core.test.js +45 -34
- package/x/core/core.test.js.map +1 -1
- package/x/core/devices/auto-gamepads.d.ts +2 -0
- package/x/core/devices/auto-gamepads.js +6 -0
- package/x/core/devices/auto-gamepads.js.map +1 -0
- package/x/core/devices/device.d.ts +5 -0
- package/x/core/devices/device.js +7 -0
- package/x/core/devices/device.js.map +1 -0
- package/x/core/devices/infra/group.d.ts +8 -0
- package/x/core/devices/infra/group.js +21 -0
- package/x/core/devices/infra/group.js.map +1 -0
- package/x/core/devices/infra/sampler.d.ts +9 -0
- package/x/core/devices/infra/sampler.js +18 -0
- package/x/core/devices/infra/sampler.js.map +1 -0
- package/x/core/devices/standard/gamepad.d.ts +11 -0
- package/x/core/devices/standard/gamepad.js +65 -0
- package/x/core/devices/standard/gamepad.js.map +1 -0
- package/x/core/{controllers → devices}/standard/index.d.ts +2 -1
- package/x/core/{controllers → devices}/standard/index.js +2 -1
- package/x/core/devices/standard/index.js.map +1 -0
- package/x/core/devices/standard/keyboard.d.ts +9 -0
- package/x/core/devices/standard/keyboard.js +28 -0
- package/x/core/devices/standard/keyboard.js.map +1 -0
- package/x/core/devices/standard/pointer.d.ts +15 -0
- package/x/core/{controllers → devices}/standard/pointer.js +17 -19
- package/x/core/devices/standard/pointer.js.map +1 -0
- package/x/core/devices/standard/primary.d.ts +10 -0
- package/x/core/devices/standard/primary.js +17 -0
- package/x/core/devices/standard/primary.js.map +1 -0
- package/x/core/devices/standard/stick.d.ts +15 -0
- package/x/core/devices/standard/stick.js +24 -0
- package/x/core/devices/standard/stick.js.map +1 -0
- package/x/core/devices/standard/vpad.d.ts +7 -0
- package/x/core/{controllers/standard/virtual-gamepad.js → devices/standard/vpad.js} +10 -10
- package/x/core/devices/standard/vpad.js.map +1 -0
- package/x/core/{controllers → devices}/types.d.ts +0 -1
- package/x/core/{port → devices}/types.js.map +1 -1
- package/x/core/hub/hub.d.ts +27 -24
- package/x/core/hub/hub.js +71 -61
- package/x/core/hub/hub.js.map +1 -1
- package/x/core/hub/meta-bindings.d.ts +2 -0
- package/x/core/hub/meta-bindings.js +21 -0
- package/x/core/hub/meta-bindings.js.map +1 -0
- package/x/core/hub/parts/connected.d.ts +14 -0
- package/x/core/hub/parts/connected.js +12 -0
- package/x/core/hub/parts/connected.js.map +1 -0
- package/x/core/hub/port.d.ts +10 -0
- package/x/core/hub/port.js +19 -0
- package/x/core/hub/port.js.map +1 -0
- package/x/core/hub/types.d.ts +9 -0
- package/x/core/hub/types.js +2 -0
- package/x/core/hub/types.js.map +1 -0
- package/x/core/index.d.ts +13 -12
- package/x/core/index.js +13 -12
- package/x/core/index.js.map +1 -1
- package/x/core/testing/testing.d.ts +20 -38
- package/x/core/testing/testing.js +17 -16
- package/x/core/testing/testing.js.map +1 -1
- package/x/deck/deck.d.ts +35 -0
- package/x/deck/deck.js +50 -0
- package/x/deck/deck.js.map +1 -0
- package/x/deck/index.d.ts +10 -0
- package/x/deck/index.js +11 -0
- package/x/deck/index.js.map +1 -0
- package/x/deck/parts/catalog.d.ts +23 -0
- package/x/deck/parts/catalog.js +35 -0
- package/x/deck/parts/catalog.js.map +1 -0
- package/x/deck/parts/db.d.ts +20 -0
- package/x/deck/parts/db.js +52 -0
- package/x/deck/parts/db.js.map +1 -0
- package/x/deck/parts/device-skins/device-icons.d.ts +12 -0
- package/x/deck/parts/device-skins/device-icons.js +27 -0
- package/x/deck/parts/device-skins/device-icons.js.map +1 -0
- package/x/deck/parts/device-skins/device-skin.d.ts +14 -0
- package/x/deck/parts/device-skins/device-skin.js +22 -0
- package/x/deck/parts/device-skins/device-skin.js.map +1 -0
- package/x/deck/parts/local-storage-kv.d.ts +2 -0
- package/x/deck/parts/local-storage-kv.js +6 -0
- package/x/deck/parts/local-storage-kv.js.map +1 -0
- package/x/deck/parts/merge-bindings.d.ts +2 -0
- package/x/deck/parts/merge-bindings.js +15 -0
- package/x/deck/parts/merge-bindings.js.map +1 -0
- package/x/deck/parts/overlay-visibility.d.ts +21 -0
- package/x/deck/parts/overlay-visibility.js +35 -0
- package/x/deck/parts/overlay-visibility.js.map +1 -0
- package/x/deck/views/deck-overlay/component.d.ts +2 -0
- package/x/deck/views/deck-overlay/component.js +40 -0
- package/x/deck/views/deck-overlay/component.js.map +1 -0
- package/x/deck/views/deck-overlay/style.css.js +109 -0
- package/x/deck/views/deck-overlay/style.css.js.map +1 -0
- package/x/deck/views/framework.d.ts +3 -0
- package/x/deck/views/framework.js +8 -0
- package/x/deck/views/framework.js.map +1 -0
- package/x/demo/game/game.d.ts +20 -0
- package/x/demo/game/game.js +63 -0
- package/x/demo/game/game.js.map +1 -0
- package/x/demo/game/parts/agent.d.ts +7 -0
- package/x/demo/game/parts/agent.js +8 -0
- package/x/demo/game/parts/agent.js.map +1 -0
- package/x/demo/game/parts/game-bindings.d.ts +15 -0
- package/x/demo/game/parts/game-bindings.js +10 -0
- package/x/demo/game/parts/game-bindings.js.map +1 -0
- package/x/demo/game/parts/logic.d.ts +8 -0
- package/x/demo/game/parts/logic.js +21 -0
- package/x/demo/game/parts/logic.js.map +1 -0
- package/x/demo/game/parts/player.d.ts +14 -0
- package/x/demo/game/parts/player.js +26 -0
- package/x/demo/game/parts/player.js.map +1 -0
- package/x/demo/game/parts/renderer.d.ts +13 -0
- package/x/demo/game/parts/renderer.js +91 -0
- package/x/demo/game/parts/renderer.js.map +1 -0
- package/x/demo/game/parts/state.d.ts +8 -0
- package/x/demo/game/parts/state.js +20 -0
- package/x/demo/game/parts/state.js.map +1 -0
- package/x/demo/game/parts/virtual-device.d.ts +8 -0
- package/x/demo/game/parts/virtual-device.js +11 -0
- package/x/demo/game/parts/virtual-device.js.map +1 -0
- package/x/demo/main.bundle.js +4 -10
- package/x/demo/main.bundle.js.map +1 -1
- package/x/demo/main.bundle.min.js +315 -54
- package/x/demo/main.bundle.min.js.map +4 -4
- package/x/demo/main.css +30 -2
- package/x/demo/ui/tact-demo/component.d.ts +4 -0
- package/x/demo/ui/tact-demo/component.js +12 -0
- package/x/demo/ui/tact-demo/component.js.map +1 -0
- package/x/demo/ui/tact-demo/style.css.d.ts +2 -0
- package/x/demo/ui/tact-demo/style.css.js +3 -0
- package/x/demo/ui/tact-demo/style.css.js.map +1 -0
- package/x/demo/ui/theater/styles.css.js +56 -0
- package/x/demo/ui/theater/styles.css.js.map +1 -0
- package/x/demo/ui/theater/view.d.ts +2 -0
- package/x/demo/ui/theater/view.js +42 -0
- package/x/demo/ui/theater/view.js.map +1 -0
- package/x/demo/ui/theater/virtual/style.css.d.ts +2 -0
- package/x/demo/ui/theater/virtual/style.css.js +42 -0
- package/x/demo/ui/theater/virtual/style.css.js.map +1 -0
- package/x/demo/ui/theater/virtual/view.d.ts +4 -0
- package/x/demo/ui/theater/virtual/view.js +19 -0
- package/x/demo/ui/theater/virtual/view.js.map +1 -0
- package/x/demo/ui/utils/loader.d.ts +1 -0
- package/x/demo/ui/utils/loader.js +3 -0
- package/x/demo/ui/utils/loader.js.map +1 -0
- package/x/index.d.ts +3 -1
- package/x/index.html +47 -8
- package/x/index.html.js +16 -6
- package/x/index.html.js.map +1 -1
- package/x/index.js +3 -1
- package/x/index.js.map +1 -1
- package/x/nubs/components.d.ts +9 -0
- package/x/nubs/components.js +11 -0
- package/x/nubs/components.js.map +1 -0
- package/x/nubs/index.d.ts +4 -0
- package/x/nubs/index.js +5 -0
- package/x/nubs/index.js.map +1 -0
- package/x/nubs/lookpad/component.d.ts +4 -0
- package/x/nubs/lookpad/component.js +36 -0
- package/x/nubs/lookpad/component.js.map +1 -0
- package/x/nubs/stick/component.d.ts +368 -0
- package/x/nubs/stick/component.js +101 -0
- package/x/nubs/stick/component.js.map +1 -0
- package/x/nubs/stick/style.css.d.ts +2 -0
- package/x/nubs/stick/style.css.js +69 -0
- package/x/nubs/stick/style.css.js.map +1 -0
- package/x/nubs/vpad/component.d.ts +368 -0
- package/x/nubs/{virtual-gamepad/view.js → vpad/component.js} +20 -11
- package/x/nubs/vpad/component.js.map +1 -0
- package/x/nubs/vpad/styles.css.d.ts +2 -0
- package/x/nubs/vpad/styles.css.js.map +1 -0
- package/x/nubs/vpad/utils/gamepad-inputs.js.map +1 -0
- package/x/nubs/vpad/utils/prevent-default-touch-shenanigans.js.map +1 -0
- package/x/nubs/vpad/utils/touch-tracking.js.map +1 -0
- package/x/utils/circular-clamp.d.ts +2 -0
- package/x/utils/circular-clamp.js +8 -0
- package/x/utils/circular-clamp.js.map +1 -0
- package/x/utils/dispensers.d.ts +7 -0
- package/x/utils/dispensers.js +16 -0
- package/x/utils/dispensers.js.map +1 -0
- package/x/utils/split-axis.d.ts +7 -0
- package/x/utils/split-axis.js +7 -2
- package/x/utils/split-axis.js.map +1 -1
- package/s/core/controllers/controller.ts +0 -7
- package/s/core/controllers/infra/group.ts +0 -17
- package/s/core/controllers/infra/sampler.ts +0 -22
- package/s/core/controllers/standard/gamepad.ts +0 -81
- package/s/core/controllers/standard/keyboard.ts +0 -53
- package/s/core/controllers/standard/stick.ts +0 -30
- package/s/core/controllers/utils/modprefix.ts +0 -16
- package/s/core/hub/auto-gamepads.ts +0 -8
- package/s/core/hub/bindings.ts +0 -21
- package/s/core/port/port.ts +0 -34
- package/s/core/port/resolution/defaults.ts +0 -30
- package/s/core/port/resolution/resolver.ts +0 -77
- package/s/core/port/resolution/types.ts +0 -9
- package/s/core/port/types.ts +0 -10
- package/s/core/port/utils/aggregate_samples_into_map.ts +0 -20
- package/s/core/port/utils/wipe_samples_map.ts +0 -8
- package/s/nubs/lookpad/utils/listeners.ts +0 -53
- package/s/nubs/lookpad/view.ts +0 -32
- package/s/nubs/stick/styles.ts +0 -22
- package/s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts +0 -27
- package/s/nubs/stick/utils/find_closest_point_on_circle.ts +0 -15
- package/s/nubs/stick/utils/make_pointer_listeners.ts +0 -50
- package/s/nubs/stick/utils/within_radius.ts +0 -6
- package/s/nubs/stick/view.ts +0 -50
- package/s/nubs/stick-graphic/styles.ts +0 -38
- package/s/nubs/stick-graphic/types/basis.ts +0 -5
- package/s/nubs/stick-graphic/utils/calculate_basis.ts +0 -19
- package/s/nubs/stick-graphic/utils/stick_vector_to_pixels.ts +0 -13
- package/s/nubs/stick-graphic/utils/transform.ts +0 -10
- package/s/nubs/stick-graphic/view.ts +0 -43
- package/x/core/controllers/controller.d.ts +0 -4
- package/x/core/controllers/controller.js +0 -3
- package/x/core/controllers/controller.js.map +0 -1
- package/x/core/controllers/infra/group.d.ts +0 -7
- package/x/core/controllers/infra/group.js +0 -13
- package/x/core/controllers/infra/group.js.map +0 -1
- package/x/core/controllers/infra/sampler.d.ts +0 -8
- package/x/core/controllers/infra/sampler.js +0 -17
- package/x/core/controllers/infra/sampler.js.map +0 -1
- package/x/core/controllers/standard/gamepad.d.ts +0 -10
- package/x/core/controllers/standard/gamepad.js +0 -70
- package/x/core/controllers/standard/gamepad.js.map +0 -1
- package/x/core/controllers/standard/index.js.map +0 -1
- package/x/core/controllers/standard/keyboard.d.ts +0 -9
- package/x/core/controllers/standard/keyboard.js +0 -42
- package/x/core/controllers/standard/keyboard.js.map +0 -1
- package/x/core/controllers/standard/pointer.d.ts +0 -11
- package/x/core/controllers/standard/pointer.js.map +0 -1
- package/x/core/controllers/standard/stick.d.ts +0 -15
- package/x/core/controllers/standard/stick.js +0 -27
- package/x/core/controllers/standard/stick.js.map +0 -1
- package/x/core/controllers/standard/virtual-gamepad.d.ts +0 -7
- package/x/core/controllers/standard/virtual-gamepad.js.map +0 -1
- package/x/core/controllers/types.js.map +0 -1
- package/x/core/controllers/utils/modprefix.d.ts +0 -1
- package/x/core/controllers/utils/modprefix.js +0 -16
- package/x/core/controllers/utils/modprefix.js.map +0 -1
- package/x/core/hub/auto-gamepads.d.ts +0 -2
- package/x/core/hub/auto-gamepads.js +0 -6
- package/x/core/hub/auto-gamepads.js.map +0 -1
- package/x/core/hub/bindings.d.ts +0 -2
- package/x/core/hub/bindings.js +0 -19
- package/x/core/hub/bindings.js.map +0 -1
- package/x/core/port/action.js.map +0 -1
- package/x/core/port/port.d.ts +0 -12
- package/x/core/port/port.js +0 -25
- package/x/core/port/port.js.map +0 -1
- package/x/core/port/resolution/defaults.d.ts +0 -4
- package/x/core/port/resolution/defaults.js +0 -23
- package/x/core/port/resolution/defaults.js.map +0 -1
- package/x/core/port/resolution/lens-algo.d.ts +0 -2
- package/x/core/port/resolution/lens-algo.js.map +0 -1
- package/x/core/port/resolution/resolver.d.ts +0 -9
- package/x/core/port/resolution/resolver.js +0 -64
- package/x/core/port/resolution/resolver.js.map +0 -1
- package/x/core/port/resolution/types.d.ts +0 -6
- package/x/core/port/resolution/types.js +0 -2
- package/x/core/port/resolution/types.js.map +0 -1
- package/x/core/port/types.d.ts +0 -7
- package/x/core/port/types.js +0 -2
- package/x/core/port/utils/aggregate_samples_into_map.d.ts +0 -3
- package/x/core/port/utils/aggregate_samples_into_map.js +0 -11
- package/x/core/port/utils/aggregate_samples_into_map.js.map +0 -1
- package/x/core/port/utils/is-pressed.js.map +0 -1
- package/x/core/port/utils/wipe_samples_map.d.ts +0 -2
- package/x/core/port/utils/wipe_samples_map.js +0 -5
- package/x/core/port/utils/wipe_samples_map.js.map +0 -1
- package/x/nubs/lookpad/utils/listeners.d.ts +0 -19
- package/x/nubs/lookpad/utils/listeners.js +0 -37
- package/x/nubs/lookpad/utils/listeners.js.map +0 -1
- package/x/nubs/lookpad/view.d.ts +0 -1
- package/x/nubs/lookpad/view.js +0 -24
- package/x/nubs/lookpad/view.js.map +0 -1
- package/x/nubs/stick/styles.d.ts +0 -1
- package/x/nubs/stick/styles.js +0 -22
- package/x/nubs/stick/styles.js.map +0 -1
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.d.ts +0 -3
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js +0 -16
- package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js.map +0 -1
- package/x/nubs/stick/utils/find_closest_point_on_circle.d.ts +0 -2
- package/x/nubs/stick/utils/find_closest_point_on_circle.js +0 -6
- package/x/nubs/stick/utils/find_closest_point_on_circle.js.map +0 -1
- package/x/nubs/stick/utils/make_pointer_listeners.d.ts +0 -16
- package/x/nubs/stick/utils/make_pointer_listeners.js +0 -34
- package/x/nubs/stick/utils/make_pointer_listeners.js.map +0 -1
- package/x/nubs/stick/utils/within_radius.d.ts +0 -2
- package/x/nubs/stick/utils/within_radius.js +0 -4
- package/x/nubs/stick/utils/within_radius.js.map +0 -1
- package/x/nubs/stick/view.d.ts +0 -2
- package/x/nubs/stick/view.js +0 -38
- package/x/nubs/stick/view.js.map +0 -1
- package/x/nubs/stick-graphic/styles.js +0 -38
- package/x/nubs/stick-graphic/styles.js.map +0 -1
- package/x/nubs/stick-graphic/types/basis.d.ts +0 -4
- package/x/nubs/stick-graphic/types/basis.js +0 -2
- package/x/nubs/stick-graphic/types/basis.js.map +0 -1
- package/x/nubs/stick-graphic/utils/calculate_basis.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/calculate_basis.js +0 -10
- package/x/nubs/stick-graphic/utils/calculate_basis.js.map +0 -1
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js +0 -7
- package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js.map +0 -1
- package/x/nubs/stick-graphic/utils/transform.d.ts +0 -2
- package/x/nubs/stick-graphic/utils/transform.js +0 -7
- package/x/nubs/stick-graphic/utils/transform.js.map +0 -1
- package/x/nubs/stick-graphic/view.d.ts +0 -3
- package/x/nubs/stick-graphic/view.js +0 -30
- package/x/nubs/stick-graphic/view.js.map +0 -1
- package/x/nubs/virtual-gamepad/styles.css.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js.map +0 -1
- package/x/nubs/virtual-gamepad/utils/touch-tracking.js.map +0 -1
- package/x/nubs/virtual-gamepad/view.d.ts +0 -2
- package/x/nubs/virtual-gamepad/view.js.map +0 -1
- /package/s/core/{port/utils → bindings/parts}/is-pressed.ts +0 -0
- /package/s/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.ts +0 -0
- /package/s/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.ts +0 -0
- /package/s/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.ts +0 -0
- /package/x/core/{port/utils → bindings/parts}/is-pressed.d.ts +0 -0
- /package/x/core/{port/utils → bindings/parts}/is-pressed.js +0 -0
- /package/x/core/{controllers → devices}/types.js +0 -0
- /package/x/{nubs/virtual-gamepad/styles.css.d.ts → deck/views/deck-overlay/style.css.d.ts} +0 -0
- /package/x/{nubs/stick-graphic/styles.d.ts → demo/ui/theater/styles.css.d.ts} +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/styles.css.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.js +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.d.ts +0 -0
- /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.js +0 -0
package/README.md
CHANGED
|
@@ -1,83 +1,82 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
>
|
|
2
|
+
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> ### 🚨🚨 TACT IS UNDER DEVELOPMENT!! 🚨🚨
|
|
5
|
+
> *everything is half-broken right now.. just gimmie a minute to finish coding this, will ya?*
|
|
6
|
+
|
|
7
|
+
<br></br>
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<br></br>
|
|
14
|
+
|
|
15
|
+
# 🎮 @benev/tact
|
|
16
|
+
> *web game input library, from keypress to couch co-op*
|
|
4
17
|
|
|
5
18
|
```ts
|
|
6
19
|
npm install @benev/tact
|
|
7
20
|
```
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
- 🧩 **bindings** describe how actions interpret samples
|
|
12
|
-
- 🔌 **port** updates actions by interpreting samples
|
|
13
|
-
- 🛞 **hub** plugs controllers into ports (multi-gamepad couch co-op!)
|
|
14
|
-
- 📱 **nubs** is mobile ui virtual gamepad stuff
|
|
22
|
+
tact is a toolkit for handling user inputs on the web.
|
|
23
|
+
it's good at user-customizable keybindings, multiple gamepad support, and mobile ui.
|
|
15
24
|
|
|
25
|
+
- 🛹 **[#deck](#deck)** full setup with localstorage persistence
|
|
26
|
+
- 🎮 **[#devices](#devices)** produce user input samples
|
|
27
|
+
- 🧩 **[#bindings](#bindings)** describe how actions interpret samples
|
|
28
|
+
- 🔌 **[#port](#port)** updates actions by interpreting samples
|
|
29
|
+
- 🛞 **[#hub](#hub)** plugs devices into ports (multi-gamepad couch co-op!)
|
|
30
|
+
- 📱 **[#nubs](#nubs)** is mobile ui virtual gamepad stuff
|
|
16
31
|
|
|
17
32
|
|
|
18
33
|
<br/><br/>
|
|
34
|
+
<a id="deck"></a>
|
|
19
35
|
|
|
20
36
|
## 🍋 tact deck
|
|
21
|
-
> *
|
|
37
|
+
> *full setup with ui, batteries included*
|
|
22
38
|
|
|
23
|
-
the deck
|
|
39
|
+
the deck ties together all the important pieces of tact into a single user experience, complete with ui components.
|
|
24
40
|
|
|
25
41
|
### 🛹 deck setup
|
|
26
42
|
- **import stuff from tact**
|
|
27
43
|
```ts
|
|
28
44
|
import * as tact from "@benev/tact"
|
|
29
45
|
```
|
|
30
|
-
- **setup your deck**
|
|
46
|
+
- **setup your deck, and your game's bindings**
|
|
31
47
|
```ts
|
|
32
|
-
const deck =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{lenses: [{code: "gamepad.a"}]},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
48
|
+
const deck = await tact.Deck.load({
|
|
49
|
+
|
|
50
|
+
// how many player ports are possible? 1 is fine..
|
|
51
|
+
portCount: 4,
|
|
52
|
+
|
|
53
|
+
// where to store the user-customized bindings
|
|
54
|
+
kv: tact.localStorageKv(),
|
|
55
|
+
|
|
56
|
+
// default archetypal bindings for your game
|
|
57
|
+
bindings: {
|
|
58
|
+
walking: {forward: "KeyW", jump: "Space"},
|
|
46
59
|
gunning: {
|
|
47
|
-
shoot: [
|
|
48
|
-
{lenses: [{code: "pointer.button.left"}]},
|
|
49
|
-
{lenses: [{code: "gamepad.trigger.right"}]},
|
|
50
|
-
],
|
|
60
|
+
shoot: ["or", "pointer.button.left", "gamepad.trigger.right"],
|
|
51
61
|
},
|
|
52
|
-
}
|
|
62
|
+
},
|
|
53
63
|
})
|
|
54
64
|
```
|
|
55
65
|
|
|
56
|
-
### 🛹 plug
|
|
66
|
+
### 🛹 plug devices into the hub
|
|
57
67
|
- **plug a keyboard/mouse player into the hub**
|
|
58
68
|
```ts
|
|
59
|
-
deck.hub.plug(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
new tact.PointerController(),
|
|
63
|
-
new tact.VirtualGamepadController(),
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
```
|
|
67
|
-
- **auto connect/disconnect gamepads as they come and go**
|
|
69
|
+
deck.hub.plug(new tact.PrimaryDevice())
|
|
70
|
+
```
|
|
71
|
+
- **automatically detect and plug gamepads**
|
|
68
72
|
```ts
|
|
69
73
|
tact.autoGamepads(deck.hub.plug)
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
### 🛹 do your gameplay
|
|
73
|
-
- **
|
|
74
|
-
```ts
|
|
75
|
-
for (const port of deck.ports)
|
|
76
|
-
port.modes.adds("walking", "gunning")
|
|
77
|
-
```
|
|
78
|
-
- **poll the deck, interrogate actions for your gameplay**
|
|
77
|
+
- **poll the deck, interrogate actions**
|
|
79
78
|
```ts
|
|
80
|
-
|
|
79
|
+
myGameLoop(() => {
|
|
81
80
|
|
|
82
81
|
// do your polling
|
|
83
82
|
const [p1, p2, p3, p4] = deck.hub.poll()
|
|
@@ -90,40 +89,47 @@ the deck is the heart of tact.. it ties all the important parts together..
|
|
|
90
89
|
})
|
|
91
90
|
```
|
|
92
91
|
|
|
92
|
+
### 🛹 deck ui: the overlay
|
|
93
|
+
- **register the deck's web components to the dom**
|
|
94
|
+
```ts
|
|
95
|
+
deck.registerComponents()
|
|
96
|
+
```
|
|
97
|
+
- **place the ui on top of your game canvas**
|
|
98
|
+
```html
|
|
99
|
+
<deck-overlay></deck-overlay>
|
|
100
|
+
```
|
|
101
|
+
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
<br/><br/>
|
|
105
|
+
<a id="devices"></a>
|
|
96
106
|
|
|
97
|
-
## 🍋 tact
|
|
98
|
-
> *
|
|
107
|
+
## 🍋 tact devices
|
|
108
|
+
> *sources of user input "samples"*
|
|
99
109
|
|
|
100
110
|
### 🎮 polling is good, actually
|
|
101
111
|
- tact operates on the basis of *polling*
|
|
102
112
|
- *"but polling is bad"* says you — but no — you're wrong — polling is unironically *based,* and you *should* do it
|
|
103
|
-
-
|
|
104
|
-
- the gift of polling is total control over *when* inputs are processed
|
|
113
|
+
- the gift of polling is total control over *when* inputs are processed, this is good for games
|
|
105
114
|
- i will elaborate no further 🗿
|
|
106
115
|
|
|
107
|
-
### 🎮 basically how a
|
|
108
|
-
- make a
|
|
116
|
+
### 🎮 basically how a device works
|
|
117
|
+
- make a device
|
|
109
118
|
```ts
|
|
110
|
-
const keyboard = new tact.
|
|
119
|
+
const keyboard = new tact.KeyboardDevice()
|
|
111
120
|
```
|
|
112
|
-
-
|
|
121
|
+
- reading samples looks like this
|
|
113
122
|
```ts
|
|
114
|
-
const
|
|
115
|
-
// [
|
|
116
|
-
// ["KeyA", 1],
|
|
117
|
-
// ["Space", 0]
|
|
118
|
-
// ]
|
|
123
|
+
for (const sample of keyboard.samples())
|
|
124
|
+
console.log(sample) // ["KeyA", 1]
|
|
119
125
|
```
|
|
120
|
-
-
|
|
126
|
+
- some devices have disposers to call when you're done with them
|
|
121
127
|
```ts
|
|
122
128
|
keyboard.dispose()
|
|
123
129
|
```
|
|
124
130
|
|
|
125
131
|
### 🎮 samples explained
|
|
126
|
-
- a sample is a raw input of type `[code: string, value: number]`
|
|
132
|
+
- a sample is a raw input tuple of type `[code: string, value: number]`
|
|
127
133
|
- a sample has a `code` string
|
|
128
134
|
- it's either a [standard keycode](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values), like `KeyA`
|
|
129
135
|
- or it's something we made up, like `pointer.button.left` or `gamepad.trigger.right`
|
|
@@ -135,37 +141,21 @@ the deck is the heart of tact.. it ties all the important parts together..
|
|
|
135
141
|
- sometimes we use numbers greater then `1`, like for dots of pointer movement like in `pointer.move.up`
|
|
136
142
|
- don't worry about sensitivity, deadzones, values like `0.00001` — actions will account for all that using bindings later on
|
|
137
143
|
|
|
138
|
-
### 🎮 sample code modprefixes
|
|
139
|
-
- here at tact, we have this nifty `modprefix` convention
|
|
140
|
-
- consider a keycode like `KeyA`
|
|
141
|
-
- `ctrl-KeyA` means the "ctrl" modifier was held
|
|
142
|
-
- `alt-KeyA` means the "alt" modifier was held
|
|
143
|
-
- `meta-KeyA` means the "meta" modifier was held (command or windows keys)
|
|
144
|
-
- `shift-KeyA` means the "shift" modifier was held
|
|
145
|
-
- `ctrl-alt-meta-shift-KeyA` they can stack, but always in this order (the word `cams` helps remind me the valid order)
|
|
146
|
-
- `x-KeyA` means *no* modifier was held (exclusive)
|
|
147
|
-
- `KeyA` doesn't care if any modifiers were held or not
|
|
148
|
-
|
|
149
144
|
### 🎮 sample code reference
|
|
150
|
-
- **
|
|
145
|
+
- **KeyboardDevice**
|
|
151
146
|
- any [standard keycode](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values)
|
|
152
147
|
- `KeyA`
|
|
153
148
|
- `Space`
|
|
154
149
|
- `Digit2`
|
|
155
150
|
- etc
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- `alt-shift-Space`
|
|
159
|
-
- `x-Digit2`
|
|
160
|
-
- etc
|
|
161
|
-
- **PointerController**
|
|
162
|
-
- mouse buttons (plus modprefixes)
|
|
151
|
+
- **PointerDevice**
|
|
152
|
+
- mouse buttons
|
|
163
153
|
- `pointer.button.left`
|
|
164
154
|
- `pointer.button.right`
|
|
165
155
|
- `pointer.button.middle`
|
|
166
156
|
- `pointer.button.4`
|
|
167
157
|
- `pointer.button.5`
|
|
168
|
-
- mouse wheel
|
|
158
|
+
- mouse wheel
|
|
169
159
|
- `pointer.wheel.up`
|
|
170
160
|
- `pointer.wheel.down`
|
|
171
161
|
- `pointer.wheel.left`
|
|
@@ -175,7 +165,7 @@ the deck is the heart of tact.. it ties all the important parts together..
|
|
|
175
165
|
- `pointer.move.down`
|
|
176
166
|
- `pointer.move.left`
|
|
177
167
|
- `pointer.move.right`
|
|
178
|
-
- **
|
|
168
|
+
- **GamepadDevice**
|
|
179
169
|
- gamepad buttons
|
|
180
170
|
- `gamepad.a`
|
|
181
171
|
- `gamepad.b`
|
|
@@ -207,69 +197,147 @@ the deck is the heart of tact.. it ties all the important parts together..
|
|
|
207
197
|
|
|
208
198
|
|
|
209
199
|
<br/><br/>
|
|
200
|
+
<a id="bindings"></a>
|
|
210
201
|
|
|
211
202
|
## 🍋 tact bindings
|
|
212
203
|
> *keybindings! they describe how actions interpret samples*
|
|
213
204
|
|
|
214
205
|
### 🧩 bindings example
|
|
215
|
-
- let's start with a small example
|
|
206
|
+
- **let's start with a small example:**
|
|
216
207
|
```ts
|
|
217
208
|
const bindings = tact.asBindings({
|
|
218
|
-
walking: {
|
|
219
|
-
forward: [{lenses: [{code: "KeyW"}]}],
|
|
220
|
-
jump: [{lenses: [{code: "Space"}]}],
|
|
221
|
-
},
|
|
209
|
+
walking: {forward: "KeyW", jump: "Space"},
|
|
222
210
|
gunning: {
|
|
223
|
-
shoot: [
|
|
211
|
+
shoot: ["or", "pointer.button.left", "gamepad.trigger.right"],
|
|
224
212
|
},
|
|
225
213
|
})
|
|
226
214
|
```
|
|
227
215
|
- `walking` and `gunning` are **modes**
|
|
228
216
|
- `forward`, `jump`, and `shoot` are **actions**
|
|
229
|
-
-
|
|
230
|
-
|
|
231
|
-
|
|
217
|
+
- note that whole modes can be enabled or disabled during gameplay
|
|
218
|
+
|
|
219
|
+
### 🧩 bindings are a lispy domain-specific-language
|
|
220
|
+
- **you can do complex stuff**
|
|
221
|
+
```ts
|
|
222
|
+
["or",
|
|
223
|
+
"KeyQ",
|
|
224
|
+
["and",
|
|
225
|
+
"KeyA",
|
|
226
|
+
"KeyD",
|
|
227
|
+
["not", "KeyS"],
|
|
228
|
+
],
|
|
229
|
+
]
|
|
230
|
+
```
|
|
231
|
+
- press Q, or
|
|
232
|
+
- press A + D, while not pressing S
|
|
233
|
+
- **you can get really weird**
|
|
234
|
+
```ts
|
|
235
|
+
["cond",
|
|
236
|
+
["code", "gamepad.trigger.right", {range: [0, 0.5], timing: ["tap"]}],
|
|
237
|
+
["and", "gamepad.bumper.left", ["not", "gamepad.trigger.left"]],
|
|
238
|
+
]
|
|
239
|
+
```
|
|
240
|
+
- hold LB and tap RT halfway while not holding LT
|
|
241
|
+
|
|
242
|
+
### 🧩 bindings atom reference
|
|
243
|
+
- **string** — strings are interpreted as "code" atoms with default settings
|
|
244
|
+
- **"code"** — allows you to customize the settings
|
|
245
|
+
```ts
|
|
246
|
+
["code", "KeyA", {
|
|
247
|
+
scale: 1,
|
|
248
|
+
invert: false,
|
|
249
|
+
deadzone: 0,
|
|
250
|
+
timing: ["direct"],
|
|
251
|
+
}]
|
|
252
|
+
```
|
|
253
|
+
- defaults shown
|
|
254
|
+
- `scale` is sensitivity, the value gets multiplied by this
|
|
255
|
+
- `invert` will invert a value by subtracting it from 1
|
|
256
|
+
- `deadzone` ignores values below the threshold (and remaps to preserve the range)
|
|
257
|
+
- `timing` lets you specify special timing considerations
|
|
258
|
+
- `["direct"]` ignores timing considerations
|
|
259
|
+
- `["tap", 250]` only fires for taps under 250ms
|
|
260
|
+
- `["hold", 250]` only fires for holds over 250ms
|
|
261
|
+
- **"or"** — resolves to the maximum value
|
|
262
|
+
```ts
|
|
263
|
+
["or", "KeyA", "KeyB", "KeyC"]
|
|
264
|
+
```
|
|
265
|
+
- **"and"** — resolves to the minimum value
|
|
266
|
+
```ts
|
|
267
|
+
["and", "KeyA", "KeyB", "KeyC"]
|
|
268
|
+
```
|
|
269
|
+
- **"not"** — resolves to the opposite effect
|
|
270
|
+
```ts
|
|
271
|
+
["not", "KeyA"]
|
|
272
|
+
```
|
|
273
|
+
- **"cond"** — conditional situation (example for modifiers shown)
|
|
274
|
+
```ts
|
|
275
|
+
["cond", "KeyA", ["and",
|
|
276
|
+
["or", "ControlLeft", "ControlRight"],
|
|
277
|
+
["not", ["or", "AltLeft", "AltRight"]],
|
|
278
|
+
["not", ["or", "MetaLeft", "MetaRight"]],
|
|
279
|
+
["not", ["or", "ShiftLeft", "ShiftRight"]],
|
|
280
|
+
]]
|
|
281
|
+
```
|
|
282
|
+
- KeyA is the value that gets used
|
|
283
|
+
- but only if the following condition passes
|
|
284
|
+
- **"mods"** — macro for modifiers
|
|
285
|
+
```ts
|
|
286
|
+
["mods", "KeyA", {ctrl: true}]
|
|
287
|
+
```
|
|
288
|
+
- equivalent to the "cond" example above
|
|
289
|
+
- `ctrl`, `alt`, `meta`, `shift` are available
|
|
232
290
|
|
|
233
291
|
|
|
234
292
|
|
|
235
293
|
<br/><br/>
|
|
294
|
+
<a id="port"></a>
|
|
236
295
|
|
|
237
296
|
## 🍋 tact port
|
|
238
297
|
> *polling gives you "actions"*
|
|
239
298
|
|
|
240
|
-
|
|
299
|
+
a port represents a single playable port, and you poll it each frame to resolve actions for you to read.
|
|
300
|
+
|
|
301
|
+
### 🔌 port setup
|
|
241
302
|
- **make a port**
|
|
242
303
|
```ts
|
|
243
304
|
const port = new tact.Port(bindings)
|
|
244
305
|
```
|
|
245
|
-
- **attach some
|
|
306
|
+
- **attach some devices to the port**
|
|
246
307
|
```ts
|
|
247
|
-
port.
|
|
248
|
-
.add(new tact.
|
|
249
|
-
.add(new tact.
|
|
250
|
-
.add(new tact.
|
|
308
|
+
port.devices
|
|
309
|
+
.add(new tact.KeyboardDevice())
|
|
310
|
+
.add(new tact.PointerDevice())
|
|
311
|
+
.add(new tact.VpadDevice())
|
|
251
312
|
```
|
|
252
|
-
- you can add/delete
|
|
253
|
-
- **
|
|
313
|
+
- you can add/delete devices from the set any time
|
|
314
|
+
- **manipulate modes**
|
|
254
315
|
```ts
|
|
316
|
+
port.modes.clear()
|
|
255
317
|
port.modes.add("walking")
|
|
256
318
|
```
|
|
257
|
-
- if you don't enable any modes, no actions will happen
|
|
258
319
|
- actions only happen for enabled modes
|
|
259
320
|
- you can toggle modes on and off by adding/deleting them from the modes set
|
|
260
321
|
- **you can update the bindings any time**
|
|
261
322
|
```ts
|
|
262
323
|
port.bindings = freshBindings
|
|
263
324
|
```
|
|
325
|
+
- **wire up gamepad auto connect/disconnect**
|
|
326
|
+
```ts
|
|
327
|
+
tact.autoGamepads(device => {
|
|
328
|
+
port.devices.add(device)
|
|
329
|
+
return () => port.devices.delete(device)
|
|
330
|
+
})
|
|
331
|
+
```
|
|
264
332
|
|
|
265
333
|
### 🔌 interrogating actions
|
|
266
334
|
- **poll the port every frame**
|
|
267
335
|
```ts
|
|
268
|
-
|
|
336
|
+
port.poll()
|
|
269
337
|
```
|
|
270
338
|
- **now you can inspect the `actions`**
|
|
271
339
|
```ts
|
|
272
|
-
actions.walking.forward.value // 1
|
|
340
|
+
port.actions.walking.forward.value // 1
|
|
273
341
|
```
|
|
274
342
|
- `walking` is a `mode`
|
|
275
343
|
- `forward` is an `action`
|
|
@@ -283,77 +351,81 @@ the deck is the heart of tact.. it ties all the important parts together..
|
|
|
283
351
|
|
|
284
352
|
|
|
285
353
|
<br/><br/>
|
|
354
|
+
<a id="hub"></a>
|
|
286
355
|
|
|
287
356
|
## 🍋 tact hub
|
|
288
357
|
> *multiple gamepads! couch co-op is so back*
|
|
289
358
|
|
|
290
359
|
you know the way old-timey game consoles had four controller ports on the front?
|
|
291
360
|
|
|
292
|
-
the hub embraces that analogy, helping you coordinate the plugging and unplugging of virtual
|
|
361
|
+
the hub embraces that analogy, helping you coordinate the plugging and unplugging of virtual controller devices into its virtual ports.
|
|
293
362
|
|
|
294
363
|
### 🛞 create a hub with ports
|
|
295
|
-
- **adopt standard hub bindings**
|
|
296
|
-
```ts
|
|
297
|
-
// transform your game's bindings into hub-friendly bindings
|
|
298
|
-
const hubBindings = tact.Hub.bindings(bindings)
|
|
299
|
-
```
|
|
300
|
-
- this augments your bindings with standard hub-specific bindings
|
|
301
|
-
- this lets players to shimmy what port their controller is plugged into
|
|
302
|
-
- gamepad: hold gamma (middle button) and press bumpers
|
|
303
|
-
- keyboard: left bracket or right bracket
|
|
304
364
|
- **make hub with multiple ports at the ready**
|
|
305
365
|
```ts
|
|
306
366
|
const hub = new tact.Hub([
|
|
307
|
-
new tact.Port(
|
|
308
|
-
new tact.Port(
|
|
309
|
-
new tact.Port(
|
|
310
|
-
new tact.Port(
|
|
367
|
+
new tact.Port(bindings),
|
|
368
|
+
new tact.Port(bindings),
|
|
369
|
+
new tact.Port(bindings),
|
|
370
|
+
new tact.Port(bindings),
|
|
311
371
|
])
|
|
312
372
|
```
|
|
313
373
|
- yes that's right — each player port gets its own bindings 🤯
|
|
314
374
|
|
|
315
|
-
### 🛞 plug in some
|
|
375
|
+
### 🛞 plug in some devices
|
|
316
376
|
- **let's plug in the keyboard/mouse player**
|
|
317
377
|
```ts
|
|
318
|
-
hub.plug(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
new tact.PointerController(),
|
|
322
|
-
new tact.VirtualGamepadController(),
|
|
323
|
-
)
|
|
324
|
-
)
|
|
325
|
-
```
|
|
326
|
-
- the hub requires a single controller to represent a player, thus we can use a `GroupController` to combine multple controllers into one
|
|
378
|
+
hub.plug(new tact.PrimaryDevice())
|
|
379
|
+
```
|
|
380
|
+
- the hub requires a single device to represent a player, so you can use a `GroupDevice` to combine multple devices into one
|
|
327
381
|
- **wire up gamepad auto connect/disconnect**
|
|
328
382
|
```ts
|
|
329
383
|
tact.autoGamepads(hub.plug)
|
|
330
384
|
```
|
|
331
385
|
|
|
332
|
-
### 🛞
|
|
386
|
+
### 🛞 now we're gaming
|
|
333
387
|
- **do your polling, interrogate those actions**
|
|
334
388
|
```ts
|
|
335
389
|
const [p1, p2, p3, p4] = hub.poll()
|
|
336
390
|
|
|
337
|
-
p1.walking.jump.value // 1
|
|
338
|
-
p2.walking.jump.value // 0
|
|
391
|
+
p1.actions.walking.jump.value // 1
|
|
392
|
+
p2.actions.walking.jump.value // 0
|
|
339
393
|
```
|
|
340
394
|
|
|
341
395
|
|
|
342
396
|
|
|
343
397
|
<br/><br/>
|
|
398
|
+
<a id="nubs"></a>
|
|
344
399
|
|
|
345
400
|
## 🍋 tact nubs
|
|
346
401
|
> *mobile ui like virtual thumbsticks and buttons*
|
|
347
402
|
|
|
403
|
+
### 📱 nubs setup
|
|
404
|
+
- **register nub components to dom**
|
|
405
|
+
```ts
|
|
406
|
+
tact.registerNubs()
|
|
407
|
+
```
|
|
408
|
+
- **place nub components onto your html page**
|
|
409
|
+
```html
|
|
410
|
+
<nub-stick></nub-stick>
|
|
411
|
+
```
|
|
412
|
+
|
|
348
413
|
### 📱 nub stick
|
|
349
|
-
|
|
414
|
+
- **place a nub-stick onto your page**
|
|
415
|
+
```html
|
|
416
|
+
<nub-stick></nub-stick>
|
|
417
|
+
```
|
|
418
|
+
- **get the stick device, plug it into your hub or whatever**
|
|
419
|
+
```ts
|
|
420
|
+
const nubStick = document.queryElement<tact.NubStick>("nub-stick")!
|
|
350
421
|
|
|
351
|
-
|
|
352
|
-
|
|
422
|
+
deck.hub.plug(nubStick.device)
|
|
423
|
+
```
|
|
353
424
|
|
|
354
425
|
|
|
355
426
|
|
|
356
427
|
<br/><br/>
|
|
428
|
+
<a id="benev"></a>
|
|
357
429
|
|
|
358
430
|
## 🍋 tact is by https://benevolent.games/
|
|
359
431
|
> *building the future of web games*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@benev/tact",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-4",
|
|
4
4
|
"description": "keybindings and gamepad support for web games",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chase Moskal <chasemoskal@gmail.com>",
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
"lit": "^3.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@benev/math": "^0.2.0-
|
|
36
|
-
"@e280/
|
|
37
|
-
"@e280/
|
|
38
|
-
"@e280/
|
|
35
|
+
"@benev/math": "^0.2.0-4",
|
|
36
|
+
"@e280/kv": "^0.1.0",
|
|
37
|
+
"@e280/sly": "^0.2.0-16",
|
|
38
|
+
"@e280/strata": "^0.2.0-13",
|
|
39
|
+
"@e280/stz": "^0.2.5"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@e280/science": "^0.1.
|
|
42
|
-
"@e280/scute": "^0.
|
|
42
|
+
"@e280/science": "^0.1.2",
|
|
43
|
+
"@e280/scute": "^0.1.0",
|
|
43
44
|
"http-server": "^14.1.1",
|
|
44
45
|
"npm-run-all": "^4.1.5",
|
|
45
46
|
"typescript": "^5.9.2"
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import {sub} from "@e280/stz"
|
|
3
|
+
import {isPressed} from "./parts/is-pressed.js"
|
|
3
4
|
|
|
4
5
|
export class Action {
|
|
6
|
+
on = sub<[Action]>()
|
|
7
|
+
onDown = sub<[Action]>()
|
|
8
|
+
|
|
5
9
|
#value = 0
|
|
6
10
|
#previous = 0
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
get value() {
|
|
13
|
+
return this.#value
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
set value(v: number) {
|
|
17
|
+
this.#previous = this.#value
|
|
18
|
+
this.#value = v
|
|
19
|
+
|
|
20
|
+
this.on.publish(this)
|
|
21
|
+
if (this.down) this.onDown.publish(this)
|
|
11
22
|
}
|
|
12
23
|
|
|
13
|
-
get value() { return this.#value }
|
|
14
24
|
get previous() { return this.#previous }
|
|
15
25
|
get changed() { return this.#value !== this.#previous }
|
|
16
26
|
get pressed() { return isPressed(this.#value) }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import {Code, CodeSettings, CodeState} from "../types.js"
|
|
3
|
+
|
|
4
|
+
export const defaultHoldTime = 250
|
|
5
|
+
|
|
6
|
+
export function defaultCodeState([,,settings]: Code): CodeState {
|
|
7
|
+
return {
|
|
8
|
+
lastValue: 0,
|
|
9
|
+
holdStart: 0,
|
|
10
|
+
settings: defaultifyCodeSettings(settings),
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function defaultCodeSettings(): CodeSettings {
|
|
15
|
+
return {
|
|
16
|
+
scale: 1,
|
|
17
|
+
invert: false,
|
|
18
|
+
range: null,
|
|
19
|
+
bottom: null,
|
|
20
|
+
top: null,
|
|
21
|
+
timing: ["direct"],
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function defaultifyCodeSettings(partial: Partial<CodeSettings> = {}): CodeSettings {
|
|
26
|
+
return {
|
|
27
|
+
...defaultCodeSettings(),
|
|
28
|
+
...partial,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|