@benev/tact 0.1.0-3 → 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 +111 -103
- package/package.json +7 -7
- package/s/core/bindings/action.ts +14 -4
- package/s/core/bindings/parts/defaults.ts +3 -1
- package/s/core/bindings/parts/lens-algo.ts +17 -13
- package/s/core/bindings/resolver.ts +12 -12
- package/s/core/bindings/sample-map.ts +25 -0
- package/s/core/bindings/types.ts +3 -1
- 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 +15 -11
- 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 +5 -6
- package/s/core/index.ts +12 -14
- package/s/core/testing/testing.ts +19 -14
- 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/bindings/action.d.ts +3 -1
- package/x/core/bindings/action.js +12 -4
- package/x/core/bindings/action.js.map +1 -1
- package/x/core/bindings/parts/defaults.js +3 -1
- package/x/core/bindings/parts/defaults.js.map +1 -1
- package/x/core/bindings/parts/lens-algo.js +14 -7
- package/x/core/bindings/parts/lens-algo.js.map +1 -1
- package/x/core/bindings/resolver.d.ts +5 -4
- package/x/core/bindings/resolver.js +12 -10
- package/x/core/bindings/resolver.js.map +1 -1
- 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 +3 -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 +14 -11
- 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/{controllers → devices}/types.js.map +1 -1
- package/x/core/hub/hub.d.ts +27 -23
- 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 +5 -5
- package/x/core/hub/types.js +1 -1
- package/x/core/hub/types.js.map +1 -1
- package/x/core/index.d.ts +12 -12
- package/x/core/index.js +12 -12
- package/x/core/index.js.map +1 -1
- package/x/core/testing/testing.d.ts +13 -11
- package/x/core/testing/testing.js +14 -13
- 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.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 -77
- package/s/core/controllers/standard/keyboard.ts +0 -50
- package/s/core/controllers/standard/stick.ts +0 -30
- package/s/core/deck/deck.ts +0 -40
- package/s/core/deck/parts/bindings-depot.ts +0 -24
- package/s/core/deck/parts/local-storage-kv.ts +0 -7
- package/s/core/hub/auto-gamepads.ts +0 -8
- package/s/core/hub/bindings.ts +0 -18
- package/s/core/port/port.ts +0 -34
- 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 -9
- package/x/core/controllers/standard/gamepad.js +0 -66
- 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 -39
- 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/deck/deck.d.ts +0 -16
- package/x/core/deck/deck.js +0 -31
- package/x/core/deck/deck.js.map +0 -1
- package/x/core/deck/parts/bindings-depot.d.ts +0 -9
- package/x/core/deck/parts/bindings-depot.js +0 -19
- package/x/core/deck/parts/bindings-depot.js.map +0 -1
- package/x/core/deck/parts/local-storage-kv.js +0 -5
- package/x/core/deck/parts/local-storage-kv.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 -16
- package/x/core/hub/bindings.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/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/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/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/{controllers → devices}/types.js +0 -0
- /package/x/{core/deck → deck}/parts/local-storage-kv.d.ts +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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import {html} from "lit"
|
|
3
|
+
import {cssReset, view} from "@e280/sly"
|
|
4
|
+
import styleCss from "./style.css.js"
|
|
5
|
+
import {Hub} from "../../../../core/hub/hub.js"
|
|
6
|
+
import {NubStick} from "../../../../nubs/stick/component.js"
|
|
7
|
+
import {VirtualDevice} from "../../../game/parts/virtual-device.js"
|
|
8
|
+
import {DeviceSkin} from "../../../../deck/parts/device-skins/device-skin.js"
|
|
9
|
+
|
|
10
|
+
export const VirtualDeviceView = view(use => (
|
|
11
|
+
hub: Hub<any>,
|
|
12
|
+
device: VirtualDevice,
|
|
13
|
+
_deviceSkin: DeviceSkin,
|
|
14
|
+
) => {
|
|
15
|
+
|
|
16
|
+
use.styles(cssReset, styleCss)
|
|
17
|
+
use.attrs.string.device = "virtual"
|
|
18
|
+
|
|
19
|
+
const unplug = () => hub.unplug(device)
|
|
20
|
+
|
|
21
|
+
return html`
|
|
22
|
+
<div class=box>
|
|
23
|
+
${NubStick.view(device)}
|
|
24
|
+
|
|
25
|
+
<button @click="${device.shimmyPrevious}">👈</button>
|
|
26
|
+
<button @click="${unplug}">💀</button>
|
|
27
|
+
<button @click="${device.shimmyNext}">👉</button>
|
|
28
|
+
</div>
|
|
29
|
+
`
|
|
30
|
+
})
|
|
31
|
+
|
package/s/index.html.ts
CHANGED
|
@@ -12,9 +12,6 @@ export default ssg.page(import.meta.url, async orb => ({
|
|
|
12
12
|
css: "demo/main.css",
|
|
13
13
|
dark: true,
|
|
14
14
|
favicon,
|
|
15
|
-
head: html`
|
|
16
|
-
<meta data-version="${orb.packageVersion()}" />
|
|
17
|
-
`,
|
|
18
15
|
|
|
19
16
|
socialCard: {
|
|
20
17
|
title,
|
|
@@ -28,15 +25,28 @@ export default ssg.page(import.meta.url, async orb => ({
|
|
|
28
25
|
<header>
|
|
29
26
|
<h1>
|
|
30
27
|
<strong>@benev/tact</strong>
|
|
31
|
-
<
|
|
28
|
+
<small>v${orb.packageVersion()}</small>
|
|
32
29
|
</h1>
|
|
33
30
|
<div class=deets>
|
|
34
|
-
<
|
|
35
|
-
<
|
|
31
|
+
<p><em>"from keypress to couch co-op"</em></p>
|
|
32
|
+
<p>
|
|
33
|
+
tact is a user input toolkit for the web. it's good at customizable keybindings, and multiple gamepad support.
|
|
34
|
+
see <a href="https://github.com/benevolent-games/tact">github</a>,
|
|
35
|
+
see <a href="https://benevolent.games/">benevolent.games</a>.
|
|
36
|
+
</p>
|
|
36
37
|
</div>
|
|
37
38
|
</header>
|
|
38
39
|
|
|
39
40
|
<tact-demo></tact-demo>
|
|
41
|
+
|
|
42
|
+
<section>
|
|
43
|
+
<h3>controls</h3>
|
|
44
|
+
<ul>
|
|
45
|
+
<li><strong>keyboard</strong> wasd, left-bracket, right-bracket, backslash.</li>
|
|
46
|
+
<li><strong>gamepad</strong> thumbsticks, hold beta/gamma and press bumpers or dpad left/right.</li>
|
|
47
|
+
<li><strong>virtual</strong> use your mouse to press the little buttons.</li>
|
|
48
|
+
</ul>
|
|
49
|
+
</section>
|
|
40
50
|
`,
|
|
41
51
|
}))
|
|
42
52
|
|
package/s/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import {dom} from "@e280/sly"
|
|
3
|
+
import {NubLookpad} from "./lookpad/component.js"
|
|
4
|
+
import {NubStick} from "./stick/component.js"
|
|
5
|
+
import {NubVpad} from "./vpad/component.js"
|
|
6
|
+
|
|
7
|
+
export const nubs = () => ({
|
|
8
|
+
NubLookpad,
|
|
9
|
+
NubStick,
|
|
10
|
+
NubVpad,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const registerNubs = () => dom.register(nubs())
|
|
14
|
+
|
package/s/nubs/index.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import {dom, view} from "@e280/sly"
|
|
3
|
+
import {styles} from "./styles.js"
|
|
4
|
+
|
|
5
|
+
const NubLookpadView = view(use => () => {
|
|
6
|
+
use.name("nub-lookpad")
|
|
7
|
+
use.styles(styles)
|
|
8
|
+
|
|
9
|
+
const $captured = use.signal<number | undefined>(undefined)
|
|
10
|
+
|
|
11
|
+
use.mount(() => dom.events(use.element, {
|
|
12
|
+
pointerdown: (event: PointerEvent) => {
|
|
13
|
+
event.preventDefault()
|
|
14
|
+
if ($captured.value)
|
|
15
|
+
use.element.releasePointerCapture($captured.value)
|
|
16
|
+
|
|
17
|
+
use.element.setPointerCapture(event.pointerId)
|
|
18
|
+
$captured.value = event.pointerId
|
|
19
|
+
// onPointerDrag(event)
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
pointermove: [{passive: false}, (event: PointerEvent) => {
|
|
23
|
+
event.preventDefault()
|
|
24
|
+
if (event.pointerId === $captured.value) {
|
|
25
|
+
// onPointerDrag(event)
|
|
26
|
+
}
|
|
27
|
+
}],
|
|
28
|
+
|
|
29
|
+
pointerup: (event: PointerEvent) => {
|
|
30
|
+
event.preventDefault()
|
|
31
|
+
if (event.pointerId === $captured.value) {
|
|
32
|
+
use.element.releasePointerCapture($captured.value)
|
|
33
|
+
$captured.value = undefined
|
|
34
|
+
// onPointerDrag(event)
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export class NubLookpad extends (
|
|
41
|
+
NubLookpadView
|
|
42
|
+
.component()
|
|
43
|
+
.props(() => [])
|
|
44
|
+
) {}
|
|
45
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
|
|
2
|
+
import {html} from "lit"
|
|
3
|
+
import {coalesce, nap} from "@e280/stz"
|
|
4
|
+
import {Scalar, Vec2} from "@benev/math"
|
|
5
|
+
import {BaseElement, cssReset, dom, view} from "@e280/sly"
|
|
6
|
+
|
|
7
|
+
import styleCss from "./style.css.js"
|
|
8
|
+
import {circularClamp} from "../../utils/circular-clamp.js"
|
|
9
|
+
import {StickDevice} from "../../core/devices/standard/stick.js"
|
|
10
|
+
|
|
11
|
+
const NubStickView = view(use => ({$vector}: StickDevice) => {
|
|
12
|
+
use.name("nub-stick")
|
|
13
|
+
use.css(cssReset, styleCss)
|
|
14
|
+
|
|
15
|
+
const range = use.once(() => new Vec2(0.2, 0.8))
|
|
16
|
+
const $captured = use.signal<number | undefined>(undefined)
|
|
17
|
+
|
|
18
|
+
use.mount(() => {
|
|
19
|
+
function recalc(event: PointerEvent) {
|
|
20
|
+
const rect = use.element.getBoundingClientRect()
|
|
21
|
+
const vector = $vector.get()
|
|
22
|
+
vector.x = Scalar.remap(event.clientX, rect.left, rect.right, -1, 1)
|
|
23
|
+
vector.y = Scalar.remap(event.clientY, rect.top, rect.bottom, -1, 1)
|
|
24
|
+
vector.set(circularClamp(vector, range))
|
|
25
|
+
$vector.publish()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function release() {
|
|
29
|
+
if ($captured.value === undefined) return
|
|
30
|
+
$vector.get().set_(0, 0)
|
|
31
|
+
$vector.publish()
|
|
32
|
+
|
|
33
|
+
// fix for ridiculous firefox bug,
|
|
34
|
+
// where our captured pointerup was clicking outside buttons
|
|
35
|
+
nap(0).then(() => {
|
|
36
|
+
if ($captured.value === undefined) return
|
|
37
|
+
use.element.releasePointerCapture($captured.value)
|
|
38
|
+
$captured.value = undefined
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return coalesce(
|
|
43
|
+
|
|
44
|
+
// fix for ridiculous firefox bug
|
|
45
|
+
dom.events(document.body, {
|
|
46
|
+
click: [{capture: true}, (event: Event) => {
|
|
47
|
+
if ($captured.value === undefined) return
|
|
48
|
+
event.preventDefault()
|
|
49
|
+
event.stopPropagation()
|
|
50
|
+
}],
|
|
51
|
+
}),
|
|
52
|
+
|
|
53
|
+
dom.events(use.element, {
|
|
54
|
+
pointerdown: (event: PointerEvent) => {
|
|
55
|
+
if ($captured.value === undefined) {
|
|
56
|
+
$captured.value = event.pointerId
|
|
57
|
+
use.element.setPointerCapture($captured.value)
|
|
58
|
+
recalc(event)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
pointermove: [{}, (event: PointerEvent) => {
|
|
62
|
+
if ($captured.value !== undefined)
|
|
63
|
+
recalc(event)
|
|
64
|
+
}],
|
|
65
|
+
pointerup: release,
|
|
66
|
+
pointercancel: release,
|
|
67
|
+
})
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const vector = $vector.get()
|
|
72
|
+
const innerstyle = `width: ${range.x * 100}%;`
|
|
73
|
+
const outerstyle = `width: ${range.y * 100}%;`
|
|
74
|
+
|
|
75
|
+
const framestyle = (factor: number) => {
|
|
76
|
+
const f = factor * 0.5
|
|
77
|
+
const x = f * vector.x * 100
|
|
78
|
+
const y = f * vector.y * 100
|
|
79
|
+
return `
|
|
80
|
+
transform-origin: center center;
|
|
81
|
+
transform: translate(${x}%, ${y}%);
|
|
82
|
+
`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return html`
|
|
86
|
+
<div class=frame>
|
|
87
|
+
<div class=inner style="${innerstyle}"></div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class=frame>
|
|
91
|
+
<div class=outer style="${outerstyle}"></div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class=frame>
|
|
95
|
+
<div class=stickbase></div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class=frame style="${framestyle(0.5)}">
|
|
99
|
+
<div class=stickunder></div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div class=frame style="${framestyle(1.0)}">
|
|
103
|
+
<div class=stick></div>
|
|
104
|
+
</div>
|
|
105
|
+
`
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
export class NubStick extends (
|
|
109
|
+
NubStickView
|
|
110
|
+
.component(class extends BaseElement {
|
|
111
|
+
readonly device = new StickDevice()
|
|
112
|
+
})
|
|
113
|
+
.props(el => [el.device])
|
|
114
|
+
) {}
|
|
115
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
import {css} from "lit"
|
|
3
|
+
export default css`
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
--nub-size: 60%;
|
|
7
|
+
--nub-color: #fff8;
|
|
8
|
+
|
|
9
|
+
position: relative;
|
|
10
|
+
display: block;
|
|
11
|
+
|
|
12
|
+
cursor: default;
|
|
13
|
+
user-select: none;
|
|
14
|
+
|
|
15
|
+
width: 6em;
|
|
16
|
+
height: auto;
|
|
17
|
+
aspect-ratio: 1 / 1;
|
|
18
|
+
|
|
19
|
+
background: #0008;
|
|
20
|
+
border-radius: 100%;
|
|
21
|
+
outline: 1px solid color-mix(in srgb, transparent, var(--nub-color) 10%);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host * {
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.frame {
|
|
29
|
+
position: absolute;
|
|
30
|
+
inset: 0;
|
|
31
|
+
margin: auto;
|
|
32
|
+
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: auto;
|
|
35
|
+
aspect-ratio: 1 / 1;
|
|
36
|
+
|
|
37
|
+
> div {
|
|
38
|
+
position: absolute;
|
|
39
|
+
inset: 0;
|
|
40
|
+
margin: auto;
|
|
41
|
+
width: var(--nub-size);
|
|
42
|
+
height: auto;
|
|
43
|
+
aspect-ratio: 1 / 1;
|
|
44
|
+
border-radius: 100%;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.inner {
|
|
49
|
+
outline: 1px solid color-mix(in srgb, transparent, var(--nub-color) 10%);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.outer {
|
|
53
|
+
outline: 1px solid color-mix(in srgb, transparent, var(--nub-color) 10%);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.stickbase {
|
|
57
|
+
display: none;
|
|
58
|
+
background: color-mix(in srgb, transparent, var(--nub-color) 25%);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.stickunder {
|
|
62
|
+
background: color-mix(in srgb, transparent, var(--nub-color) 50%);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.stick {
|
|
66
|
+
background: #fff8;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
`
|
|
70
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
import {html} from "lit"
|
|
3
|
-
import {view} from "@e280/sly"
|
|
3
|
+
import {BaseElement, view} from "@e280/sly"
|
|
4
4
|
import {ev, MapG} from "@e280/stz"
|
|
5
5
|
|
|
6
6
|
import stylesCss from "./styles.css.js"
|
|
7
7
|
|
|
8
|
-
import {NubStick} from "../stick/
|
|
8
|
+
import {NubStick} from "../stick/component.js"
|
|
9
9
|
import {GamepadInputs} from "./utils/gamepad-inputs.js"
|
|
10
10
|
import {touchTracking} from "./utils/touch-tracking.js"
|
|
11
|
-
import {
|
|
11
|
+
import {VpadDevice} from "../../core/devices/standard/vpad.js"
|
|
12
12
|
import {preventDefaultTouchShenanigans} from "./utils/prevent-default-touch-shenanigans.js"
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
use.name("
|
|
14
|
+
const NubVpadView = view(use => (device: VpadDevice) => {
|
|
15
|
+
use.name("nub-vpad")
|
|
16
16
|
use.css(stylesCss)
|
|
17
17
|
|
|
18
18
|
const buttons = use.once(() => new Set<HTMLButtonElement>())
|
|
@@ -38,11 +38,11 @@ export const VirtualGamepad = view(use => (controller: VirtualGamepadController)
|
|
|
38
38
|
buttons,
|
|
39
39
|
touchdown: button => {
|
|
40
40
|
const code = codes.require(button)
|
|
41
|
-
|
|
41
|
+
device.setSample(code, 1)
|
|
42
42
|
},
|
|
43
43
|
touchup: button => {
|
|
44
44
|
const code = codes.require(button)
|
|
45
|
-
|
|
45
|
+
device.setSample(code, 0)
|
|
46
46
|
},
|
|
47
47
|
}))
|
|
48
48
|
|
|
@@ -121,19 +121,29 @@ export const VirtualGamepad = view(use => (controller: VirtualGamepadController)
|
|
|
121
121
|
<div class="left side">
|
|
122
122
|
${renderLeftShoulder()}
|
|
123
123
|
${renderDPad()}
|
|
124
|
-
${NubStick
|
|
124
|
+
${NubStick.view
|
|
125
|
+
.props(device.stickLeft)
|
|
125
126
|
.attr("class", "stick")
|
|
126
|
-
.
|
|
127
|
+
.render()}
|
|
127
128
|
</div>
|
|
128
129
|
|
|
129
130
|
<div class="right side">
|
|
130
131
|
${renderRightShoulder()}
|
|
131
132
|
${renderButtonPad()}
|
|
132
|
-
${NubStick
|
|
133
|
+
${NubStick.view
|
|
134
|
+
.props(device.stickRight)
|
|
133
135
|
.attr("class", "stick")
|
|
134
|
-
.
|
|
136
|
+
.render()}
|
|
135
137
|
</div>
|
|
136
138
|
</div>
|
|
137
139
|
`
|
|
138
140
|
})
|
|
139
141
|
|
|
142
|
+
export class NubVpad extends (
|
|
143
|
+
NubVpadView
|
|
144
|
+
.component(class extends BaseElement {
|
|
145
|
+
readonly device = new VpadDevice()
|
|
146
|
+
})
|
|
147
|
+
.props(el => [el.device])
|
|
148
|
+
) {}
|
|
149
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {Scalar, Vec2, Xy} from "@benev/math"
|
|
3
|
+
|
|
4
|
+
export function circularClamp(vector: Xy, range: Vec2) {
|
|
5
|
+
const v = Vec2.from(vector)
|
|
6
|
+
const distance = v.distance_(0, 0)
|
|
7
|
+
const modifiedDistance = Scalar.remap(
|
|
8
|
+
distance,
|
|
9
|
+
range.x, range.y,
|
|
10
|
+
0, 1,
|
|
11
|
+
true,
|
|
12
|
+
)
|
|
13
|
+
return v.normalize().multiplyBy(modifiedDistance)
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import {Dispenser, range} from "@e280/stz"
|
|
3
|
+
|
|
4
|
+
const palette = (n: number) => range(n).map(i => {
|
|
5
|
+
const d = (i * (360 / n)) + 180
|
|
6
|
+
return `hsl(${d % 360}deg, 100%, 50%)`
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export class ColorDispenser extends Dispenser<string> {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(() => palette(12))
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class LetterDispenser extends Dispenser<string> {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(() => [..."abcdefghijklmnopqrstuvwxyz"])
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
package/s/utils/split-axis.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
|
|
2
|
+
import {Xy} from "@benev/math"
|
|
3
|
+
|
|
2
4
|
export function splitAxis(n: number) {
|
|
3
5
|
return (n >= 0)
|
|
4
|
-
? [
|
|
5
|
-
: [Math.abs(n)
|
|
6
|
+
? [n, 0]
|
|
7
|
+
: [0, Math.abs(n)]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function splitVector(vector: Xy) {
|
|
11
|
+
const [right, left] = splitAxis(vector.x)
|
|
12
|
+
const [down, up] = splitAxis(vector.y)
|
|
13
|
+
return {up, down, left, right}
|
|
6
14
|
}
|
|
7
15
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare class Action {
|
|
2
2
|
#private;
|
|
3
|
-
|
|
3
|
+
on: import("@e280/stz").Sub<[Action]>;
|
|
4
|
+
onDown: import("@e280/stz").Sub<[Action]>;
|
|
4
5
|
get value(): number;
|
|
6
|
+
set value(v: number);
|
|
5
7
|
get previous(): number;
|
|
6
8
|
get changed(): boolean;
|
|
7
9
|
get pressed(): boolean;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { sub } from "@e280/stz";
|
|
1
2
|
import { isPressed } from "./parts/is-pressed.js";
|
|
2
3
|
export class Action {
|
|
4
|
+
on = sub();
|
|
5
|
+
onDown = sub();
|
|
3
6
|
#value = 0;
|
|
4
7
|
#previous = 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
get value() {
|
|
9
|
+
return this.#value;
|
|
10
|
+
}
|
|
11
|
+
set value(v) {
|
|
12
|
+
this.#previous = this.#value;
|
|
13
|
+
this.#value = v;
|
|
14
|
+
this.on.publish(this);
|
|
15
|
+
if (this.down)
|
|
16
|
+
this.onDown.publish(this);
|
|
8
17
|
}
|
|
9
|
-
get value() { return this.#value; }
|
|
10
18
|
get previous() { return this.#previous; }
|
|
11
19
|
get changed() { return this.#value !== this.#previous; }
|
|
12
20
|
get pressed() { return isPressed(this.#value); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../s/core/bindings/action.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,MAAM,OAAO,MAAM;IAClB,MAAM,GAAG,CAAC,CAAA;IACV,SAAS,GAAG,CAAC,CAAA;IAEb,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../s/core/bindings/action.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,MAAM,OAAO,MAAM;IAClB,EAAE,GAAG,GAAG,EAAY,CAAA;IACpB,MAAM,GAAG,GAAG,EAAY,CAAA;IAExB,MAAM,GAAG,CAAC,CAAA;IACV,SAAS,GAAG,CAAC,CAAA;IAEb,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,CAAS;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QAEf,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACrB,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC;IAC/C,IAAI,IAAI,KAAK,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC;IAC1E,IAAI,EAAE,KAAK,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC;CACxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../s/core/bindings/parts/defaults.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC,MAAM,UAAU,gBAAgB,CAAC,CAAC,EAAC,EAAC,QAAQ,CAAO;IAClD,OAAO;QACN,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,CAAC;KAC1C,CAAA;AACF,CAAC;AAED,SAAS,mBAAmB;IAC3B,OAAO;QACN,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,KAAK;QACb,
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../s/core/bindings/parts/defaults.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC,MAAM,UAAU,gBAAgB,CAAC,CAAC,EAAC,EAAC,QAAQ,CAAO;IAClD,OAAO;QACN,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,CAAC;KAC1C,CAAA;AACF,CAAC;AAED,SAAS,mBAAmB;IAC3B,OAAO;QACN,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,CAAC,QAAQ,CAAC;KAClB,CAAA;AACF,CAAC;AAED,SAAS,sBAAsB,CAAC,UAAiC,EAAE;IAClE,OAAO;QACN,GAAG,mBAAmB,EAAE;QACxB,GAAG,OAAO;KACV,CAAA;AACF,CAAC"}
|
|
@@ -2,15 +2,22 @@ import { pipe } from "@e280/stz";
|
|
|
2
2
|
import { Scalar } from "@benev/math";
|
|
3
3
|
import { isPressed } from "./is-pressed.js";
|
|
4
4
|
import { defaultHoldTime } from "./defaults.js";
|
|
5
|
-
export const lensAlgo = (now, state, v) => pipe(v).line(function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const lensAlgo = (now, state, v) => pipe(v).line(function clippings(value) {
|
|
6
|
+
const { settings } = state;
|
|
7
|
+
if (settings.range) {
|
|
8
|
+
const [bottom, top] = settings.range;
|
|
9
|
+
value = Scalar.isBetween(value, bottom, top)
|
|
10
|
+
? Scalar.remap(value, bottom, top, 0, 1, true)
|
|
11
|
+
: 0;
|
|
12
|
+
}
|
|
13
|
+
if (settings.bottom)
|
|
14
|
+
value = Math.max(settings.bottom, value);
|
|
15
|
+
if (settings.top)
|
|
16
|
+
value = Math.min(settings.top, value);
|
|
17
|
+
return value;
|
|
11
18
|
}, function inversion(value) {
|
|
12
19
|
return state.settings.invert
|
|
13
|
-
?
|
|
20
|
+
? 1 - value
|
|
14
21
|
: value;
|
|
15
22
|
}, function scaling(value) {
|
|
16
23
|
return state.settings.scale * value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens-algo.js","sourceRoot":"","sources":["../../../../s/core/bindings/parts/lens-algo.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAA;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,GAAW,EACX,KAAgB,EAChB,CAAS,EACR,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAEjB,SAAS,
|
|
1
|
+
{"version":3,"file":"lens-algo.js","sourceRoot":"","sources":["../../../../s/core/bindings/parts/lens-algo.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { SampleMap } from "
|
|
1
|
+
import { SampleMap } from "./sample-map.js";
|
|
2
2
|
import { Actions, Bindings } from "./types.js";
|
|
3
3
|
export declare class Resolver<B extends Bindings> {
|
|
4
4
|
#private;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
bindings: B;
|
|
6
|
+
readonly actions: Actions<B>;
|
|
7
|
+
constructor(bindings: B);
|
|
8
|
+
resolve(now: number, modes: Set<keyof B>, sampleMap: SampleMap): Actions<B>;
|
|
8
9
|
}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import { MapG, pub, obMap } from "@e280/stz";
|
|
2
2
|
import { Action } from "./action.js";
|
|
3
|
+
import { SampleMap } from "./sample-map.js";
|
|
3
4
|
import { lensAlgo } from "./parts/lens-algo.js";
|
|
4
5
|
import { tmax, tmin } from "../../utils/quick-math.js";
|
|
5
6
|
import { defaultCodeState } from "./parts/defaults.js";
|
|
6
7
|
export class Resolver {
|
|
7
8
|
bindings;
|
|
8
|
-
|
|
9
|
+
actions;
|
|
10
|
+
#modes = new Set();
|
|
11
|
+
#sampleMap = new SampleMap();
|
|
9
12
|
#now = 0;
|
|
10
|
-
#samples = new Map();
|
|
11
13
|
#codeStates = new MapG();
|
|
12
14
|
#update = pub();
|
|
13
|
-
constructor(bindings
|
|
15
|
+
constructor(bindings) {
|
|
14
16
|
this.bindings = bindings;
|
|
15
|
-
this
|
|
17
|
+
this.actions = obMap(bindings, (bracket, mode) => obMap(bracket, atom => {
|
|
16
18
|
const action = new Action();
|
|
17
19
|
this.#update.subscribe(() => {
|
|
18
|
-
|
|
20
|
+
action.value = this.#modes.has(mode)
|
|
19
21
|
? this.#resolveAtom()(atom)
|
|
20
22
|
: 0;
|
|
21
|
-
Action.update(action, value);
|
|
22
23
|
});
|
|
23
24
|
return action;
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
resolve(now, modes, sampleMap) {
|
|
27
28
|
this.#now = now;
|
|
28
|
-
this.#
|
|
29
|
+
this.#modes = modes;
|
|
30
|
+
this.#sampleMap = sampleMap;
|
|
29
31
|
this.#update();
|
|
30
|
-
return this
|
|
32
|
+
return this.actions;
|
|
31
33
|
}
|
|
32
34
|
#resolveCode(count, code, settings) {
|
|
33
35
|
const state = this.#codeStates.guarantee(count, () => defaultCodeState(["code", code, settings]));
|
|
34
|
-
const value = this.#
|
|
36
|
+
const value = this.#sampleMap.get(code) ?? 0;
|
|
35
37
|
return lensAlgo(this.#now, state, value);
|
|
36
38
|
}
|
|
37
39
|
#resolveAtom = (context = { count: 0 }) => (atom) => {
|