@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
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {tmax} from "../../../utils/quick-math.js"
|
|
3
|
-
import {splitAxis} from "../../../utils/split-axis.js"
|
|
4
|
-
import {SamplerController} from "../infra/sampler.js"
|
|
5
|
-
import {gamepads, Pad} from "../../../utils/gamepads.js"
|
|
6
|
-
|
|
7
|
-
const gamepadButtonCodes = [
|
|
8
|
-
"gamepad.a",
|
|
9
|
-
"gamepad.b",
|
|
10
|
-
"gamepad.x",
|
|
11
|
-
"gamepad.y",
|
|
12
|
-
"gamepad.bumper.left",
|
|
13
|
-
"gamepad.bumper.right",
|
|
14
|
-
"gamepad.trigger.left",
|
|
15
|
-
"gamepad.trigger.right",
|
|
16
|
-
"gamepad.alpha",
|
|
17
|
-
"gamepad.beta",
|
|
18
|
-
"gamepad.stick.left.click",
|
|
19
|
-
"gamepad.stick.right.click",
|
|
20
|
-
"gamepad.up",
|
|
21
|
-
"gamepad.down",
|
|
22
|
-
"gamepad.left",
|
|
23
|
-
"gamepad.right",
|
|
24
|
-
"gamepad.gamma",
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
export class GamepadController extends SamplerController {
|
|
28
|
-
static on(fn: (controller: GamepadController) => () => void) {
|
|
29
|
-
return gamepads(pad => fn(new this(pad)))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
constructor(public pad: Pad) {
|
|
33
|
-
super()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get gamepad() {
|
|
37
|
-
return this.pad.gamepad
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
takeSamples() {
|
|
41
|
-
const {gamepad} = this.pad
|
|
42
|
-
this.#pollButtons(gamepad)
|
|
43
|
-
this.#pollSticks(gamepad)
|
|
44
|
-
return super.takeSamples()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
#pollButtons(gamepad: Gamepad) {
|
|
48
|
-
let anyButtonValue = 0
|
|
49
|
-
|
|
50
|
-
const recordAny = (value: number) => {
|
|
51
|
-
anyButtonValue = tmax([anyButtonValue, value])
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
for (const [index, code] of gamepadButtonCodes.entries()) {
|
|
55
|
-
const value = gamepad.buttons.at(index)?.value ?? 0
|
|
56
|
-
recordAny(value)
|
|
57
|
-
this.setSample(code, value)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.setSample("gamepad.any", anyButtonValue)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#pollSticks(gamepad: Gamepad) {
|
|
64
|
-
const [leftY, leftX, rightY, rightX] = gamepad.axes
|
|
65
|
-
|
|
66
|
-
const [leftUp, leftDown] = splitAxis(leftX)
|
|
67
|
-
const [leftLeft, leftRight] = splitAxis(leftY)
|
|
68
|
-
this.setSample("gamepad.stick.left.up", leftUp)
|
|
69
|
-
this.setSample("gamepad.stick.left.down", leftDown)
|
|
70
|
-
this.setSample("gamepad.stick.left.left", leftLeft)
|
|
71
|
-
this.setSample("gamepad.stick.left.right", leftRight)
|
|
72
|
-
|
|
73
|
-
const [rightUp, rightDown] = splitAxis(rightX)
|
|
74
|
-
const [rightLeft, rightRight] = splitAxis(rightY)
|
|
75
|
-
this.setSample("gamepad.stick.right.up", rightUp)
|
|
76
|
-
this.setSample("gamepad.stick.right.down", rightDown)
|
|
77
|
-
this.setSample("gamepad.stick.right.left", rightLeft)
|
|
78
|
-
this.setSample("gamepad.stick.right.right", rightRight)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {coalesce, ev, sub} from "@e280/stz"
|
|
3
|
-
import {Sample} from "../types.js"
|
|
4
|
-
import {Controller} from "../controller.js"
|
|
5
|
-
import {modprefix} from "../utils/modprefix.js"
|
|
6
|
-
|
|
7
|
-
export class KeyboardController extends Controller {
|
|
8
|
-
on = sub<Sample>()
|
|
9
|
-
dispose: () => void
|
|
10
|
-
#held = new Set<string>()
|
|
11
|
-
|
|
12
|
-
constructor(target: EventTarget = window) {
|
|
13
|
-
super()
|
|
14
|
-
|
|
15
|
-
const down = (code: string) => {
|
|
16
|
-
this.#held.add(code)
|
|
17
|
-
this.on.pub(code, 1)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const up = (code: string) => {
|
|
21
|
-
this.#held.delete(code)
|
|
22
|
-
this.on.pub(code, 0)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
this.dispose = coalesce(
|
|
26
|
-
ev(target, {
|
|
27
|
-
keydown: (event: KeyboardEvent) => {
|
|
28
|
-
if (event.repeat) return
|
|
29
|
-
down(event.code)
|
|
30
|
-
down(modprefix(event, event.code))
|
|
31
|
-
},
|
|
32
|
-
keyup: (event: KeyboardEvent) => {
|
|
33
|
-
up(event.code)
|
|
34
|
-
up(modprefix(event, event.code))
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
ev(window, {
|
|
39
|
-
blur: () => {
|
|
40
|
-
for (const code of this.#held)
|
|
41
|
-
this.on.pub(code, 0)
|
|
42
|
-
this.#held.clear()
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
takeSamples() {
|
|
49
|
-
return [...this.#held]
|
|
50
|
-
.map(code => [code, 1] as Sample)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Vec2} from "@benev/math"
|
|
3
|
-
import {signal} from "@e280/strata"
|
|
4
|
-
import {Disposable} from "@e280/stz"
|
|
5
|
-
import {SamplerController} from "../infra/sampler.js"
|
|
6
|
-
import {splitAxis} from "../../../utils/split-axis.js"
|
|
7
|
-
|
|
8
|
-
export class StickController extends SamplerController implements Disposable {
|
|
9
|
-
vector = signal(Vec2.zero())
|
|
10
|
-
dispose: () => void
|
|
11
|
-
|
|
12
|
-
constructor(public channel = "stick") {
|
|
13
|
-
super()
|
|
14
|
-
this.dispose = this.vector.on(() => {
|
|
15
|
-
const {up, down, left, right} = this.breakdown()
|
|
16
|
-
this.setSample(`${channel}.up`, up)
|
|
17
|
-
this.setSample(`${channel}.down`, down)
|
|
18
|
-
this.setSample(`${channel}.left`, left)
|
|
19
|
-
this.setSample(`${channel}.right`, right)
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
breakdown() {
|
|
24
|
-
const {x, y} = this.vector.get()
|
|
25
|
-
const [down, up] = splitAxis(y)
|
|
26
|
-
const [left, right] = splitAxis(x)
|
|
27
|
-
return {up, down, left, right}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export function modprefix(event: KeyboardEvent | PointerEvent | WheelEvent, code: string) {
|
|
3
|
-
const modifiers: string[] = []
|
|
4
|
-
|
|
5
|
-
if (event.ctrlKey) modifiers.push("ctrl")
|
|
6
|
-
if (event.altKey) modifiers.push("alt")
|
|
7
|
-
if (event.metaKey) modifiers.push("meta")
|
|
8
|
-
if (event.shiftKey) modifiers.push("shift")
|
|
9
|
-
|
|
10
|
-
const prefix = modifiers.length > 0
|
|
11
|
-
? [...modifiers].join("-")
|
|
12
|
-
: "x"
|
|
13
|
-
|
|
14
|
-
return `${prefix}-${code}`
|
|
15
|
-
}
|
|
16
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {gamepads} from "../../utils/gamepads.js"
|
|
3
|
-
import {GamepadController} from "../controllers/standard/gamepad.js"
|
|
4
|
-
|
|
5
|
-
export function autoGamepads(fn: (controller: GamepadController) => () => void) {
|
|
6
|
-
return gamepads(pad => fn(new GamepadController(pad)))
|
|
7
|
-
}
|
|
8
|
-
|
package/s/core/hub/bindings.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Hub} from "./hub.js"
|
|
3
|
-
import {AsHubBindings, Bindings} from "../bindings/types.js"
|
|
4
|
-
|
|
5
|
-
export function hubBindings<B extends Bindings>(b: B): AsHubBindings<B> {
|
|
6
|
-
return {
|
|
7
|
-
...b,
|
|
8
|
-
[Hub.mode]: {
|
|
9
|
-
shimmyNext: [
|
|
10
|
-
{lenses: [{code: "BracketRight"}]},
|
|
11
|
-
{lenses: [{code: "gamepad.right"}], required: [{code: "gamepad.gamma"}]},
|
|
12
|
-
{lenses: [{code: "gamepad.bumper.right"}], required: [{code: "gamepad.gamma"}]},
|
|
13
|
-
],
|
|
14
|
-
shimmyPrevious: [
|
|
15
|
-
{lenses: [{code: "BracketLeft"}]},
|
|
16
|
-
{lenses: [{code: "gamepad.left"}], required: [{code: "gamepad.gamma"}]},
|
|
17
|
-
{lenses: [{code: "gamepad.bumper.left"}], required: [{code: "gamepad.gamma"}]},
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
}
|
package/s/core/port/port.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {SetG} from "@e280/stz"
|
|
3
|
-
import {Bindings} from "../bindings/types.js"
|
|
4
|
-
import {SampleMap} from "../controllers/types.js"
|
|
5
|
-
import {Resolver} from "./resolution/resolver.js"
|
|
6
|
-
import {Controller} from "../controllers/controller.js"
|
|
7
|
-
import {wipe_samples_map} from "./utils/wipe_samples_map.js"
|
|
8
|
-
import {aggregate_samples_into_map} from "./utils/aggregate_samples_into_map.js"
|
|
9
|
-
|
|
10
|
-
export class Port<B extends Bindings> {
|
|
11
|
-
readonly modes = new SetG<keyof B>()
|
|
12
|
-
readonly controllers = new SetG<Controller>()
|
|
13
|
-
#resolver: Resolver<B>
|
|
14
|
-
#samples: SampleMap = new Map()
|
|
15
|
-
|
|
16
|
-
constructor(bindings: B) {
|
|
17
|
-
this.#resolver = new Resolver(bindings, this.modes)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get bindings() {
|
|
21
|
-
return this.#resolver.bindings
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
set bindings(b: B) {
|
|
25
|
-
this.#resolver = new Resolver(b, this.modes)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
poll(now: number = Date.now()) {
|
|
29
|
-
wipe_samples_map(this.#samples)
|
|
30
|
-
aggregate_samples_into_map(this.controllers, this.#samples)
|
|
31
|
-
return this.#resolver.poll(now, this.#samples)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {LensState} from "./types.js"
|
|
3
|
-
import {Lens, LensSettings} from "../../bindings/types.js"
|
|
4
|
-
|
|
5
|
-
export const defaultHoldTime = 250
|
|
6
|
-
|
|
7
|
-
export function defaultLensState(lens: Lens): LensState {
|
|
8
|
-
return {
|
|
9
|
-
lastValue: 0,
|
|
10
|
-
holdStart: 0,
|
|
11
|
-
settings: defaultifyLensSettings(lens.settings),
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function defaultLensSettings(): LensSettings {
|
|
16
|
-
return {
|
|
17
|
-
scale: 1,
|
|
18
|
-
invert: false,
|
|
19
|
-
deadzone: 0.2,
|
|
20
|
-
timing: {style: "direct"},
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function defaultifyLensSettings(partial: Partial<LensSettings> = {}): LensSettings {
|
|
25
|
-
return {
|
|
26
|
-
...defaultLensSettings(),
|
|
27
|
-
...partial,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {obMap, pub, WeakMapG} from "@e280/stz"
|
|
3
|
-
|
|
4
|
-
import {Actions} from "../types.js"
|
|
5
|
-
import {Action} from "../action.js"
|
|
6
|
-
import {LensState} from "./types.js"
|
|
7
|
-
import {lensAlgo} from "./lens-algo.js"
|
|
8
|
-
import {defaultLensState} from "./defaults.js"
|
|
9
|
-
import {tmax} from "../../../utils/quick-math.js"
|
|
10
|
-
import {SampleMap} from "../../controllers/types.js"
|
|
11
|
-
import {Bindings, Fork, Lens, Spoon} from "../../bindings/types.js"
|
|
12
|
-
|
|
13
|
-
export class Resolver<B extends Bindings> {
|
|
14
|
-
#actions: Actions<B>
|
|
15
|
-
#modes: Set<keyof B>
|
|
16
|
-
|
|
17
|
-
#now = 0
|
|
18
|
-
#samples: SampleMap = new Map()
|
|
19
|
-
#lensStates = new WeakMapG<Lens, LensState>()
|
|
20
|
-
#update = pub()
|
|
21
|
-
|
|
22
|
-
constructor(public readonly bindings: B, modes: Set<keyof B>) {
|
|
23
|
-
this.#modes = modes
|
|
24
|
-
this.#actions = obMap(bindings, (bracket, mode) => obMap(bracket, fork => {
|
|
25
|
-
const action = new Action()
|
|
26
|
-
this.#update.subscribe(() => {
|
|
27
|
-
Action.update(action, this.#resolveFork(fork, mode))
|
|
28
|
-
})
|
|
29
|
-
return action
|
|
30
|
-
})) as Actions<B>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
poll(now: number, samples: SampleMap) {
|
|
34
|
-
this.#now = now
|
|
35
|
-
this.#samples = samples
|
|
36
|
-
this.#update()
|
|
37
|
-
return this.#actions
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#resolveFork = (fork: Fork, mode: keyof B) => {
|
|
41
|
-
return (this.#modes.has(mode))
|
|
42
|
-
? tmax(fork.map(this.#resolveSpoon))
|
|
43
|
-
: 0
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
#resolveSpoon = (spoon: Spoon) => {
|
|
47
|
-
const {lenses, required = [], forbidden = []} = spoon
|
|
48
|
-
|
|
49
|
-
const satisfiedRequirements = () => {
|
|
50
|
-
if (required.length === 0) return true
|
|
51
|
-
const requiredValues = required.map(this.#resolveLens)
|
|
52
|
-
return !requiredValues.some(value => value <= 0)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const satisfiedForbiddens = () => {
|
|
56
|
-
if (forbidden.length === 0) return true
|
|
57
|
-
const forbiddenValues = forbidden.map(this.#resolveLens)
|
|
58
|
-
return !forbiddenValues.some(value => value > 0)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const combineValues = () => {
|
|
62
|
-
const values = lenses.map(this.#resolveLens)
|
|
63
|
-
return tmax(values)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (satisfiedRequirements() && satisfiedForbiddens())
|
|
67
|
-
? combineValues()
|
|
68
|
-
: 0
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
#resolveLens = (lens: Lens) => {
|
|
72
|
-
const state = this.#lensStates.guarantee(lens, () => defaultLensState(lens))
|
|
73
|
-
const v = this.#samples.get(lens.code) ?? 0
|
|
74
|
-
return lensAlgo(this.#now, state, v)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
package/s/core/port/types.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {SampleMap} from "../../controllers/types.js"
|
|
3
|
-
import {Controller} from "../../controllers/controller.js"
|
|
4
|
-
|
|
5
|
-
export function aggregate_samples_into_map(
|
|
6
|
-
controllers: Set<Controller>,
|
|
7
|
-
map: SampleMap,
|
|
8
|
-
) {
|
|
9
|
-
|
|
10
|
-
for (const controller of controllers) {
|
|
11
|
-
for (const [code, value] of controller.takeSamples()) {
|
|
12
|
-
const previous = map.get(code) ?? 0
|
|
13
|
-
if (value > previous)
|
|
14
|
-
map.set(code, value)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return map
|
|
19
|
-
}
|
|
20
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export function lookpad_listeners({
|
|
3
|
-
onPointerDrag,
|
|
4
|
-
getPointerCaptureElement,
|
|
5
|
-
}: {
|
|
6
|
-
onPointerDrag: (event: PointerEvent) => void
|
|
7
|
-
getPointerCaptureElement: () => HTMLElement
|
|
8
|
-
}) {
|
|
9
|
-
|
|
10
|
-
let pointer_id: number | undefined
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
pointerdown: {
|
|
14
|
-
options: undefined,
|
|
15
|
-
handleEvent: (event: PointerEvent) => {
|
|
16
|
-
event.preventDefault()
|
|
17
|
-
|
|
18
|
-
const element = getPointerCaptureElement()
|
|
19
|
-
|
|
20
|
-
if (pointer_id)
|
|
21
|
-
element.releasePointerCapture(pointer_id)
|
|
22
|
-
|
|
23
|
-
pointer_id = event.pointerId
|
|
24
|
-
element.setPointerCapture(pointer_id)
|
|
25
|
-
onPointerDrag(event)
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
pointermove: {
|
|
30
|
-
options: {passive: false},
|
|
31
|
-
handleEvent: (event: PointerEvent) => {
|
|
32
|
-
event.preventDefault()
|
|
33
|
-
|
|
34
|
-
if (event.pointerId === pointer_id)
|
|
35
|
-
onPointerDrag(event)
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
pointerup: {
|
|
40
|
-
options: undefined,
|
|
41
|
-
handleEvent: (event: PointerEvent) => {
|
|
42
|
-
event.preventDefault()
|
|
43
|
-
|
|
44
|
-
if (event.pointerId === pointer_id) {
|
|
45
|
-
getPointerCaptureElement().releasePointerCapture(pointer_id)
|
|
46
|
-
pointer_id = undefined
|
|
47
|
-
onPointerDrag(event)
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
package/s/nubs/lookpad/view.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {html} from "lit"
|
|
3
|
-
import {view} from "@e280/sly"
|
|
4
|
-
|
|
5
|
-
import {styles} from "./styles.js"
|
|
6
|
-
import {lookpad_listeners} from "./utils/listeners.js"
|
|
7
|
-
|
|
8
|
-
export const NubLookpad = view(use => () => {
|
|
9
|
-
use.name("nub-lookpad")
|
|
10
|
-
use.styles(styles)
|
|
11
|
-
|
|
12
|
-
const pad = use.life(() => {
|
|
13
|
-
const pad = document.createElement("div")
|
|
14
|
-
pad.className = "pad"
|
|
15
|
-
|
|
16
|
-
const listeners = lookpad_listeners({
|
|
17
|
-
getPointerCaptureElement: () => pad,
|
|
18
|
-
onPointerDrag: () => {},
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
for (const [event, {handleEvent, options}] of Object.entries(listeners))
|
|
22
|
-
pad.addEventListener(event as any, handleEvent, options)
|
|
23
|
-
|
|
24
|
-
return [pad, () => {
|
|
25
|
-
for (const [event, {handleEvent}] of Object.entries(listeners))
|
|
26
|
-
pad.removeEventListener(event as any, handleEvent)
|
|
27
|
-
}]
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
return html`${pad}`
|
|
31
|
-
})
|
|
32
|
-
|
package/s/nubs/stick/styles.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {css} from "lit"
|
|
3
|
-
export const styles = css`
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
display: block;
|
|
7
|
-
width: 8em;
|
|
8
|
-
aspect-ratio: 1 / 1;
|
|
9
|
-
touch-action: none;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.container {
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 100%;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
[part="graphic"] {
|
|
18
|
-
width: 100%;
|
|
19
|
-
height: 100%;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
`
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Vec2} from "@benev/math"
|
|
3
|
-
import {within_radius} from "./within_radius.js"
|
|
4
|
-
import {Basis} from "../../stick-graphic/types/basis.js"
|
|
5
|
-
import {find_closest_point_on_circle} from "./find_closest_point_on_circle.js"
|
|
6
|
-
|
|
7
|
-
export function calculate_new_vector_from_pointer_position(
|
|
8
|
-
{radius, rect: {left, top, width, height}}: Basis,
|
|
9
|
-
{x: client_x, y: client_y}: Vec2,
|
|
10
|
-
): Vec2 {
|
|
11
|
-
|
|
12
|
-
const middle_x = left + (width / 2)
|
|
13
|
-
const middle_y = top + (height / 2)
|
|
14
|
-
|
|
15
|
-
let new_vector = Vec2.new((client_x - middle_x), (client_y - middle_y))
|
|
16
|
-
|
|
17
|
-
if (!within_radius(radius, new_vector))
|
|
18
|
-
new_vector = find_closest_point_on_circle(radius, new_vector)
|
|
19
|
-
const [x, y] = new_vector
|
|
20
|
-
|
|
21
|
-
const final = Vec2.new((x / radius), -(y / radius))
|
|
22
|
-
|
|
23
|
-
return [...final].some(isNaN)
|
|
24
|
-
? Vec2.zero()
|
|
25
|
-
: final
|
|
26
|
-
}
|
|
27
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Vec2} from "@benev/math"
|
|
3
|
-
|
|
4
|
-
export function find_closest_point_on_circle(
|
|
5
|
-
radius: number,
|
|
6
|
-
{x, y}: Vec2,
|
|
7
|
-
): Vec2 {
|
|
8
|
-
|
|
9
|
-
const magnitude = Math.sqrt((x ** 2) + (y ** 2))
|
|
10
|
-
|
|
11
|
-
return Vec2.new(
|
|
12
|
-
(x / magnitude) * radius,
|
|
13
|
-
(y / magnitude) * radius,
|
|
14
|
-
)
|
|
15
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Vec2} from "@benev/math"
|
|
3
|
-
|
|
4
|
-
export function make_pointer_listeners({
|
|
5
|
-
set_vector,
|
|
6
|
-
set_pointer_position,
|
|
7
|
-
}: {
|
|
8
|
-
set_vector: (vector: Vec2) => void
|
|
9
|
-
set_pointer_position: (position: Vec2) => void
|
|
10
|
-
}) {
|
|
11
|
-
|
|
12
|
-
let pointer_id: number | undefined
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
pointerdown: {
|
|
16
|
-
handleEvent: (event: PointerEvent) => {
|
|
17
|
-
event.preventDefault()
|
|
18
|
-
|
|
19
|
-
const element = event.currentTarget as HTMLElement
|
|
20
|
-
|
|
21
|
-
if (pointer_id)
|
|
22
|
-
element.releasePointerCapture(pointer_id)
|
|
23
|
-
|
|
24
|
-
pointer_id = event.pointerId
|
|
25
|
-
element.setPointerCapture(pointer_id)
|
|
26
|
-
set_pointer_position(Vec2.new(event.clientX, event.clientY))
|
|
27
|
-
set_vector(Vec2.zero())
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
pointermove: {
|
|
32
|
-
passive: false,
|
|
33
|
-
handleEvent: (event: PointerEvent) => {
|
|
34
|
-
event.preventDefault()
|
|
35
|
-
|
|
36
|
-
if (event.pointerId === pointer_id)
|
|
37
|
-
set_pointer_position(Vec2.new(event.clientX, event.clientY))
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
pointerup: {
|
|
42
|
-
handleEvent: (event: PointerEvent) => {
|
|
43
|
-
event.preventDefault()
|
|
44
|
-
pointer_id = undefined
|
|
45
|
-
set_vector(Vec2.zero())
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
package/s/nubs/stick/view.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {html} from "lit"
|
|
3
|
-
import {view} from "@e280/sly"
|
|
4
|
-
import {Vec2} from "@benev/math"
|
|
5
|
-
|
|
6
|
-
import {styles} from "./styles.js"
|
|
7
|
-
import {Basis} from "../stick-graphic/types/basis.js"
|
|
8
|
-
import {NubStickGraphic} from "../stick-graphic/view.js"
|
|
9
|
-
import {StickController} from "../../core/controllers/standard/stick.js"
|
|
10
|
-
import {make_pointer_listeners} from "./utils/make_pointer_listeners.js"
|
|
11
|
-
import {calculate_new_vector_from_pointer_position} from "./utils/calculate_new_vector_from_pointer_position.js"
|
|
12
|
-
|
|
13
|
-
export const NubStick = view(use => (stick: StickController) => {
|
|
14
|
-
use.name("nub-stick")
|
|
15
|
-
use.styles(styles)
|
|
16
|
-
|
|
17
|
-
let basis: Basis | undefined = undefined
|
|
18
|
-
const updateBasis = (b: Basis) => basis = b
|
|
19
|
-
|
|
20
|
-
const listeners = use.once(() => make_pointer_listeners({
|
|
21
|
-
set_vector: vector => stick.vector.value = vector,
|
|
22
|
-
set_pointer_position: position => {
|
|
23
|
-
if (basis)
|
|
24
|
-
stick.vector.value = calculate_new_vector_from_pointer_position(
|
|
25
|
-
basis,
|
|
26
|
-
position,
|
|
27
|
-
)
|
|
28
|
-
},
|
|
29
|
-
}))
|
|
30
|
-
|
|
31
|
-
use.mount(() => {
|
|
32
|
-
stick.vector.set(Vec2.zero())
|
|
33
|
-
return () => stick.vector.set(Vec2.zero())
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
return html`
|
|
37
|
-
<div
|
|
38
|
-
class=container
|
|
39
|
-
.vector="${stick.vector}"
|
|
40
|
-
@pointerdown="${listeners.pointerdown}"
|
|
41
|
-
@pointermove="${listeners.pointermove}"
|
|
42
|
-
@pointerup="${listeners.pointerup}"
|
|
43
|
-
>
|
|
44
|
-
${NubStickGraphic
|
|
45
|
-
.attr("part", "graphic")
|
|
46
|
-
.props(stick.vector.get(), updateBasis)}
|
|
47
|
-
</div>
|
|
48
|
-
`
|
|
49
|
-
})
|
|
50
|
-
|