@benev/tact 0.4.0-0 → 0.4.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -66
- package/package.json +5 -4
- package/s/demo/main.bundle.ts +18 -3
- package/s/demo/main.css +4 -3
- package/s/demo/presets.ts +54 -0
- package/s/gamepad/gamepad-app/element.ts +11 -4
- package/s/gamepad/gamepad-app/style.css.ts +5 -1
- package/s/gamepad/index.html.ts +1 -1
- package/s/gamepad/main.css +10 -1
- package/s/index.html.ts +13 -6
- package/s/lib/index.ts +15 -4
- package/s/lib/input/{encoder.ts → controller.ts} +23 -15
- package/s/lib/input/data/endian.ts +3 -0
- package/s/{_archive/lib3/input/data → lib/input/data/intent}/decode.ts +4 -3
- package/s/lib/input/data/intent/encode.ts +25 -0
- package/s/{_archive/lib3/input/data/params.ts → lib/input/data/intent/sizes.ts} +1 -2
- package/s/lib/input/data/intent/types.ts +6 -0
- package/s/lib/input/data/parcel/decode.ts +32 -0
- package/s/lib/input/data/parcel/encode.ts +30 -0
- package/s/lib/input/data/parcel/sizes.ts +5 -0
- package/s/lib/input/data/parcel/types.ts +8 -0
- package/s/lib/input/data/test.ts +23 -0
- package/s/lib/input/decoder.ts +16 -10
- package/s/lib/input/evaluate/context.ts +2 -3
- package/s/lib/input/evaluate/evaluate.ts +45 -15
- package/s/lib/input/expression.ts +5 -5
- package/s/lib/input/investigate/is-expression.ts +1 -0
- package/s/lib/input/investigate/make-input.ts +1 -5
- package/s/lib/input/sources/gamepad.ts +3 -9
- package/s/lib/input/sources/pointer.ts +0 -18
- package/s/lib/input/test.ts +194 -0
- package/s/lib/input/testing/quickbind.ts +6 -5
- package/s/lib/input/types.ts +3 -7
- package/s/lib/input/utils/mouse-button.ts +1 -6
- package/s/lib/test.ts +3 -177
- package/s/lib/ui/deck/auto-gamepads.ts +29 -0
- package/s/lib/ui/deck/collector.ts +52 -0
- package/s/lib/ui/deck/controls/controls.ts +76 -0
- package/s/lib/ui/deck/controls/internal/assignments.ts +24 -0
- package/s/lib/ui/deck/controls/internal/data.ts +51 -0
- package/s/lib/ui/deck/controls/internal/fns.ts +38 -0
- package/s/lib/ui/deck/controls/internal/profiles.ts +83 -0
- package/s/lib/ui/deck/controls/types.ts +23 -0
- package/s/lib/ui/deck/hub.ts +108 -0
- package/s/lib/ui/deck/setup/deck.ts +31 -0
- package/s/lib/ui/deck/setup/tact.ts +86 -0
- package/s/lib/ui/deck/setup/types.ts +12 -0
- package/s/lib/ui/deck/types.ts +26 -0
- package/s/lib/ui/deck/utils/first-preset.ts +9 -0
- package/s/lib/ui/icons/akar/LICENSE +23 -0
- package/s/lib/ui/icons/akar/backspace.svg.ts +4 -0
- package/s/lib/ui/icons/akar/circle-plus.svg.ts +4 -0
- package/s/lib/ui/icons/akar/copy.svg.ts +4 -0
- package/s/lib/ui/icons/akar/cross.svg.ts +4 -0
- package/s/lib/ui/icons/akar/devices.svg.ts +4 -0
- package/s/lib/ui/icons/akar/drag-vertical-fill.svg.ts +4 -0
- package/s/lib/ui/icons/akar/game-controller.svg.ts +4 -0
- package/s/lib/ui/icons/akar/key-cap.svg.ts +4 -0
- package/s/lib/ui/icons/akar/people-group.svg.ts +4 -0
- package/s/lib/ui/icons/akar/person-add.svg.ts +4 -0
- package/s/lib/ui/icons/akar/settings-horizontal.svg.ts +4 -0
- package/s/lib/ui/icons/akar/trash-can.svg.ts +4 -0
- package/s/lib/ui/icons/akar/x-small.svg.ts +4 -0
- package/s/lib/ui/views/controllers/style.css.ts +158 -0
- package/s/lib/ui/views/controllers/subviews/controller.ts +53 -0
- package/s/lib/ui/views/controllers/subviews/dropcard.ts +31 -0
- package/s/lib/ui/views/controllers/subviews/player.ts +38 -0
- package/s/lib/ui/views/controllers/view.ts +72 -0
- package/s/lib/ui/views/customize/parts/capture-gamepad-chord.ts +59 -0
- package/s/lib/ui/views/customize/parts/capture-key-chord.ts +70 -0
- package/s/lib/ui/views/customize/parts/capture-pointer-chord.ts +55 -0
- package/s/lib/ui/views/customize/parts/render-bindings.ts +67 -0
- package/s/lib/ui/views/customize/style.css.ts +144 -0
- package/s/lib/ui/views/customize/subviews/expression.ts +88 -0
- package/s/lib/ui/views/customize/subviews/recorder.ts +76 -0
- package/s/lib/ui/views/customize/view.ts +104 -0
- package/s/lib/ui/views/deck/style.css.ts +69 -0
- package/s/lib/ui/views/deck/types.ts +15 -0
- package/s/lib/ui/views/deck/view.ts +49 -0
- package/s/lib/ui/views/profile-select/view.ts +44 -0
- package/s/lib/ui/views/theme.css.ts +115 -0
- package/s/lib/ui/views/visualizer/style.css.ts +23 -0
- package/s/lib/ui/views/visualizer/view.ts +16 -0
- package/s/lib/ui/views/visualizer/visualizer.ts +17 -0
- package/s/lib/utils/ellipsis.ts +7 -0
- package/s/lib/utils/hueify.ts +5 -0
- package/x/demo/main.bundle.js +16 -3
- package/x/demo/main.bundle.js.map +1 -1
- package/x/demo/main.bundle.min.js +809 -11
- package/x/demo/main.bundle.min.js.map +4 -4
- package/x/demo/main.css +4 -3
- package/x/demo/presets.d.ts +30 -0
- package/x/demo/presets.js +51 -0
- package/x/demo/presets.js.map +1 -0
- package/x/gamepad/gamepad-app/element.js +9 -4
- package/x/gamepad/gamepad-app/element.js.map +1 -1
- package/x/gamepad/gamepad-app/style.css.js +5 -1
- package/x/gamepad/gamepad-app/style.css.js.map +1 -1
- package/x/gamepad/index.html +4 -4
- package/x/gamepad/index.html.js +1 -1
- package/x/gamepad/main.bundle.min.js +24 -20
- package/x/gamepad/main.bundle.min.js.map +4 -4
- package/x/gamepad/main.css +10 -1
- package/x/index.html +16 -9
- package/x/index.html.js +13 -6
- package/x/index.html.js.map +1 -1
- package/x/lib/index.d.ts +14 -1
- package/x/lib/index.js +14 -1
- package/x/lib/index.js.map +1 -1
- package/x/lib/input/controller.d.ts +15 -0
- package/x/lib/input/{encoder.js → controller.js} +19 -13
- package/x/lib/input/controller.js.map +1 -0
- package/x/lib/input/data/endian.d.ts +1 -0
- package/x/lib/input/data/endian.js +2 -0
- package/x/lib/input/data/endian.js.map +1 -0
- package/x/lib/input/data/intent/decode.d.ts +5 -0
- package/x/lib/input/data/{decode.js → intent/decode.js} +3 -2
- package/x/lib/input/data/intent/decode.js.map +1 -0
- package/x/lib/input/data/intent/encode.d.ts +2 -0
- package/x/lib/input/data/intent/encode.js +18 -0
- package/x/lib/input/data/intent/encode.js.map +1 -0
- package/x/lib/input/data/{params.d.ts → intent/sizes.d.ts} +1 -2
- package/x/lib/input/data/intent/sizes.js +5 -0
- package/x/lib/input/data/intent/sizes.js.map +1 -0
- package/x/lib/input/data/intent/types.d.ts +4 -0
- package/x/lib/input/data/intent/types.js +2 -0
- package/x/lib/input/data/intent/types.js.map +1 -0
- package/x/lib/input/data/parcel/decode.d.ts +2 -0
- package/x/lib/input/data/parcel/decode.js +22 -0
- package/x/lib/input/data/parcel/decode.js.map +1 -0
- package/x/lib/input/data/parcel/encode.d.ts +2 -0
- package/x/lib/input/data/parcel/encode.js +19 -0
- package/x/lib/input/data/parcel/encode.js.map +1 -0
- package/x/lib/input/data/parcel/sizes.d.ts +3 -0
- package/x/lib/input/data/parcel/sizes.js +4 -0
- package/x/lib/input/data/parcel/sizes.js.map +1 -0
- package/x/lib/input/data/parcel/types.d.ts +5 -0
- package/x/lib/input/data/parcel/types.js +2 -0
- package/x/lib/input/data/parcel/types.js.map +1 -0
- package/x/lib/input/data/test.d.ts +6 -0
- package/x/lib/input/data/test.js +19 -0
- package/x/lib/input/data/test.js.map +1 -0
- package/x/lib/input/decoder.d.ts +2 -2
- package/x/lib/input/decoder.js +12 -10
- package/x/lib/input/decoder.js.map +1 -1
- package/x/lib/input/evaluate/context.d.ts +2 -3
- package/x/lib/input/evaluate/context.js +2 -3
- package/x/lib/input/evaluate/context.js.map +1 -1
- package/x/lib/input/evaluate/evaluate.d.ts +1 -1
- package/x/lib/input/evaluate/evaluate.js +42 -14
- package/x/lib/input/evaluate/evaluate.js.map +1 -1
- package/x/lib/input/expression.d.ts +1 -1
- package/x/lib/input/investigate/is-expression.js +2 -0
- package/x/lib/input/investigate/is-expression.js.map +1 -1
- package/x/lib/input/investigate/make-input.js +1 -5
- package/x/lib/input/investigate/make-input.js.map +1 -1
- package/x/lib/input/sources/gamepad.js +3 -9
- package/x/lib/input/sources/gamepad.js.map +1 -1
- package/x/lib/input/sources/pointer.js +0 -21
- package/x/lib/input/sources/pointer.js.map +1 -1
- package/x/lib/input/test.d.ts +18 -0
- package/x/lib/input/test.js +143 -0
- package/x/lib/input/test.js.map +1 -0
- package/x/lib/input/testing/quickbind.d.ts +3 -2
- package/x/lib/input/testing/quickbind.js +6 -5
- package/x/lib/input/testing/quickbind.js.map +1 -1
- package/x/lib/input/types.d.ts +3 -8
- package/x/lib/input/types.js.map +1 -1
- package/x/lib/input/utils/mouse-button.js +1 -6
- package/x/lib/input/utils/mouse-button.js.map +1 -1
- package/x/lib/test.js +3 -133
- package/x/lib/test.js.map +1 -1
- package/x/lib/ui/deck/auto-gamepads.d.ts +4 -0
- package/x/lib/ui/deck/auto-gamepads.js +19 -0
- package/x/lib/ui/deck/auto-gamepads.js.map +1 -0
- package/x/lib/ui/deck/collector.d.ts +13 -0
- package/x/lib/ui/deck/collector.js +35 -0
- package/x/lib/ui/deck/collector.js.map +1 -0
- package/x/lib/ui/deck/controls/controls.d.ts +19 -0
- package/x/lib/ui/deck/controls/controls.js +56 -0
- package/x/lib/ui/deck/controls/controls.js.map +1 -0
- package/x/lib/ui/deck/controls/internal/assignments.d.ts +9 -0
- package/x/lib/ui/deck/controls/internal/assignments.js +16 -0
- package/x/lib/ui/deck/controls/internal/assignments.js.map +1 -0
- package/x/lib/ui/deck/controls/internal/data.d.ts +29 -0
- package/x/lib/ui/deck/controls/internal/data.js +29 -0
- package/x/lib/ui/deck/controls/internal/data.js.map +1 -0
- package/x/lib/ui/deck/controls/internal/fns.d.ts +6 -0
- package/x/lib/ui/deck/controls/internal/fns.js +19 -0
- package/x/lib/ui/deck/controls/internal/fns.js.map +1 -0
- package/x/lib/ui/deck/controls/internal/profiles.d.ts +18 -0
- package/x/lib/ui/deck/controls/internal/profiles.js +59 -0
- package/x/lib/ui/deck/controls/internal/profiles.js.map +1 -0
- package/x/lib/ui/deck/controls/types.d.ts +17 -0
- package/x/lib/ui/deck/controls/types.js +2 -0
- package/x/lib/ui/deck/controls/types.js.map +1 -0
- package/x/lib/ui/deck/hub.d.ts +21 -0
- package/x/lib/ui/deck/hub.js +85 -0
- package/x/lib/ui/deck/hub.js.map +1 -0
- package/x/lib/ui/deck/setup/deck.d.ts +3 -0
- package/x/lib/ui/deck/setup/deck.js +20 -0
- package/x/lib/ui/deck/setup/deck.js.map +1 -0
- package/x/lib/ui/deck/setup/tact.d.ts +17 -0
- package/x/lib/ui/deck/setup/tact.js +67 -0
- package/x/lib/ui/deck/setup/tact.js.map +1 -0
- package/x/lib/ui/deck/setup/types.d.ts +9 -0
- package/x/lib/ui/deck/setup/types.js +2 -0
- package/x/lib/ui/deck/setup/types.js.map +1 -0
- package/x/lib/ui/deck/types.d.ts +18 -0
- package/x/lib/ui/deck/types.js +3 -0
- package/x/lib/ui/deck/types.js.map +1 -0
- package/x/lib/ui/deck/utils/first-preset.d.ts +6 -0
- package/x/lib/ui/deck/utils/first-preset.js +5 -0
- package/x/lib/ui/deck/utils/first-preset.js.map +1 -0
- package/x/lib/ui/icons/akar/backspace.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/backspace.svg.js +3 -0
- package/x/lib/ui/icons/akar/backspace.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/circle-plus.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/circle-plus.svg.js +3 -0
- package/x/lib/ui/icons/akar/circle-plus.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/copy.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/copy.svg.js +3 -0
- package/x/lib/ui/icons/akar/copy.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/cross.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/cross.svg.js +3 -0
- package/x/lib/ui/icons/akar/cross.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/devices.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/devices.svg.js +3 -0
- package/x/lib/ui/icons/akar/devices.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/drag-vertical-fill.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/drag-vertical-fill.svg.js +3 -0
- package/x/lib/ui/icons/akar/drag-vertical-fill.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/game-controller.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/game-controller.svg.js +3 -0
- package/x/lib/ui/icons/akar/game-controller.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/key-cap.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/key-cap.svg.js +3 -0
- package/x/lib/ui/icons/akar/key-cap.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/people-group.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/people-group.svg.js +3 -0
- package/x/lib/ui/icons/akar/people-group.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/person-add.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/person-add.svg.js +3 -0
- package/x/lib/ui/icons/akar/person-add.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/settings-horizontal.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/settings-horizontal.svg.js +3 -0
- package/x/lib/ui/icons/akar/settings-horizontal.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/trash-can.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/trash-can.svg.js +3 -0
- package/x/lib/ui/icons/akar/trash-can.svg.js.map +1 -0
- package/x/lib/ui/icons/akar/x-small.svg.d.ts +2 -0
- package/x/lib/ui/icons/akar/x-small.svg.js +3 -0
- package/x/lib/ui/icons/akar/x-small.svg.js.map +1 -0
- package/x/lib/ui/views/controllers/style.css.js +157 -0
- package/x/lib/ui/views/controllers/style.css.js.map +1 -0
- package/x/lib/ui/views/controllers/subviews/controller.d.ts +3 -0
- package/x/lib/ui/views/controllers/subviews/controller.js +45 -0
- package/x/lib/ui/views/controllers/subviews/controller.js.map +1 -0
- package/x/lib/ui/views/controllers/subviews/dropcard.d.ts +9 -0
- package/x/lib/ui/views/controllers/subviews/dropcard.js +20 -0
- package/x/lib/ui/views/controllers/subviews/dropcard.js.map +1 -0
- package/x/lib/ui/views/controllers/subviews/player.d.ts +2 -0
- package/x/lib/ui/views/controllers/subviews/player.js +32 -0
- package/x/lib/ui/views/controllers/subviews/player.js.map +1 -0
- package/x/lib/ui/views/controllers/view.d.ts +2 -0
- package/x/lib/ui/views/controllers/view.js +64 -0
- package/x/lib/ui/views/controllers/view.js.map +1 -0
- package/x/lib/ui/views/customize/parts/capture-gamepad-chord.d.ts +2 -0
- package/x/lib/ui/views/customize/parts/capture-gamepad-chord.js +46 -0
- package/x/lib/ui/views/customize/parts/capture-gamepad-chord.js.map +1 -0
- package/x/lib/ui/views/customize/parts/capture-key-chord.d.ts +2 -0
- package/x/lib/ui/views/customize/parts/capture-key-chord.js +58 -0
- package/x/lib/ui/views/customize/parts/capture-key-chord.js.map +1 -0
- package/x/lib/ui/views/customize/parts/capture-pointer-chord.d.ts +2 -0
- package/x/lib/ui/views/customize/parts/capture-pointer-chord.js +42 -0
- package/x/lib/ui/views/customize/parts/capture-pointer-chord.js.map +1 -0
- package/x/lib/ui/views/customize/parts/render-bindings.d.ts +3 -0
- package/x/lib/ui/views/customize/parts/render-bindings.js +32 -0
- package/x/lib/ui/views/customize/parts/render-bindings.js.map +1 -0
- package/x/lib/ui/views/customize/style.css.d.ts +2 -0
- package/x/lib/ui/views/customize/style.css.js +143 -0
- package/x/lib/ui/views/customize/style.css.js.map +1 -0
- package/x/lib/ui/views/customize/subviews/expression.d.ts +2 -0
- package/x/lib/ui/views/customize/subviews/expression.js +75 -0
- package/x/lib/ui/views/customize/subviews/expression.js.map +1 -0
- package/x/lib/ui/views/customize/subviews/recorder.d.ts +3 -0
- package/x/lib/ui/views/customize/subviews/recorder.js +60 -0
- package/x/lib/ui/views/customize/subviews/recorder.js.map +1 -0
- package/x/lib/ui/views/customize/view.d.ts +6 -0
- package/x/lib/ui/views/customize/view.js +82 -0
- package/x/lib/ui/views/customize/view.js.map +1 -0
- package/x/lib/ui/views/deck/style.css.d.ts +2 -0
- package/x/lib/ui/views/deck/style.css.js +68 -0
- package/x/lib/ui/views/deck/style.css.js.map +1 -0
- package/x/lib/ui/views/deck/types.d.ts +14 -0
- package/x/lib/ui/views/deck/types.js +2 -0
- package/x/lib/ui/views/deck/types.js.map +1 -0
- package/x/lib/ui/views/deck/view.d.ts +2 -0
- package/x/lib/ui/views/deck/view.js +41 -0
- package/x/lib/ui/views/deck/view.js.map +1 -0
- package/x/lib/ui/views/profile-select/view.d.ts +4 -0
- package/x/lib/ui/views/profile-select/view.js +34 -0
- package/x/lib/ui/views/profile-select/view.js.map +1 -0
- package/x/lib/ui/views/theme.css.d.ts +2 -0
- package/x/lib/ui/views/theme.css.js +113 -0
- package/x/lib/ui/views/theme.css.js.map +1 -0
- package/x/lib/ui/views/visualizer/style.css.d.ts +2 -0
- package/x/lib/ui/views/visualizer/style.css.js +22 -0
- package/x/lib/ui/views/visualizer/style.css.js.map +1 -0
- package/x/lib/ui/views/visualizer/view.d.ts +2 -0
- package/x/lib/ui/views/visualizer/view.js +11 -0
- package/x/lib/ui/views/visualizer/view.js.map +1 -0
- package/x/lib/ui/views/visualizer/visualizer.d.ts +5 -0
- package/x/lib/ui/views/visualizer/visualizer.js +13 -0
- package/x/lib/ui/views/visualizer/visualizer.js.map +1 -0
- package/x/lib/utils/ellipsis.d.ts +1 -0
- package/x/lib/utils/ellipsis.js +6 -0
- package/x/lib/utils/ellipsis.js.map +1 -0
- package/x/lib/utils/hueify.d.ts +1 -0
- package/x/lib/utils/hueify.js +4 -0
- package/x/lib/utils/hueify.js.map +1 -0
- package/x/lib/utils/make-id.d.ts +1 -0
- package/x/lib/utils/make-id.js +5 -0
- package/x/lib/utils/make-id.js.map +1 -0
- package/s/_archive/core/atom/defaults.ts +0 -32
- package/s/_archive/core/atom/lens-algo.ts +0 -84
- package/s/_archive/core/atom/types.ts +0 -44
- package/s/_archive/core/bindings/normalize.ts +0 -27
- package/s/_archive/core/bindings/shape.ts +0 -15
- package/s/_archive/core/bindings/table.ts +0 -22
- package/s/_archive/core/intent/bucket.ts +0 -28
- package/s/_archive/core/intent/consts.ts +0 -4
- package/s/_archive/core/intent/decode.ts +0 -23
- package/s/_archive/core/intent/encode.ts +0 -20
- package/s/_archive/core/intent/merge.ts +0 -15
- package/s/_archive/core/parts/action.ts +0 -36
- package/s/_archive/core/parts/sample-map.ts +0 -24
- package/s/_archive/core/resolvers/actions.ts +0 -30
- package/s/_archive/core/resolvers/intents.ts +0 -106
- package/s/_archive/core/types.ts +0 -40
- package/s/_archive/deck/controller.ts +0 -35
- package/s/_archive/deck/deck.ts +0 -92
- package/s/_archive/deck/parts/profiles.ts +0 -39
- package/s/_archive/deck/parts/runtime.ts +0 -11
- package/s/_archive/deck/parts/settings.ts +0 -30
- package/s/_archive/deck/port.ts +0 -35
- package/s/_archive/deck/types.ts +0 -16
- package/s/_archive/demo/demo-app/element.ts +0 -17
- package/s/_archive/demo/demo-app/style.css.ts +0 -10
- package/s/_archive/demo/main.bundle.ts +0 -71
- package/s/_archive/demo/main.css +0 -83
- package/s/_archive/device/devices.ts +0 -24
- package/s/_archive/device/gamepad.ts +0 -42
- package/s/_archive/device/keyboard.ts +0 -33
- package/s/_archive/device/pad/on-pad.ts +0 -50
- package/s/_archive/device/pad/pad.ts +0 -10
- package/s/_archive/device/pointer.ts +0 -89
- package/s/_archive/device/sampler.ts +0 -25
- package/s/_archive/device/stick.ts +0 -24
- package/s/_archive/index-ui.ts +0 -3
- package/s/_archive/lib/bindings/resolver.ts +0 -61
- package/s/_archive/lib/bindings/types.ts +0 -67
- package/s/_archive/lib/bindings/utils/action-resolver.ts +0 -51
- package/s/_archive/lib/bindings/utils/evaluator.ts +0 -162
- package/s/_archive/lib/bindings/utils/hash-bindings.ts +0 -22
- package/s/_archive/lib/bindings/utils/intent-coding.ts +0 -50
- package/s/_archive/lib/bindings/utils/intent-resolver.ts +0 -52
- package/s/_archive/lib/bindings/utils/investigate.ts +0 -47
- package/s/_archive/lib/bindings/utils/is-down.ts +0 -5
- package/s/_archive/lib/bindings/utils/is-expression.ts +0 -11
- package/s/_archive/lib/index.ts +0 -12
- package/s/_archive/lib/sampling/sources/example.ts +0 -7
- package/s/_archive/lib/sampling/sources/gamepad.ts +0 -63
- package/s/_archive/lib/sampling/sources/keyboard.ts +0 -52
- package/s/_archive/lib/sampling/sources/pointer.ts +0 -56
- package/s/_archive/lib/sampling/sources/sources.ts +0 -13
- package/s/_archive/lib/sampling/sources/stick.ts +0 -27
- package/s/_archive/lib/sampling/types.ts +0 -11
- package/s/_archive/lib/sampling/utils/add-sample.ts +0 -12
- package/s/_archive/lib/test.ts +0 -57
- package/s/_archive/lib/utils/backwards.ts +0 -6
- package/s/_archive/lib/utils/evergreen.ts +0 -10
- package/s/_archive/lib/utils/mouse-button.ts +0 -10
- package/s/_archive/lib/utils/pad/on-pad.ts +0 -50
- package/s/_archive/lib/utils/pad/pad.ts +0 -10
- package/s/_archive/lib/utils/split-axis.ts +0 -15
- package/s/_archive/lib2/core/decoder/decoder.ts +0 -34
- package/s/_archive/lib2/core/decoder/utils/update-input.ts +0 -21
- package/s/_archive/lib2/core/encoder/encoder.ts +0 -60
- package/s/_archive/lib2/core/encoder/evaluate/context.ts +0 -22
- package/s/_archive/lib2/core/encoder/evaluate/evaluate.ts +0 -144
- package/s/_archive/lib2/core/encoder/parts/expression-index.ts +0 -27
- package/s/_archive/lib2/core/encoder/parts/hash-bindings.ts +0 -22
- package/s/_archive/lib2/core/encoder/parts/investigate.ts +0 -50
- package/s/_archive/lib2/core/encoder/parts/sampler.ts +0 -22
- package/s/_archive/lib2/core/sources/example.ts +0 -9
- package/s/_archive/lib2/core/sources/sources.ts +0 -16
- package/s/_archive/lib2/core/types.ts +0 -78
- package/s/_archive/lib2/core/utils/data.ts +0 -50
- package/s/_archive/lib2/core/utils/is-down.ts +0 -5
- package/s/_archive/lib2/core/utils/is-expression.ts +0 -11
- package/s/_archive/lib3/input/data/encode.ts +0 -24
- package/s/_archive/lib3/input/decoder.ts +0 -56
- package/s/_archive/lib3/input/encoder.ts +0 -99
- package/s/_archive/lib3/input/evaluate/context.ts +0 -15
- package/s/_archive/lib3/input/evaluate/evaluate.ts +0 -142
- package/s/_archive/lib3/input/evaluate/utils/clock.ts +0 -14
- package/s/_archive/lib3/input/investigate/hash-bindings.ts +0 -22
- package/s/_archive/lib3/input/investigate/investigate.ts +0 -42
- package/s/_archive/lib3/input/investigate/is-expression.ts +0 -11
- package/s/_archive/lib3/input/investigate/make-input.ts +0 -18
- package/s/_archive/lib3/input/investigate/root-index.ts +0 -26
- package/s/_archive/lib3/input/mixer.ts +0 -20
- package/s/_archive/lib3/input/sources/gamepad.ts +0 -58
- package/s/_archive/lib3/input/sources/keyboard.ts +0 -49
- package/s/_archive/lib3/input/sources/plain.ts +0 -9
- package/s/_archive/lib3/input/sources/pointer.ts +0 -58
- package/s/_archive/lib3/input/sources/sources.ts +0 -24
- package/s/_archive/lib3/input/sources/stick.ts +0 -29
- package/s/_archive/lib3/input/testing/quickbind.ts +0 -20
- package/s/_archive/lib3/input/types.ts +0 -96
- package/s/_archive/lib3/input/utils/evergreen.ts +0 -10
- package/s/_archive/lib3/input/utils/is-down.ts +0 -5
- package/s/_archive/lib3/input/utils/mouse-button.ts +0 -10
- package/s/_archive/lib3/input/utils/pad/on-pad.ts +0 -50
- package/s/_archive/lib3/input/utils/pad/pad.ts +0 -10
- package/s/_archive/lib3/input/utils/sampler.ts +0 -28
- package/s/_archive/lib3/input/utils/split-axis.ts +0 -15
- package/s/_archive/lib3/test.ts +0 -100
- package/s/_archive/lib4/input/data/decode.ts +0 -25
- package/s/_archive/lib4/input/data/encode.ts +0 -24
- package/s/_archive/lib4/input/data/params.ts +0 -7
- package/s/_archive/lib4/input/encoder.ts +0 -100
- package/s/_archive/lib4/input/evaluate/context.ts +0 -16
- package/s/_archive/lib4/input/evaluate/evaluate.ts +0 -157
- package/s/_archive/lib4/input/evaluate/utils/clock.ts +0 -14
- package/s/_archive/lib4/input/investigate/hash-bindings.ts +0 -22
- package/s/_archive/lib4/input/investigate/investigate.ts +0 -37
- package/s/_archive/lib4/input/investigate/is.ts +0 -19
- package/s/_archive/lib4/input/investigate/make-input.ts +0 -18
- package/s/_archive/lib4/input/investigate/root-index.ts +0 -26
- package/s/_archive/lib4/input/sources/gamepad.ts +0 -58
- package/s/_archive/lib4/input/sources/keyboard.ts +0 -46
- package/s/_archive/lib4/input/sources/plain.ts +0 -9
- package/s/_archive/lib4/input/sources/pointer.ts +0 -50
- package/s/_archive/lib4/input/sources/sources.ts +0 -24
- package/s/_archive/lib4/input/sources/stick.ts +0 -25
- package/s/_archive/lib4/input/types.ts +0 -102
- package/s/_archive/lib4/input/utils/evergreen.ts +0 -10
- package/s/_archive/lib4/input/utils/is-down.ts +0 -5
- package/s/_archive/lib4/input/utils/mouse-button.ts +0 -10
- package/s/_archive/lib4/input/utils/pad/on-pad.ts +0 -50
- package/s/_archive/lib4/input/utils/pad/pad.ts +0 -10
- package/s/_archive/lib4/input/utils/sampler.ts +0 -28
- package/s/_archive/lib4/input/utils/split-axis.ts +0 -15
- package/s/_archive/lib4/test.ts +0 -12
- package/s/_archive/test.ts +0 -339
- package/s/_archive/ui/views/desk/style.css.ts +0 -70
- package/s/_archive/ui/views/desk/view.ts +0 -122
- package/s/_archive/utils/circular-clamp.ts +0 -14
- package/s/_archive/utils/do-async.ts +0 -5
- package/s/_archive/utils/evergreen.ts +0 -10
- package/s/_archive/utils/freeze-clone.ts +0 -7
- package/s/_archive/utils/identifier.ts +0 -30
- package/s/_archive/utils/insert.ts +0 -6
- package/s/_archive/utils/is-down.ts +0 -5
- package/s/_archive/utils/remap.ts +0 -7
- package/s/_archive/utils/shift-limit.ts +0 -9
- package/s/_archive/utils/sort-by-key.ts +0 -7
- package/s/_archive/utils/split-axis.ts +0 -15
- package/s/_archive/utils/tmax.ts +0 -7
- package/s/_archive/utils/tmin.ts +0 -7
- package/s/demo/demo-app/element.ts +0 -15
- package/s/demo/demo-app/style.css.ts +0 -10
- package/s/lib/input/data/decode.ts +0 -25
- package/s/lib/input/data/encode.ts +0 -24
- package/s/lib/input/data/params.ts +0 -7
- package/x/_archive/demo/main.css +0 -83
- package/x/demo/demo-app/element.d.ts +0 -1
- package/x/demo/demo-app/element.js +0 -12
- package/x/demo/demo-app/element.js.map +0 -1
- package/x/demo/demo-app/style.css.js +0 -9
- package/x/demo/demo-app/style.css.js.map +0 -1
- package/x/lib/input/data/decode.d.ts +0 -5
- package/x/lib/input/data/decode.js.map +0 -1
- package/x/lib/input/data/encode.d.ts +0 -2
- package/x/lib/input/data/encode.js +0 -17
- package/x/lib/input/data/encode.js.map +0 -1
- package/x/lib/input/data/params.js +0 -6
- package/x/lib/input/data/params.js.map +0 -1
- package/x/lib/input/encoder.d.ts +0 -10
- package/x/lib/input/encoder.js.map +0 -1
- /package/s/{_archive → lib}/utils/make-id.ts +0 -0
- /package/x/{demo/demo-app → lib/ui/views/controllers}/style.css.d.ts +0 -0
package/x/lib/test.js
CHANGED
|
@@ -1,134 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { PlainSource } from "./input/sources/plain.js";
|
|
5
|
-
import { quickbind } from "./input/testing/quickbind.js";
|
|
6
|
-
await run({
|
|
7
|
-
input: suite({
|
|
8
|
-
"roundtrip": test(async () => {
|
|
9
|
-
const { sample, solve } = quickbind("KeyE");
|
|
10
|
-
sample({ code: "KeyE", value: 0 });
|
|
11
|
-
expect(solve().value).is(0);
|
|
12
|
-
sample({ code: "KeyE", value: 1 });
|
|
13
|
-
const inputs = solve();
|
|
14
|
-
expect(inputs.value).is(1);
|
|
15
|
-
expect(inputs.was).is(0);
|
|
16
|
-
expect(inputs.delta).is(1);
|
|
17
|
-
}),
|
|
18
|
-
"update bindings": test(async () => {
|
|
19
|
-
const { sample, solve, encoder } = quickbind("KeyA");
|
|
20
|
-
sample({ code: "KeyA", value: 1 });
|
|
21
|
-
expect(solve().value).is(1);
|
|
22
|
-
sample({ code: "KeyA", value: 0 });
|
|
23
|
-
expect(solve().value).is(0);
|
|
24
|
-
encoder.bindings = "KeyB";
|
|
25
|
-
expect(encoder.bindings).is("KeyB");
|
|
26
|
-
sample({ code: "KeyA", value: 1 });
|
|
27
|
-
expect(solve().value).is(0);
|
|
28
|
-
sample({ code: "KeyA", value: 0 });
|
|
29
|
-
sample({ code: "KeyB", value: 1 });
|
|
30
|
-
expect(solve().value).is(1);
|
|
31
|
-
}),
|
|
32
|
-
"pointer movement accumulation": test(async () => {
|
|
33
|
-
const { sample, solve } = quickbind(["accumulate", ["sum", "pointer.x"]]);
|
|
34
|
-
let inputs = solve();
|
|
35
|
-
sample({ code: "pointer.x", value: 0 });
|
|
36
|
-
sample({ code: "pointer.x", value: 1 });
|
|
37
|
-
sample({ code: "pointer.x", value: 2 });
|
|
38
|
-
sample({ code: "pointer.x", value: -5 });
|
|
39
|
-
inputs = solve();
|
|
40
|
-
expect(inputs.value).is(-2);
|
|
41
|
-
expect(inputs.delta).is(-2);
|
|
42
|
-
sample({ code: "pointer.x", value: 2 });
|
|
43
|
-
sample({ code: "pointer.x", value: 5 });
|
|
44
|
-
inputs = solve();
|
|
45
|
-
expect(inputs.value).is(5);
|
|
46
|
-
expect(inputs.delta).is(7);
|
|
47
|
-
}),
|
|
48
|
-
"rapid transitions": test(async () => {
|
|
49
|
-
const { sample, solve } = quickbind({
|
|
50
|
-
key: "KeyE",
|
|
51
|
-
downs: ["down", "KeyE"],
|
|
52
|
-
ups: ["up", "KeyE"],
|
|
53
|
-
});
|
|
54
|
-
for (const value of [1, 0, 1, 0, 1])
|
|
55
|
-
sample({ code: "KeyE", value });
|
|
56
|
-
let inputs = solve();
|
|
57
|
-
expect(inputs.key.value).is(1);
|
|
58
|
-
expect(inputs.downs.value).is(3);
|
|
59
|
-
expect(inputs.ups.value).is(2);
|
|
60
|
-
inputs = solve();
|
|
61
|
-
expect(inputs.key.value).is(1);
|
|
62
|
-
expect(inputs.downs.value).is(0);
|
|
63
|
-
expect(inputs.ups.value).is(0);
|
|
64
|
-
}),
|
|
65
|
-
"double tap in one frame": test(async () => {
|
|
66
|
-
const { sample, solve } = quickbind(["taps", 2, 300, ["down", "KeyE"]]);
|
|
67
|
-
for (const value of [1, 0, 1, 0])
|
|
68
|
-
sample({ code: "KeyE", value });
|
|
69
|
-
expect(solve(100).value).is(1);
|
|
70
|
-
expect(solve(200).value).is(0);
|
|
71
|
-
}),
|
|
72
|
-
"held across empty frames": test(async () => {
|
|
73
|
-
const { sample, solve } = quickbind(["held", 300, "KeyE"]);
|
|
74
|
-
solve(0);
|
|
75
|
-
sample({ code: "KeyE", value: 1 });
|
|
76
|
-
expect(solve(100).value).is(0);
|
|
77
|
-
expect(solve(399).value).is(0);
|
|
78
|
-
expect(solve(400).value).is(1);
|
|
79
|
-
expect(solve(500).value).is(1);
|
|
80
|
-
sample({ code: "KeyE", value: 0 });
|
|
81
|
-
expect(solve(501).value).is(0);
|
|
82
|
-
sample({ code: "KeyE", value: 1 });
|
|
83
|
-
expect(solve(600).value).is(0);
|
|
84
|
-
expect(solve(900).value).is(1);
|
|
85
|
-
}),
|
|
86
|
-
"joystick integration": test(async () => {
|
|
87
|
-
const { sample, solve } = quickbind(["accumulate", ["*", "gamepad.x", ["dt"]]]);
|
|
88
|
-
solve(0);
|
|
89
|
-
sample({ code: "gamepad.x", value: 1 });
|
|
90
|
-
expect(solve(500).value).is(0.5);
|
|
91
|
-
expect(solve(1000).value).is(1);
|
|
92
|
-
sample({ code: "gamepad.x", value: 0 });
|
|
93
|
-
expect(solve(1500).value).is(1);
|
|
94
|
-
}),
|
|
95
|
-
"taps and holds coexist": test(async () => {
|
|
96
|
-
const { sample, solve } = quickbind({
|
|
97
|
-
tapper: ["taps", 1, 10, ["down", "KeyE"]],
|
|
98
|
-
holder: ["held", 10, "KeyE"],
|
|
99
|
-
});
|
|
100
|
-
solve(0);
|
|
101
|
-
sample({ code: "KeyE", value: 1 });
|
|
102
|
-
expect(solve(1).tapper.value).is(1);
|
|
103
|
-
sample({ code: "KeyE", value: 0 });
|
|
104
|
-
const released = solve(2);
|
|
105
|
-
expect(released.tapper.value).is(0);
|
|
106
|
-
expect(released.holder.value).is(0);
|
|
107
|
-
sample({ code: "KeyE", value: 1 });
|
|
108
|
-
const pressed = solve(3);
|
|
109
|
-
expect(pressed.tapper.value).is(1);
|
|
110
|
-
expect(pressed.holder.value).is(0);
|
|
111
|
-
const holding = solve(13);
|
|
112
|
-
expect(holding.tapper.value).is(0);
|
|
113
|
-
expect(holding.holder.value).is(1);
|
|
114
|
-
}),
|
|
115
|
-
"independent encoder consumers": test(async () => {
|
|
116
|
-
const source = new PlainSource();
|
|
117
|
-
const bindings = asBindings({
|
|
118
|
-
downs: ["down", "KeyE"],
|
|
119
|
-
ups: ["up", "KeyE"],
|
|
120
|
-
});
|
|
121
|
-
const fast = new InputEncoder(source, bindings);
|
|
122
|
-
const slow = new InputEncoder(source, bindings);
|
|
123
|
-
source.onSample.publish({ code: "KeyE", value: 1 });
|
|
124
|
-
expect([...fast.evaluate(1)].map(i => i.value)).deep([1, 0]);
|
|
125
|
-
source.onSample.publish({ code: "KeyE", value: 0 });
|
|
126
|
-
expect([...fast.evaluate(2)].map(i => i.value)).deep([0, 1]);
|
|
127
|
-
// slow consumer receives both transitions in one batch.
|
|
128
|
-
expect([...slow.evaluate(20)].map(i => i.value)).deep([1, 1]);
|
|
129
|
-
fast.dispose();
|
|
130
|
-
slow.dispose();
|
|
131
|
-
}),
|
|
132
|
-
}),
|
|
133
|
-
});
|
|
1
|
+
import { run } from "@e280/science";
|
|
2
|
+
import input from "./input/test.js";
|
|
3
|
+
await run({ input });
|
|
134
4
|
//# sourceMappingURL=test.js.map
|
package/x/lib/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/lib/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../s/lib/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAA;AACjC,OAAO,KAAK,MAAM,iBAAiB,CAAA;AAEnC,MAAM,GAAG,CAAC,EAAC,KAAK,EAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Hub } from "./hub.js";
|
|
2
|
+
import { Controller } from "../../input/controller.js";
|
|
3
|
+
import { GamepadSource } from "../../input/sources/gamepad.js";
|
|
4
|
+
export declare function autoGamepads(hub: Hub, fn?: (controller: Controller, source: GamepadSource) => () => void): () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Controller } from "../../input/controller.js";
|
|
2
|
+
import { onPad } from "../../input/utils/pad/on-pad.js";
|
|
3
|
+
import { GamepadSource } from "../../input/sources/gamepad.js";
|
|
4
|
+
export function autoGamepads(hub, fn) {
|
|
5
|
+
return onPad(pad => {
|
|
6
|
+
const source = new GamepadSource(pad);
|
|
7
|
+
const controller = new Controller({
|
|
8
|
+
source,
|
|
9
|
+
bindings: hub.bindings,
|
|
10
|
+
});
|
|
11
|
+
hub.plug(controller);
|
|
12
|
+
const dispose = fn?.(controller, source);
|
|
13
|
+
return () => {
|
|
14
|
+
hub.remove(controller);
|
|
15
|
+
dispose?.();
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=auto-gamepads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-gamepads.js","sourceRoot":"","sources":["../../../../s/lib/ui/deck/auto-gamepads.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAA;AAE5D,MAAM,UAAU,YAAY,CAC1B,GAAQ,EACR,EAAkE;IAGnE,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE;QAClB,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,CAAA;QAErC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;YACjC,MAAM;YACN,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACtB,CAAC,CAAA;QAEF,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACpB,MAAM,OAAO,GAAG,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QAExC,OAAO,GAAG,EAAE;YACX,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;YACtB,OAAO,EAAE,EAAE,CAAA;QACZ,CAAC,CAAA;IACF,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Bindings } from "../../input/types.js";
|
|
2
|
+
export declare class Collector<B extends Bindings> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(bindings: B);
|
|
5
|
+
get players(): {
|
|
6
|
+
playerId: number;
|
|
7
|
+
inputs: import("../../input/types.js").Inputs<B>;
|
|
8
|
+
}[];
|
|
9
|
+
decodeAll(...buffers: ArrayBuffer[]): {
|
|
10
|
+
playerId: number;
|
|
11
|
+
inputs: import("../../input/types.js").Inputs<B>;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RMap } from "@e280/strata";
|
|
2
|
+
import { guarantee } from "@e280/stz";
|
|
3
|
+
import { InputDecoder } from "../../input/decoder.js";
|
|
4
|
+
import { decodeParcels } from "../../input/data/parcel/decode.js";
|
|
5
|
+
export class Collector {
|
|
6
|
+
#bindings;
|
|
7
|
+
#decoders = new RMap();
|
|
8
|
+
constructor(bindings) {
|
|
9
|
+
this.#bindings = bindings;
|
|
10
|
+
}
|
|
11
|
+
get players() {
|
|
12
|
+
return [...this.#decoders].map(([playerId, decoder]) => ({
|
|
13
|
+
playerId,
|
|
14
|
+
inputs: decoder.inputs,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
#getDecoder(playerId) {
|
|
18
|
+
return guarantee(this.#decoders, playerId, () => new InputDecoder(this.#bindings));
|
|
19
|
+
}
|
|
20
|
+
decodeAll(...buffers) {
|
|
21
|
+
const grouped = new Map();
|
|
22
|
+
for (const buffer of buffers) {
|
|
23
|
+
for (const { playerId, intents } of decodeParcels(buffer))
|
|
24
|
+
guarantee(grouped, playerId, () => []).push(intents);
|
|
25
|
+
}
|
|
26
|
+
for (const [playerId, intents] of grouped)
|
|
27
|
+
this.#getDecoder(playerId).decode(...intents);
|
|
28
|
+
for (const playerId of this.#decoders.keys()) {
|
|
29
|
+
if (!grouped.has(playerId))
|
|
30
|
+
this.#decoders.delete(playerId);
|
|
31
|
+
}
|
|
32
|
+
return this.players;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../../s/lib/ui/deck/collector.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAA;AAInC,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,mCAAmC,CAAA;AAE/D,MAAM,OAAO,SAAS;IACrB,SAAS,CAAG;IACZ,SAAS,GAAG,IAAI,IAAI,EAA6B,CAAA;IAEjD,YAAY,QAAW;QACtB,IAAI,CAAC,S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js";
|
|
2
|
+
import { Bindings } from "../../../input/types.js";
|
|
3
|
+
import { Assignments } from "./internal/assignments.js";
|
|
4
|
+
import { Controller } from "../../../input/controller.js";
|
|
5
|
+
import { ControllerMeta, ControlsOptions } from "./types.js";
|
|
6
|
+
export declare class Controls<B extends Bindings = any> {
|
|
7
|
+
#private;
|
|
8
|
+
profiles: Profiles<B>;
|
|
9
|
+
assignments: Assignments;
|
|
10
|
+
readonly presets: import("../types.js").Presets<B>;
|
|
11
|
+
constructor(options: ControlsOptions<B>);
|
|
12
|
+
get on(): (fn: () => unknown) => () => void;
|
|
13
|
+
load(): Promise<void>;
|
|
14
|
+
get controllers(): Controller<any>[];
|
|
15
|
+
get fallbackProfileKey(): string;
|
|
16
|
+
meta(controller: Controller): ControllerMeta | undefined;
|
|
17
|
+
attach(controller: Controller, meta: Omit<ControllerMeta, "id">): void;
|
|
18
|
+
detach(controller: Controller): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { collect, got, setEntries } from "@e280/stz";
|
|
2
|
+
import { Profiles } from "./internal/profiles.js";
|
|
3
|
+
import { makeControlsData } from "./internal/data.js";
|
|
4
|
+
import { Assignments } from "./internal/assignments.js";
|
|
5
|
+
export class Controls {
|
|
6
|
+
#data;
|
|
7
|
+
profiles;
|
|
8
|
+
assignments;
|
|
9
|
+
presets;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.#data = makeControlsData(options);
|
|
12
|
+
this.profiles = new Profiles(this.#data);
|
|
13
|
+
this.assignments = new Assignments(this.#data);
|
|
14
|
+
this.presets = options.presets;
|
|
15
|
+
}
|
|
16
|
+
get on() {
|
|
17
|
+
return this.#data.subby.on;
|
|
18
|
+
}
|
|
19
|
+
#rebind(controller) {
|
|
20
|
+
const { preferences, assignments, controllers } = this.#data;
|
|
21
|
+
const meta = got(controllers.get(controller));
|
|
22
|
+
const profileKey = assignments.get(controller)
|
|
23
|
+
?? preferences.get(meta.handle)
|
|
24
|
+
?? meta.defaultProfileKey;
|
|
25
|
+
controller.bindings = this.profiles.get(profileKey).bindings;
|
|
26
|
+
assignments.set(controller, profileKey);
|
|
27
|
+
}
|
|
28
|
+
async load() {
|
|
29
|
+
const { kvs, controllers, preferences, profiles: { customs } } = this.#data;
|
|
30
|
+
customs.clear();
|
|
31
|
+
setEntries(customs, await collect(kvs.profiles));
|
|
32
|
+
preferences.clear();
|
|
33
|
+
setEntries(preferences, await collect(kvs.preferences));
|
|
34
|
+
for (const controller of controllers.keys())
|
|
35
|
+
this.#rebind(controller);
|
|
36
|
+
}
|
|
37
|
+
get controllers() {
|
|
38
|
+
return [...this.#data.controllers.keys()];
|
|
39
|
+
}
|
|
40
|
+
get fallbackProfileKey() {
|
|
41
|
+
return this.#data.profiles.fallback.key;
|
|
42
|
+
}
|
|
43
|
+
meta(controller) {
|
|
44
|
+
return this.#data.controllers.get(controller);
|
|
45
|
+
}
|
|
46
|
+
attach(controller, meta) {
|
|
47
|
+
const id = this.#data.idCounter.next();
|
|
48
|
+
this.#data.controllers.set(controller, { ...meta, id });
|
|
49
|
+
this.#rebind(controller);
|
|
50
|
+
}
|
|
51
|
+
detach(controller) {
|
|
52
|
+
this.#data.controllers.delete(controller);
|
|
53
|
+
this.#data.assignments.delete(controller);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../../../s/lib/ui/deck/controls/controls.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAC,MAAM,WAAW,CAAA;AAElD,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AAIrD,MAAM,OAAO,QAAQ;IACpB,KAAK,CAAA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AAA;QAEhD,WAAW,CAAC,KAAK,EAAE,CAAA;QACnB,UAAU,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAA;QAEvD,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,IAAI,EAAE;YAC1C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC1B,CAAC;IAED,IAAI,WAAW;QACd,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,kBAAkB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAA;IACxC,CAAC;IAED,IAAI,CAAC,UAAsB;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC9C,CAAC;IAED,MAAM,CAAC,UAAsB,EAAE,IAAgC;QAC9D,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACtC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,EAAC,GAAG,IAAI,EAAE,EAAE,EAAC,CAAC,CAAA;QACrD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACzB,CAAC;IAED,MAAM,CAAC,UAAsB;QAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QACzC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAC1C,CAAC;CACD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ControlsData } from "./data.js";
|
|
2
|
+
import { ProfileKey } from "../../types.js";
|
|
3
|
+
import { Controller } from "../../../../input/controller.js";
|
|
4
|
+
export declare class Assignments {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(data: ControlsData<any>);
|
|
7
|
+
assign(controller: Controller, profileKey: ProfileKey): Promise<void>;
|
|
8
|
+
assignedProfileKeyOf(controller: Controller): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { assignProfile } from "./fns.js";
|
|
2
|
+
export class Assignments {
|
|
3
|
+
#data;
|
|
4
|
+
constructor(data) {
|
|
5
|
+
this.#data = data;
|
|
6
|
+
}
|
|
7
|
+
async assign(controller, profileKey) {
|
|
8
|
+
await assignProfile(this.#data, controller, profileKey);
|
|
9
|
+
this.#data.subby.publish();
|
|
10
|
+
}
|
|
11
|
+
assignedProfileKeyOf(controller) {
|
|
12
|
+
const { assignments } = this.#data;
|
|
13
|
+
return assignments.get(controller) ?? this.#data.profiles.fallback.key;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=assignments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assignments.js","sourceRoot":"","sources":["../../../../../../s/lib/ui/deck/controls/internal/assignments.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAKtC,MAAM,OAAO,WAAW;IACvB,KAAK,CAAA;IAEL,YAAY,IAAuB;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAsB,EAAE,UAAsB;QAC1D,MAAM,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;QACvD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;IAED,oBAAoB,CAAC,UAAsB;QAC1C,MAAM,EAAC,WAAW,EAAC,GAAG,IAAI,CAAC,KAAK,CAAA;QAChC,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAA;IACvE,CAAC;CACD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RMap } from "@e280/strata";
|
|
2
|
+
import { IdCounter } from "@e280/stz";
|
|
3
|
+
import { Profile } from "../../types.js";
|
|
4
|
+
import { Bindings } from "../../../../input/types.js";
|
|
5
|
+
import { Controller } from "../../../../input/controller.js";
|
|
6
|
+
import { ControllerMeta, ControlsOptions } from "../types.js";
|
|
7
|
+
export type ControlsData<B extends Bindings> = (ReturnType<typeof makeControlsData<B>>);
|
|
8
|
+
export declare function makeControlsData<B extends Bindings>({ kv, presets, }: ControlsOptions<B>): {
|
|
9
|
+
subby: import("@e280/stz").Subby<[]>;
|
|
10
|
+
kv: import("@e280/kv").Kv<unknown>;
|
|
11
|
+
presets: import("../../types.js").Presets<B>;
|
|
12
|
+
bindings: B;
|
|
13
|
+
idCounter: IdCounter;
|
|
14
|
+
profiles: {
|
|
15
|
+
presets: RMap<string, Profile<B>>;
|
|
16
|
+
customs: RMap<string, Profile<B>>;
|
|
17
|
+
fallback: {
|
|
18
|
+
key: string;
|
|
19
|
+
profile: Profile<B>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
controllers: RMap<Controller<any>, ControllerMeta>;
|
|
23
|
+
assignments: RMap<Controller<any>, string>;
|
|
24
|
+
preferences: RMap<string, string>;
|
|
25
|
+
kvs: {
|
|
26
|
+
profiles: import("@e280/kv").Kv<Profile>;
|
|
27
|
+
preferences: import("@e280/kv").Kv<string>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RMap } from "@e280/strata";
|
|
2
|
+
import { got, IdCounter, setEntries, subby } from "@e280/stz";
|
|
3
|
+
export function makeControlsData({ kv, presets, }) {
|
|
4
|
+
const fallbackKey = got(Object.keys(presets)[0], "missing presets");
|
|
5
|
+
const fallbackProfile = got(presets[fallbackKey]);
|
|
6
|
+
const bindings = fallbackProfile.bindings;
|
|
7
|
+
const profiles = {
|
|
8
|
+
presets: new RMap(),
|
|
9
|
+
customs: new RMap(),
|
|
10
|
+
fallback: { key: fallbackKey, profile: fallbackProfile },
|
|
11
|
+
};
|
|
12
|
+
setEntries(profiles.presets, Object.entries(presets));
|
|
13
|
+
return {
|
|
14
|
+
subby: subby(),
|
|
15
|
+
kv,
|
|
16
|
+
presets,
|
|
17
|
+
bindings,
|
|
18
|
+
idCounter: new IdCounter(),
|
|
19
|
+
profiles,
|
|
20
|
+
controllers: new RMap(),
|
|
21
|
+
assignments: new RMap(),
|
|
22
|
+
preferences: new RMap(),
|
|
23
|
+
kvs: {
|
|
24
|
+
profiles: kv.scope("profiles"),
|
|
25
|
+
preferences: kv.scope("preferences"),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../../../../../s/lib/ui/deck/controls/internal/data.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,WAAW,CAAA;AAW3D,MAAM,UAAU,gBAAgB,CAAqB,EACnD,EAAE,EACF,OAAO,GACa;IAErB,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;IACnE,MAAM,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAA;IAEzC,MAAM,QAAQ,GAAG;QAChB,OAAO,EAAE,IAAI,IAAI,EAA0B;QAC3C,OAAO,EAAE,IAAI,IAAI,EAA0B;QAC3C,QAAQ,EAAE,EAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAC;KACtD,CAAA;IAED,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IAErD,OAAO;QACN,KAAK,EAAE,KAAK,EAAE;QAEd,EAAE;QACF,OAAO;QACP,QAAQ;QACR,SAAS,EAAE,IAAI,SAAS,EAAE;QAE1B,QAAQ;QAER,WAAW,EAAE,IAAI,IAAI,EAA8B;QACnD,WAAW,EAAE,IAAI,IAAI,EAA0B;QAC/C,WAAW,EAAE,IAAI,IAAI,EAAgC;QAErD,GAAG,EAAE;YACJ,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAU,UAAU,CAAC;YACvC,WAAW,EAAE,EAAE,CAAC,KAAK,CAAa,aAAa,CAAC;SAChD;KACD,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ControlsData } from "./data.js";
|
|
2
|
+
import { ProfileKey } from "../../types.js";
|
|
3
|
+
import { Bindings } from "../../../../input/types.js";
|
|
4
|
+
import { Controller } from "../../../../input/controller.js";
|
|
5
|
+
export declare function getProfile<B extends Bindings>(data: ControlsData<B>, profileKey?: ProfileKey): import("../../types.js").Profile<B>;
|
|
6
|
+
export declare function assignProfile<B extends Bindings>(data: ControlsData<B>, controller: Controller, profileKey: ProfileKey): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { given, got } from "@e280/stz";
|
|
2
|
+
export function getProfile(data, profileKey) {
|
|
3
|
+
const { presets, customs, fallback } = data.profiles;
|
|
4
|
+
if (profileKey === undefined)
|
|
5
|
+
return fallback.profile;
|
|
6
|
+
return customs.get(profileKey)
|
|
7
|
+
?? presets.get(profileKey)
|
|
8
|
+
?? got(presets.get(fallback.key));
|
|
9
|
+
}
|
|
10
|
+
export async function assignProfile(data, controller, profileKey) {
|
|
11
|
+
const { kvs, controllers, assignments } = data;
|
|
12
|
+
controller.bindings = getProfile(data, profileKey).bindings;
|
|
13
|
+
assignments.set(controller, profileKey);
|
|
14
|
+
await given(controllers.get(controller)?.handle, async (handle) => {
|
|
15
|
+
data.preferences.set(handle, profileKey);
|
|
16
|
+
await kvs.preferences.set(handle, profileKey);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=fns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fns.js","sourceRoot":"","sources":["../../../../../../s/lib/ui/deck/controls/internal/fns.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAMpC,MAAM,UAAU,UAAU,CACxB,IAAqB,EACrB,UAAuB;IAGxB,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAA;IAElD,IAAI,UAAU,KAAK,SAAS;QAC3B,OAAO,QAAQ,CAAC,OAAO,CAAA;IAExB,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;WAC1B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;WACvB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAqB,EACrB,UAAsB,EACtB,UAAsB;IAGvB,MAAM,EAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAC,GAAG,IAAI,CAAA;IAC5C,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAA;IAC3D,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAEvC,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QAC/D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QACxC,MAAM,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ControlsData } from "./data.js";
|
|
2
|
+
import { Profile, ProfileKey } from "../../types.js";
|
|
3
|
+
import { Bindings } from "../../../../input/types.js";
|
|
4
|
+
export declare class Profiles<B extends Bindings> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(data: ControlsData<B>);
|
|
7
|
+
get presets(): [string, Profile<B>][];
|
|
8
|
+
get customs(): [string, Profile<B>][];
|
|
9
|
+
isPreset(profileKey: string): boolean;
|
|
10
|
+
get(profileKey?: ProfileKey): Profile<B>;
|
|
11
|
+
create(key: ProfileKey, profile: Profile<B>): Promise<void>;
|
|
12
|
+
clone(key: ProfileKey, basedOn: ProfileKey): Promise<void>;
|
|
13
|
+
delete(profileKey: ProfileKey): Promise<void>;
|
|
14
|
+
update(profileKey: ProfileKey, changes: Partial<{
|
|
15
|
+
bindings: B;
|
|
16
|
+
label: string;
|
|
17
|
+
}>): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { assignProfile, getProfile } from "./fns.js";
|
|
2
|
+
import { isCompatible } from "../../../../input/investigate/is-compatible.js";
|
|
3
|
+
export class Profiles {
|
|
4
|
+
#data;
|
|
5
|
+
constructor(data) {
|
|
6
|
+
this.#data = data;
|
|
7
|
+
}
|
|
8
|
+
#ensureBindingsAreCompatible(b) {
|
|
9
|
+
if (!isCompatible(b, this.#data.bindings))
|
|
10
|
+
throw new Error("incompatible bindings");
|
|
11
|
+
}
|
|
12
|
+
get presets() {
|
|
13
|
+
return [...this.#data.profiles.presets];
|
|
14
|
+
}
|
|
15
|
+
get customs() {
|
|
16
|
+
return [...this.#data.profiles.customs];
|
|
17
|
+
}
|
|
18
|
+
isPreset(profileKey) {
|
|
19
|
+
return this.#data.profiles.presets.has(profileKey);
|
|
20
|
+
}
|
|
21
|
+
get(profileKey) {
|
|
22
|
+
return getProfile(this.#data, profileKey);
|
|
23
|
+
}
|
|
24
|
+
async create(key, profile) {
|
|
25
|
+
const { kvs, profiles } = this.#data;
|
|
26
|
+
this.#ensureBindingsAreCompatible(profile.bindings);
|
|
27
|
+
profiles.customs.set(key, profile);
|
|
28
|
+
await kvs.profiles.set(key, profile);
|
|
29
|
+
this.#data.subby.publish();
|
|
30
|
+
}
|
|
31
|
+
async clone(key, basedOn) {
|
|
32
|
+
const { label, bindings } = this.get(basedOn);
|
|
33
|
+
await this.create(key, { basedOn, bindings, label: `${label} copy` });
|
|
34
|
+
}
|
|
35
|
+
async delete(profileKey) {
|
|
36
|
+
const { kvs, assignments, profiles: { customs, fallback } } = this.#data;
|
|
37
|
+
customs.delete(profileKey);
|
|
38
|
+
await kvs.profiles.delete(profileKey);
|
|
39
|
+
for (const [controller, controllerKey] of assignments)
|
|
40
|
+
if (controllerKey === profileKey)
|
|
41
|
+
await assignProfile(this.#data, controller, fallback.key);
|
|
42
|
+
this.#data.subby.publish();
|
|
43
|
+
}
|
|
44
|
+
async update(profileKey, changes) {
|
|
45
|
+
const { kvs, assignments, profiles: { customs } } = this.#data;
|
|
46
|
+
if (changes.bindings)
|
|
47
|
+
this.#ensureBindingsAreCompatible(changes.bindings);
|
|
48
|
+
const staleProfile = this.get(profileKey);
|
|
49
|
+
const freshProfile = { ...structuredClone(staleProfile), ...changes };
|
|
50
|
+
customs.set(profileKey, freshProfile);
|
|
51
|
+
for (const [controller, controllerKey] of assignments) {
|
|
52
|
+
if (controllerKey === profileKey)
|
|
53
|
+
controller.bindings = freshProfile.bindings;
|
|
54
|
+
}
|
|
55
|
+
await kvs.profiles.set(profileKey, freshProfile);
|
|
56
|
+
this.#data.subby.publish();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|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GAAG,CAAC,UAAU,CAAC,CAAA;QACzC,MAAM,YAAY,GAAG,EAAC,GAAG,eAAe,CAAC,YAAY,CAAC,EAAE,GAAG,OAAO,EAAC,CAAA;QAEnE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;QAErC,KAAK,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,WAAW,EAAE,CAAC;YACvD,IAAI,aAAa,KAAK,UAAU;gBAC/B,UAAU,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAA;QAC7C,CAAC;QAED,MAAM,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;QAChD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Kv } from "@e280/kv";
|
|
2
|
+
import { Content } from "@e280/sly";
|
|
3
|
+
import { Bindings } from "../../../input/types.js";
|
|
4
|
+
import { ProfileKey, Presets } from "../types.js";
|
|
5
|
+
export type ControllerHandle = string;
|
|
6
|
+
export type ControllerMeta = {
|
|
7
|
+
id: number;
|
|
8
|
+
icon: Content;
|
|
9
|
+
handle: ControllerHandle;
|
|
10
|
+
name: string;
|
|
11
|
+
tooltip: string;
|
|
12
|
+
defaultProfileKey: ProfileKey;
|
|
13
|
+
};
|
|
14
|
+
export type ControlsOptions<B extends Bindings> = {
|
|
15
|
+
kv: Kv;
|
|
16
|
+
presets: Presets<B>;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../s/lib/ui/deck/controls/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PlayerId } from "./types.js";
|
|
2
|
+
import { Bindings } from "../../input/types.js";
|
|
3
|
+
import { Controller } from "../../input/controller.js";
|
|
4
|
+
export declare class Hub<B extends Bindings = any> {
|
|
5
|
+
#private;
|
|
6
|
+
readonly bindings: B;
|
|
7
|
+
constructor(bindings: B);
|
|
8
|
+
get playerIds(): number[];
|
|
9
|
+
get controllers(): {
|
|
10
|
+
unassigned: Controller<B>[];
|
|
11
|
+
assigned: Map<number, Controller<B>[]>;
|
|
12
|
+
};
|
|
13
|
+
createPlayer(): PlayerId;
|
|
14
|
+
deletePlayer(playerId: PlayerId): this;
|
|
15
|
+
add(controller: Controller<B>): this;
|
|
16
|
+
remove(controller: Controller<B>): this;
|
|
17
|
+
unplug(controller: Controller<B>): this;
|
|
18
|
+
plug(controller: Controller<B>, playerId?: PlayerId): this;
|
|
19
|
+
encode(playerId: PlayerId, time?: number): ArrayBuffer;
|
|
20
|
+
encodeAll(time?: number): ArrayBuffer;
|
|
21
|
+
}
|