@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.
Files changed (419) hide show
  1. package/README.md +205 -133
  2. package/package.json +8 -7
  3. package/s/core/{port → bindings}/action.ts +15 -5
  4. package/s/core/bindings/parts/defaults.ts +31 -0
  5. package/s/core/{port/resolution → bindings/parts}/lens-algo.ts +23 -20
  6. package/s/core/bindings/resolver.ts +96 -0
  7. package/s/core/bindings/sample-map.ts +25 -0
  8. package/s/core/bindings/types.ts +45 -42
  9. package/s/core/core.test.ts +46 -34
  10. package/s/core/devices/auto-gamepads.ts +8 -0
  11. package/s/core/devices/device.ts +12 -0
  12. package/s/core/devices/infra/group.ts +24 -0
  13. package/s/core/devices/infra/sampler.ts +22 -0
  14. package/s/core/devices/standard/gamepad.ts +83 -0
  15. package/s/core/{controllers → devices}/standard/index.ts +2 -1
  16. package/s/core/devices/standard/keyboard.ts +31 -0
  17. package/s/core/{controllers → devices}/standard/pointer.ts +18 -20
  18. package/s/core/devices/standard/primary.ts +20 -0
  19. package/s/core/devices/standard/stick.ts +27 -0
  20. package/s/core/{controllers/standard/virtual-gamepad.ts → devices/standard/vpad.ts} +9 -9
  21. package/s/core/{controllers → devices}/types.ts +0 -1
  22. package/s/core/hub/hub.ts +78 -62
  23. package/s/core/hub/meta-bindings.ts +23 -0
  24. package/s/core/hub/parts/connected.ts +15 -0
  25. package/s/core/hub/port.ts +26 -0
  26. package/s/core/hub/types.ts +13 -0
  27. package/s/core/index.ts +13 -13
  28. package/s/core/testing/testing.ts +22 -17
  29. package/s/deck/deck.ts +77 -0
  30. package/s/deck/index.ts +14 -0
  31. package/s/deck/parts/catalog.ts +58 -0
  32. package/s/deck/parts/db.ts +66 -0
  33. package/s/deck/parts/device-skins/device-icons.ts +38 -0
  34. package/s/deck/parts/device-skins/device-skin.ts +29 -0
  35. package/s/deck/parts/local-storage-kv.ts +8 -0
  36. package/s/deck/parts/merge-bindings.ts +21 -0
  37. package/s/deck/parts/overlay-visibility.ts +49 -0
  38. package/s/deck/views/deck-overlay/component.ts +48 -0
  39. package/s/deck/views/deck-overlay/style.css.ts +112 -0
  40. package/s/deck/views/framework.ts +14 -0
  41. package/s/demo/game/game.ts +85 -0
  42. package/s/demo/game/parts/agent.ts +10 -0
  43. package/s/demo/game/parts/game-bindings.ts +20 -0
  44. package/s/demo/game/parts/logic.ts +24 -0
  45. package/s/demo/game/parts/player.ts +32 -0
  46. package/s/demo/game/parts/renderer.ts +113 -0
  47. package/s/demo/game/parts/state.ts +24 -0
  48. package/s/demo/game/parts/virtual-device.ts +13 -0
  49. package/s/demo/main.bundle.ts +6 -12
  50. package/s/demo/main.css +30 -2
  51. package/s/demo/ui/tact-demo/component.ts +13 -0
  52. package/s/demo/ui/tact-demo/style.css.ts +4 -0
  53. package/s/demo/ui/theater/styles.css.ts +57 -0
  54. package/s/demo/ui/theater/view.ts +53 -0
  55. package/s/demo/ui/theater/virtual/style.css.ts +43 -0
  56. package/s/demo/ui/theater/virtual/view.ts +31 -0
  57. package/s/demo/ui/utils/loader.ts +5 -0
  58. package/s/index.html.ts +16 -6
  59. package/s/index.ts +3 -1
  60. package/s/nubs/components.ts +14 -0
  61. package/s/nubs/index.ts +6 -0
  62. package/s/nubs/lookpad/component.ts +45 -0
  63. package/s/nubs/stick/component.ts +115 -0
  64. package/s/nubs/stick/style.css.ts +70 -0
  65. package/s/nubs/{virtual-gamepad/view.ts → vpad/component.ts} +21 -11
  66. package/s/nubs/{virtual-gamepad → vpad}/styles.css.ts +1 -0
  67. package/s/utils/circular-clamp.ts +15 -0
  68. package/s/utils/dispensers.ts +20 -0
  69. package/s/utils/split-axis.ts +10 -2
  70. package/x/core/{port → bindings}/action.d.ts +3 -1
  71. package/x/core/{port → bindings}/action.js +13 -5
  72. package/x/core/bindings/action.js.map +1 -0
  73. package/x/core/bindings/parts/defaults.d.ts +3 -0
  74. package/x/core/bindings/parts/defaults.js +25 -0
  75. package/x/core/bindings/parts/defaults.js.map +1 -0
  76. package/x/core/bindings/parts/is-pressed.js.map +1 -0
  77. package/x/core/bindings/parts/lens-algo.d.ts +2 -0
  78. package/x/core/{port/resolution → bindings/parts}/lens-algo.js +18 -11
  79. package/x/core/bindings/parts/lens-algo.js.map +1 -0
  80. package/x/core/bindings/resolver.d.ts +9 -0
  81. package/x/core/bindings/resolver.js +89 -0
  82. package/x/core/bindings/resolver.js.map +1 -0
  83. package/x/core/bindings/sample-map.d.ts +7 -0
  84. package/x/core/bindings/sample-map.js +22 -0
  85. package/x/core/bindings/sample-map.js.map +1 -0
  86. package/x/core/bindings/types.d.ts +34 -38
  87. package/x/core/bindings/types.js +0 -1
  88. package/x/core/bindings/types.js.map +1 -1
  89. package/x/core/core.test.d.ts +5 -4
  90. package/x/core/core.test.js +45 -34
  91. package/x/core/core.test.js.map +1 -1
  92. package/x/core/devices/auto-gamepads.d.ts +2 -0
  93. package/x/core/devices/auto-gamepads.js +6 -0
  94. package/x/core/devices/auto-gamepads.js.map +1 -0
  95. package/x/core/devices/device.d.ts +5 -0
  96. package/x/core/devices/device.js +7 -0
  97. package/x/core/devices/device.js.map +1 -0
  98. package/x/core/devices/infra/group.d.ts +8 -0
  99. package/x/core/devices/infra/group.js +21 -0
  100. package/x/core/devices/infra/group.js.map +1 -0
  101. package/x/core/devices/infra/sampler.d.ts +9 -0
  102. package/x/core/devices/infra/sampler.js +18 -0
  103. package/x/core/devices/infra/sampler.js.map +1 -0
  104. package/x/core/devices/standard/gamepad.d.ts +11 -0
  105. package/x/core/devices/standard/gamepad.js +65 -0
  106. package/x/core/devices/standard/gamepad.js.map +1 -0
  107. package/x/core/{controllers → devices}/standard/index.d.ts +2 -1
  108. package/x/core/{controllers → devices}/standard/index.js +2 -1
  109. package/x/core/devices/standard/index.js.map +1 -0
  110. package/x/core/devices/standard/keyboard.d.ts +9 -0
  111. package/x/core/devices/standard/keyboard.js +28 -0
  112. package/x/core/devices/standard/keyboard.js.map +1 -0
  113. package/x/core/devices/standard/pointer.d.ts +15 -0
  114. package/x/core/{controllers → devices}/standard/pointer.js +17 -19
  115. package/x/core/devices/standard/pointer.js.map +1 -0
  116. package/x/core/devices/standard/primary.d.ts +10 -0
  117. package/x/core/devices/standard/primary.js +17 -0
  118. package/x/core/devices/standard/primary.js.map +1 -0
  119. package/x/core/devices/standard/stick.d.ts +15 -0
  120. package/x/core/devices/standard/stick.js +24 -0
  121. package/x/core/devices/standard/stick.js.map +1 -0
  122. package/x/core/devices/standard/vpad.d.ts +7 -0
  123. package/x/core/{controllers/standard/virtual-gamepad.js → devices/standard/vpad.js} +10 -10
  124. package/x/core/devices/standard/vpad.js.map +1 -0
  125. package/x/core/{controllers → devices}/types.d.ts +0 -1
  126. package/x/core/{port → devices}/types.js.map +1 -1
  127. package/x/core/hub/hub.d.ts +27 -24
  128. package/x/core/hub/hub.js +71 -61
  129. package/x/core/hub/hub.js.map +1 -1
  130. package/x/core/hub/meta-bindings.d.ts +2 -0
  131. package/x/core/hub/meta-bindings.js +21 -0
  132. package/x/core/hub/meta-bindings.js.map +1 -0
  133. package/x/core/hub/parts/connected.d.ts +14 -0
  134. package/x/core/hub/parts/connected.js +12 -0
  135. package/x/core/hub/parts/connected.js.map +1 -0
  136. package/x/core/hub/port.d.ts +10 -0
  137. package/x/core/hub/port.js +19 -0
  138. package/x/core/hub/port.js.map +1 -0
  139. package/x/core/hub/types.d.ts +9 -0
  140. package/x/core/hub/types.js +2 -0
  141. package/x/core/hub/types.js.map +1 -0
  142. package/x/core/index.d.ts +13 -12
  143. package/x/core/index.js +13 -12
  144. package/x/core/index.js.map +1 -1
  145. package/x/core/testing/testing.d.ts +20 -38
  146. package/x/core/testing/testing.js +17 -16
  147. package/x/core/testing/testing.js.map +1 -1
  148. package/x/deck/deck.d.ts +35 -0
  149. package/x/deck/deck.js +50 -0
  150. package/x/deck/deck.js.map +1 -0
  151. package/x/deck/index.d.ts +10 -0
  152. package/x/deck/index.js +11 -0
  153. package/x/deck/index.js.map +1 -0
  154. package/x/deck/parts/catalog.d.ts +23 -0
  155. package/x/deck/parts/catalog.js +35 -0
  156. package/x/deck/parts/catalog.js.map +1 -0
  157. package/x/deck/parts/db.d.ts +20 -0
  158. package/x/deck/parts/db.js +52 -0
  159. package/x/deck/parts/db.js.map +1 -0
  160. package/x/deck/parts/device-skins/device-icons.d.ts +12 -0
  161. package/x/deck/parts/device-skins/device-icons.js +27 -0
  162. package/x/deck/parts/device-skins/device-icons.js.map +1 -0
  163. package/x/deck/parts/device-skins/device-skin.d.ts +14 -0
  164. package/x/deck/parts/device-skins/device-skin.js +22 -0
  165. package/x/deck/parts/device-skins/device-skin.js.map +1 -0
  166. package/x/deck/parts/local-storage-kv.d.ts +2 -0
  167. package/x/deck/parts/local-storage-kv.js +6 -0
  168. package/x/deck/parts/local-storage-kv.js.map +1 -0
  169. package/x/deck/parts/merge-bindings.d.ts +2 -0
  170. package/x/deck/parts/merge-bindings.js +15 -0
  171. package/x/deck/parts/merge-bindings.js.map +1 -0
  172. package/x/deck/parts/overlay-visibility.d.ts +21 -0
  173. package/x/deck/parts/overlay-visibility.js +35 -0
  174. package/x/deck/parts/overlay-visibility.js.map +1 -0
  175. package/x/deck/views/deck-overlay/component.d.ts +2 -0
  176. package/x/deck/views/deck-overlay/component.js +40 -0
  177. package/x/deck/views/deck-overlay/component.js.map +1 -0
  178. package/x/deck/views/deck-overlay/style.css.js +109 -0
  179. package/x/deck/views/deck-overlay/style.css.js.map +1 -0
  180. package/x/deck/views/framework.d.ts +3 -0
  181. package/x/deck/views/framework.js +8 -0
  182. package/x/deck/views/framework.js.map +1 -0
  183. package/x/demo/game/game.d.ts +20 -0
  184. package/x/demo/game/game.js +63 -0
  185. package/x/demo/game/game.js.map +1 -0
  186. package/x/demo/game/parts/agent.d.ts +7 -0
  187. package/x/demo/game/parts/agent.js +8 -0
  188. package/x/demo/game/parts/agent.js.map +1 -0
  189. package/x/demo/game/parts/game-bindings.d.ts +15 -0
  190. package/x/demo/game/parts/game-bindings.js +10 -0
  191. package/x/demo/game/parts/game-bindings.js.map +1 -0
  192. package/x/demo/game/parts/logic.d.ts +8 -0
  193. package/x/demo/game/parts/logic.js +21 -0
  194. package/x/demo/game/parts/logic.js.map +1 -0
  195. package/x/demo/game/parts/player.d.ts +14 -0
  196. package/x/demo/game/parts/player.js +26 -0
  197. package/x/demo/game/parts/player.js.map +1 -0
  198. package/x/demo/game/parts/renderer.d.ts +13 -0
  199. package/x/demo/game/parts/renderer.js +91 -0
  200. package/x/demo/game/parts/renderer.js.map +1 -0
  201. package/x/demo/game/parts/state.d.ts +8 -0
  202. package/x/demo/game/parts/state.js +20 -0
  203. package/x/demo/game/parts/state.js.map +1 -0
  204. package/x/demo/game/parts/virtual-device.d.ts +8 -0
  205. package/x/demo/game/parts/virtual-device.js +11 -0
  206. package/x/demo/game/parts/virtual-device.js.map +1 -0
  207. package/x/demo/main.bundle.js +4 -10
  208. package/x/demo/main.bundle.js.map +1 -1
  209. package/x/demo/main.bundle.min.js +315 -54
  210. package/x/demo/main.bundle.min.js.map +4 -4
  211. package/x/demo/main.css +30 -2
  212. package/x/demo/ui/tact-demo/component.d.ts +4 -0
  213. package/x/demo/ui/tact-demo/component.js +12 -0
  214. package/x/demo/ui/tact-demo/component.js.map +1 -0
  215. package/x/demo/ui/tact-demo/style.css.d.ts +2 -0
  216. package/x/demo/ui/tact-demo/style.css.js +3 -0
  217. package/x/demo/ui/tact-demo/style.css.js.map +1 -0
  218. package/x/demo/ui/theater/styles.css.js +56 -0
  219. package/x/demo/ui/theater/styles.css.js.map +1 -0
  220. package/x/demo/ui/theater/view.d.ts +2 -0
  221. package/x/demo/ui/theater/view.js +42 -0
  222. package/x/demo/ui/theater/view.js.map +1 -0
  223. package/x/demo/ui/theater/virtual/style.css.d.ts +2 -0
  224. package/x/demo/ui/theater/virtual/style.css.js +42 -0
  225. package/x/demo/ui/theater/virtual/style.css.js.map +1 -0
  226. package/x/demo/ui/theater/virtual/view.d.ts +4 -0
  227. package/x/demo/ui/theater/virtual/view.js +19 -0
  228. package/x/demo/ui/theater/virtual/view.js.map +1 -0
  229. package/x/demo/ui/utils/loader.d.ts +1 -0
  230. package/x/demo/ui/utils/loader.js +3 -0
  231. package/x/demo/ui/utils/loader.js.map +1 -0
  232. package/x/index.d.ts +3 -1
  233. package/x/index.html +47 -8
  234. package/x/index.html.js +16 -6
  235. package/x/index.html.js.map +1 -1
  236. package/x/index.js +3 -1
  237. package/x/index.js.map +1 -1
  238. package/x/nubs/components.d.ts +9 -0
  239. package/x/nubs/components.js +11 -0
  240. package/x/nubs/components.js.map +1 -0
  241. package/x/nubs/index.d.ts +4 -0
  242. package/x/nubs/index.js +5 -0
  243. package/x/nubs/index.js.map +1 -0
  244. package/x/nubs/lookpad/component.d.ts +4 -0
  245. package/x/nubs/lookpad/component.js +36 -0
  246. package/x/nubs/lookpad/component.js.map +1 -0
  247. package/x/nubs/stick/component.d.ts +368 -0
  248. package/x/nubs/stick/component.js +101 -0
  249. package/x/nubs/stick/component.js.map +1 -0
  250. package/x/nubs/stick/style.css.d.ts +2 -0
  251. package/x/nubs/stick/style.css.js +69 -0
  252. package/x/nubs/stick/style.css.js.map +1 -0
  253. package/x/nubs/vpad/component.d.ts +368 -0
  254. package/x/nubs/{virtual-gamepad/view.js → vpad/component.js} +20 -11
  255. package/x/nubs/vpad/component.js.map +1 -0
  256. package/x/nubs/vpad/styles.css.d.ts +2 -0
  257. package/x/nubs/vpad/styles.css.js.map +1 -0
  258. package/x/nubs/vpad/utils/gamepad-inputs.js.map +1 -0
  259. package/x/nubs/vpad/utils/prevent-default-touch-shenanigans.js.map +1 -0
  260. package/x/nubs/vpad/utils/touch-tracking.js.map +1 -0
  261. package/x/utils/circular-clamp.d.ts +2 -0
  262. package/x/utils/circular-clamp.js +8 -0
  263. package/x/utils/circular-clamp.js.map +1 -0
  264. package/x/utils/dispensers.d.ts +7 -0
  265. package/x/utils/dispensers.js +16 -0
  266. package/x/utils/dispensers.js.map +1 -0
  267. package/x/utils/split-axis.d.ts +7 -0
  268. package/x/utils/split-axis.js +7 -2
  269. package/x/utils/split-axis.js.map +1 -1
  270. package/s/core/controllers/controller.ts +0 -7
  271. package/s/core/controllers/infra/group.ts +0 -17
  272. package/s/core/controllers/infra/sampler.ts +0 -22
  273. package/s/core/controllers/standard/gamepad.ts +0 -81
  274. package/s/core/controllers/standard/keyboard.ts +0 -53
  275. package/s/core/controllers/standard/stick.ts +0 -30
  276. package/s/core/controllers/utils/modprefix.ts +0 -16
  277. package/s/core/hub/auto-gamepads.ts +0 -8
  278. package/s/core/hub/bindings.ts +0 -21
  279. package/s/core/port/port.ts +0 -34
  280. package/s/core/port/resolution/defaults.ts +0 -30
  281. package/s/core/port/resolution/resolver.ts +0 -77
  282. package/s/core/port/resolution/types.ts +0 -9
  283. package/s/core/port/types.ts +0 -10
  284. package/s/core/port/utils/aggregate_samples_into_map.ts +0 -20
  285. package/s/core/port/utils/wipe_samples_map.ts +0 -8
  286. package/s/nubs/lookpad/utils/listeners.ts +0 -53
  287. package/s/nubs/lookpad/view.ts +0 -32
  288. package/s/nubs/stick/styles.ts +0 -22
  289. package/s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts +0 -27
  290. package/s/nubs/stick/utils/find_closest_point_on_circle.ts +0 -15
  291. package/s/nubs/stick/utils/make_pointer_listeners.ts +0 -50
  292. package/s/nubs/stick/utils/within_radius.ts +0 -6
  293. package/s/nubs/stick/view.ts +0 -50
  294. package/s/nubs/stick-graphic/styles.ts +0 -38
  295. package/s/nubs/stick-graphic/types/basis.ts +0 -5
  296. package/s/nubs/stick-graphic/utils/calculate_basis.ts +0 -19
  297. package/s/nubs/stick-graphic/utils/stick_vector_to_pixels.ts +0 -13
  298. package/s/nubs/stick-graphic/utils/transform.ts +0 -10
  299. package/s/nubs/stick-graphic/view.ts +0 -43
  300. package/x/core/controllers/controller.d.ts +0 -4
  301. package/x/core/controllers/controller.js +0 -3
  302. package/x/core/controllers/controller.js.map +0 -1
  303. package/x/core/controllers/infra/group.d.ts +0 -7
  304. package/x/core/controllers/infra/group.js +0 -13
  305. package/x/core/controllers/infra/group.js.map +0 -1
  306. package/x/core/controllers/infra/sampler.d.ts +0 -8
  307. package/x/core/controllers/infra/sampler.js +0 -17
  308. package/x/core/controllers/infra/sampler.js.map +0 -1
  309. package/x/core/controllers/standard/gamepad.d.ts +0 -10
  310. package/x/core/controllers/standard/gamepad.js +0 -70
  311. package/x/core/controllers/standard/gamepad.js.map +0 -1
  312. package/x/core/controllers/standard/index.js.map +0 -1
  313. package/x/core/controllers/standard/keyboard.d.ts +0 -9
  314. package/x/core/controllers/standard/keyboard.js +0 -42
  315. package/x/core/controllers/standard/keyboard.js.map +0 -1
  316. package/x/core/controllers/standard/pointer.d.ts +0 -11
  317. package/x/core/controllers/standard/pointer.js.map +0 -1
  318. package/x/core/controllers/standard/stick.d.ts +0 -15
  319. package/x/core/controllers/standard/stick.js +0 -27
  320. package/x/core/controllers/standard/stick.js.map +0 -1
  321. package/x/core/controllers/standard/virtual-gamepad.d.ts +0 -7
  322. package/x/core/controllers/standard/virtual-gamepad.js.map +0 -1
  323. package/x/core/controllers/types.js.map +0 -1
  324. package/x/core/controllers/utils/modprefix.d.ts +0 -1
  325. package/x/core/controllers/utils/modprefix.js +0 -16
  326. package/x/core/controllers/utils/modprefix.js.map +0 -1
  327. package/x/core/hub/auto-gamepads.d.ts +0 -2
  328. package/x/core/hub/auto-gamepads.js +0 -6
  329. package/x/core/hub/auto-gamepads.js.map +0 -1
  330. package/x/core/hub/bindings.d.ts +0 -2
  331. package/x/core/hub/bindings.js +0 -19
  332. package/x/core/hub/bindings.js.map +0 -1
  333. package/x/core/port/action.js.map +0 -1
  334. package/x/core/port/port.d.ts +0 -12
  335. package/x/core/port/port.js +0 -25
  336. package/x/core/port/port.js.map +0 -1
  337. package/x/core/port/resolution/defaults.d.ts +0 -4
  338. package/x/core/port/resolution/defaults.js +0 -23
  339. package/x/core/port/resolution/defaults.js.map +0 -1
  340. package/x/core/port/resolution/lens-algo.d.ts +0 -2
  341. package/x/core/port/resolution/lens-algo.js.map +0 -1
  342. package/x/core/port/resolution/resolver.d.ts +0 -9
  343. package/x/core/port/resolution/resolver.js +0 -64
  344. package/x/core/port/resolution/resolver.js.map +0 -1
  345. package/x/core/port/resolution/types.d.ts +0 -6
  346. package/x/core/port/resolution/types.js +0 -2
  347. package/x/core/port/resolution/types.js.map +0 -1
  348. package/x/core/port/types.d.ts +0 -7
  349. package/x/core/port/types.js +0 -2
  350. package/x/core/port/utils/aggregate_samples_into_map.d.ts +0 -3
  351. package/x/core/port/utils/aggregate_samples_into_map.js +0 -11
  352. package/x/core/port/utils/aggregate_samples_into_map.js.map +0 -1
  353. package/x/core/port/utils/is-pressed.js.map +0 -1
  354. package/x/core/port/utils/wipe_samples_map.d.ts +0 -2
  355. package/x/core/port/utils/wipe_samples_map.js +0 -5
  356. package/x/core/port/utils/wipe_samples_map.js.map +0 -1
  357. package/x/nubs/lookpad/utils/listeners.d.ts +0 -19
  358. package/x/nubs/lookpad/utils/listeners.js +0 -37
  359. package/x/nubs/lookpad/utils/listeners.js.map +0 -1
  360. package/x/nubs/lookpad/view.d.ts +0 -1
  361. package/x/nubs/lookpad/view.js +0 -24
  362. package/x/nubs/lookpad/view.js.map +0 -1
  363. package/x/nubs/stick/styles.d.ts +0 -1
  364. package/x/nubs/stick/styles.js +0 -22
  365. package/x/nubs/stick/styles.js.map +0 -1
  366. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.d.ts +0 -3
  367. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js +0 -16
  368. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js.map +0 -1
  369. package/x/nubs/stick/utils/find_closest_point_on_circle.d.ts +0 -2
  370. package/x/nubs/stick/utils/find_closest_point_on_circle.js +0 -6
  371. package/x/nubs/stick/utils/find_closest_point_on_circle.js.map +0 -1
  372. package/x/nubs/stick/utils/make_pointer_listeners.d.ts +0 -16
  373. package/x/nubs/stick/utils/make_pointer_listeners.js +0 -34
  374. package/x/nubs/stick/utils/make_pointer_listeners.js.map +0 -1
  375. package/x/nubs/stick/utils/within_radius.d.ts +0 -2
  376. package/x/nubs/stick/utils/within_radius.js +0 -4
  377. package/x/nubs/stick/utils/within_radius.js.map +0 -1
  378. package/x/nubs/stick/view.d.ts +0 -2
  379. package/x/nubs/stick/view.js +0 -38
  380. package/x/nubs/stick/view.js.map +0 -1
  381. package/x/nubs/stick-graphic/styles.js +0 -38
  382. package/x/nubs/stick-graphic/styles.js.map +0 -1
  383. package/x/nubs/stick-graphic/types/basis.d.ts +0 -4
  384. package/x/nubs/stick-graphic/types/basis.js +0 -2
  385. package/x/nubs/stick-graphic/types/basis.js.map +0 -1
  386. package/x/nubs/stick-graphic/utils/calculate_basis.d.ts +0 -2
  387. package/x/nubs/stick-graphic/utils/calculate_basis.js +0 -10
  388. package/x/nubs/stick-graphic/utils/calculate_basis.js.map +0 -1
  389. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.d.ts +0 -2
  390. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js +0 -7
  391. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js.map +0 -1
  392. package/x/nubs/stick-graphic/utils/transform.d.ts +0 -2
  393. package/x/nubs/stick-graphic/utils/transform.js +0 -7
  394. package/x/nubs/stick-graphic/utils/transform.js.map +0 -1
  395. package/x/nubs/stick-graphic/view.d.ts +0 -3
  396. package/x/nubs/stick-graphic/view.js +0 -30
  397. package/x/nubs/stick-graphic/view.js.map +0 -1
  398. package/x/nubs/virtual-gamepad/styles.css.js.map +0 -1
  399. package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js.map +0 -1
  400. package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js.map +0 -1
  401. package/x/nubs/virtual-gamepad/utils/touch-tracking.js.map +0 -1
  402. package/x/nubs/virtual-gamepad/view.d.ts +0 -2
  403. package/x/nubs/virtual-gamepad/view.js.map +0 -1
  404. /package/s/core/{port/utils → bindings/parts}/is-pressed.ts +0 -0
  405. /package/s/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.ts +0 -0
  406. /package/s/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.ts +0 -0
  407. /package/s/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.ts +0 -0
  408. /package/x/core/{port/utils → bindings/parts}/is-pressed.d.ts +0 -0
  409. /package/x/core/{port/utils → bindings/parts}/is-pressed.js +0 -0
  410. /package/x/core/{controllers → devices}/types.js +0 -0
  411. /package/x/{nubs/virtual-gamepad/styles.css.d.ts → deck/views/deck-overlay/style.css.d.ts} +0 -0
  412. /package/x/{nubs/stick-graphic/styles.d.ts → demo/ui/theater/styles.css.d.ts} +0 -0
  413. /package/x/nubs/{virtual-gamepad → vpad}/styles.css.js +0 -0
  414. /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.d.ts +0 -0
  415. /package/x/nubs/{virtual-gamepad → vpad}/utils/gamepad-inputs.js +0 -0
  416. /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.d.ts +0 -0
  417. /package/x/nubs/{virtual-gamepad → vpad}/utils/prevent-default-touch-shenanigans.js +0 -0
  418. /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.d.ts +0 -0
  419. /package/x/nubs/{virtual-gamepad → vpad}/utils/touch-tracking.js +0 -0
@@ -1,32 +1,26 @@
1
1
 
2
- import {ev} from "@e280/stz"
3
2
  import {Vec2} from "@benev/math"
4
- import {modprefix} from "../utils/modprefix.js"
3
+ import {disposer, ev} from "@e280/stz"
4
+ import {SamplerDevice} from "../infra/sampler.js"
5
5
  import {splitAxis} from "../../../utils/split-axis.js"
6
- import {SamplerController} from "../infra/sampler.js"
7
6
 
8
- export class PointerController extends SamplerController {
7
+ export class PointerDevice extends SamplerDevice {
9
8
  client = new Vec2(0, 0)
10
9
  movement = new Vec2(0, 0)
11
- dispose: () => void
10
+ dispose = disposer()
12
11
 
13
12
  constructor(target: EventTarget = window) {
14
13
  super()
15
14
 
16
- const dispatch = (event: PointerEvent | WheelEvent, code: string, value: number) => {
17
- this.setSample(code, value)
18
- this.setSample(modprefix(event, code), value)
19
- }
20
-
21
- this.dispose = ev(target, {
15
+ this.dispose.schedule(ev(target, {
22
16
  pointerdown: (event: PointerEvent) => {
23
- const code = PointerController.buttonCode(event)
24
- dispatch(event, code, 1)
17
+ const code = PointerDevice.buttonCode(event)
18
+ this.setSample(code, 1)
25
19
  },
26
20
 
27
21
  pointerup: (event: PointerEvent) => {
28
- const code = PointerController.buttonCode(event)
29
- dispatch(event, code, 0)
22
+ const code = PointerDevice.buttonCode(event)
23
+ this.setSample(code, 0)
30
24
  },
31
25
 
32
26
  pointermove: (event: PointerEvent) => {
@@ -37,10 +31,10 @@ export class PointerController extends SamplerController {
37
31
  },
38
32
 
39
33
  wheel: (event: WheelEvent) => {
40
- for (const [code, value] of PointerController.wheelCodes(event))
41
- dispatch(event, code, value)
34
+ for (const [code, value] of PointerDevice.wheelCodes(event))
35
+ this.setSample(code, value)
42
36
  },
43
- })
37
+ }))
44
38
  }
45
39
 
46
40
  static buttonCode(event: PointerEvent) {
@@ -70,7 +64,12 @@ export class PointerController extends SamplerController {
70
64
  return movements
71
65
  }
72
66
 
73
- takeSamples() {
67
+ samples() {
68
+ this.#specialPreProcessing()
69
+ return super.samples()
70
+ }
71
+
72
+ #specialPreProcessing() {
74
73
  const [x, y] = this.movement
75
74
  const [left, right] = splitAxis(x)
76
75
  const [down, up] = splitAxis(y)
@@ -89,7 +88,6 @@ export class PointerController extends SamplerController {
89
88
  }
90
89
 
91
90
  this.movement.set_(0, 0)
92
- return super.takeSamples()
93
91
  }
94
92
  }
95
93
 
@@ -0,0 +1,20 @@
1
+
2
+ import {VpadDevice} from "./vpad.js"
3
+ import {PointerDevice} from "./pointer.js"
4
+ import {KeyboardDevice} from "./keyboard.js"
5
+ import {GroupDevice} from "../infra/group.js"
6
+
7
+ export class PrimaryDevice extends GroupDevice {
8
+ keyboard = new KeyboardDevice()
9
+ pointer = new PointerDevice()
10
+ vpad = new VpadDevice()
11
+
12
+ constructor() {
13
+ super()
14
+ this.devices
15
+ .add(this.keyboard)
16
+ .add(this.pointer)
17
+ .add(this.vpad)
18
+ }
19
+ }
20
+
@@ -0,0 +1,27 @@
1
+
2
+ import {Vec2} from "@benev/math"
3
+ import {derived, signal} from "@e280/strata"
4
+ import {Sample} from "../types.js"
5
+ import {Device} from "../device.js"
6
+ import {splitVector} from "../../../utils/split-axis.js"
7
+
8
+ export class StickDevice extends Device {
9
+ $vector = signal(Vec2.zero())
10
+ $breakdown = derived(() => splitVector(this.$vector.get()))
11
+
12
+ constructor(public channel = "stick") {
13
+ super()
14
+ }
15
+
16
+ samples() {
17
+ const {channel} = this
18
+ const {up, down, left, right} = this.$breakdown.get()
19
+ return [
20
+ [`${channel}.up`, up],
21
+ [`${channel}.down`, down],
22
+ [`${channel}.left`, left],
23
+ [`${channel}.right`, right],
24
+ ] as Sample[]
25
+ }
26
+ }
27
+
@@ -1,25 +1,25 @@
1
1
 
2
- import {StickController} from "./stick.js"
3
- import {SamplerController} from "../infra/sampler.js"
2
+ import {StickDevice} from "./stick.js"
3
+ import {SamplerDevice} from "../infra/sampler.js"
4
4
 
5
- export class VirtualGamepadController extends SamplerController {
6
- stickLeft = new StickController()
7
- stickRight = new StickController()
5
+ export class VpadDevice extends SamplerDevice {
6
+ stickLeft = new StickDevice()
7
+ stickRight = new StickDevice()
8
8
 
9
- takeSamples() {
10
- const left = this.stickLeft.breakdown()
9
+ samples() {
10
+ const left = this.stickLeft.$breakdown()
11
11
  this.setSample("gamepad.stick.left.up", left.up)
12
12
  this.setSample("gamepad.stick.left.down", left.down)
13
13
  this.setSample("gamepad.stick.left.left", left.left)
14
14
  this.setSample("gamepad.stick.left.right", left.right)
15
15
 
16
- const right = this.stickRight.breakdown()
16
+ const right = this.stickRight.$breakdown()
17
17
  this.setSample("gamepad.stick.right.up", right.up)
18
18
  this.setSample("gamepad.stick.right.down", right.down)
19
19
  this.setSample("gamepad.stick.right.left", right.left)
20
20
  this.setSample("gamepad.stick.right.right", right.right)
21
21
 
22
- return super.takeSamples()
22
+ return super.samples()
23
23
  }
24
24
  }
25
25
 
@@ -1,4 +1,3 @@
1
1
 
2
2
  export type Sample = [code: string, value: number]
3
- export type SampleMap = Map<string, number>
4
3
 
package/s/core/hub/hub.ts CHANGED
@@ -1,48 +1,40 @@
1
1
 
2
- import {SetG} from "@e280/stz"
3
2
  import {Scalar} from "@benev/math"
4
- import {Port} from "../port/port.js"
5
- import {hubBindings} from "./bindings.js"
6
- import {Controller} from "../controllers/controller.js"
7
- import {hubMode, HubBindings} from "../bindings/types.js"
3
+ import {debounce, MapG, sub} from "@e280/stz"
4
+ import {Port} from "./port.js"
5
+ import {Device} from "../devices/device.js"
6
+ import {Bindings} from "../bindings/types.js"
7
+ import {Connected} from "./parts/connected.js"
8
+ import {MetaBindings, metaMode} from "./types.js"
9
+ import {makeMetaBindings} from "./meta-bindings.js"
8
10
 
9
- export class Hub<B extends HubBindings> {
10
- static readonly mode = hubMode
11
- static readonly bindings = hubBindings
11
+ export class Hub<B extends Bindings, MB extends MetaBindings = any> {
12
12
 
13
- readonly controllers = new SetG<Controller>()
13
+ /** event fires whenever a device changes ports. */
14
+ readonly on = sub()
14
15
 
15
- constructor(public readonly ports: Port<B>[]) {
16
- for (const port of ports) {
17
- port.modes.add(Hub.mode)
18
- }
19
- }
16
+ /** all devices known to this hub */
17
+ #connected = new MapG<Device, Connected>()
20
18
 
21
- *[Symbol.iterator]() {
22
- yield* this.ports.values()
23
- }
19
+ metaPort: Port<MB>
24
20
 
25
- *entries() {
26
- yield* this.ports.entries()
27
- }
21
+ constructor(
28
22
 
29
- /** poll all the ports, and actuate hub bindings for shimmying */
30
- poll(now: number = Date.now()) {
31
- return this.ports.map(port => {
32
- const actions = port.poll(now)
33
- const fn = (delta: 1 | -1) => {
34
- const controller = this.controllerByPort(port)
35
- if (controller) this.shimmy(controller, delta)
36
- }
37
- if (actions[hubMode].shimmyNext.down) fn(1)
38
- if (actions[hubMode].shimmyPrevious.down) fn(-1)
39
- return actions
40
- })
23
+ /** available ports that devices can be assigned to. */
24
+ public readonly ports: Port<B>[],
25
+
26
+ /** special bindings for devices to shimmy between ports. */
27
+ public metaBindings = makeMetaBindings() as MB,
28
+ ) {
29
+
30
+ this.metaPort = new Port<MB>(metaBindings)
41
31
  }
42
32
 
43
- /** check if a port has a known switchboard controller assigned */
44
- isPlugged(port: Port<B>) {
45
- return !!this.controllerByPort(port)
33
+ /** poll every device, providing actions for each port, and internally handling meta actions. */
34
+ poll(now = Date.now()) {
35
+ this.#resolveMetaPort(now)
36
+ this.#actuateMetaActions(now)
37
+ return this.#resolvePorts(now)
46
38
  }
47
39
 
48
40
  portByIndex(index: number) {
@@ -51,52 +43,76 @@ export class Hub<B extends HubBindings> {
51
43
  return port
52
44
  }
53
45
 
54
- portByController(controller: Controller) {
46
+ portByDevice(device: Device) {
55
47
  for (const port of this.ports) {
56
- if (port.controllers.has(controller))
48
+ if (port.devices.has(device))
57
49
  return port
58
50
  }
59
51
  }
60
52
 
61
- controllerByPort(port: Port<B>) {
62
- for (const controller of this.controllers) {
63
- if (port.controllers.has(controller))
64
- return controller
65
- }
66
- }
67
-
68
- /** move a player's controller to the next or previous port */
69
- shimmy(controller: Controller, indexDelta: 1 | -1) {
70
- const oldIndex = this.ports.findIndex(port => port.controllers.has(controller))
53
+ /** move a player's device to the next or previous port */
54
+ shimmy(device: Device, indexDelta: 1 | -1) {
55
+ const oldIndex = this.ports.findIndex(port => port.devices.has(device))
71
56
  const maxIndex = Math.max(0, this.ports.length - 1)
72
57
  const newIndex = Scalar.clamp(oldIndex + indexDelta, 0, maxIndex)
73
58
  const port = this.portByIndex(newIndex)
74
- this.plug(controller, port)
59
+ this.reassign(device, port)
75
60
  return port
76
61
  }
77
62
 
78
- /** plug a controller into a port */
79
- plug = (controller: Controller, port: Port<B> = this.getLonelyPort()) => {
80
- this.unplug(controller)
81
- this.controllers.add(controller)
82
- port.controllers.add(controller)
83
- return () => this.unplug(controller)
63
+ reassign(device: Device, port = this.getLonelyPort()) {
64
+ this.ports.forEach(port => port.devices.delete(device))
65
+ port.devices.add(device)
66
+ this.#dispatchChange()
67
+ }
68
+
69
+ /** unplug a device */
70
+ unplug(device: Device) {
71
+ this.ports.forEach(port => port.devices.delete(device))
72
+ this.#connected.delete(device)
73
+ this.#dispatchChange()
84
74
  }
85
75
 
86
- /** unplug a controller */
87
- unplug(controller: Controller) {
88
- this.ports.forEach(port => port.controllers.delete(controller))
89
- this.controllers.delete(controller)
76
+ /** plug a device into a port */
77
+ plug = (device: Device, port = this.getLonelyPort()) => {
78
+ this.unplug(device)
79
+ this.#connected.set(device, new Connected(device, this.metaBindings))
80
+ port.devices.add(device)
81
+ this.#dispatchChange()
82
+ return () => this.unplug(device)
90
83
  }
91
84
 
92
85
  /** returns an unplugged port (otherwise the last one) */
93
86
  getLonelyPort() {
87
+ let smallest = this.ports.at(0)!
94
88
  for (const port of this.ports) {
95
- if (!this.controllerByPort(port))
96
- return port
89
+ if (port.devices.size < smallest.devices.size)
90
+ smallest = port
91
+ }
92
+ return smallest
93
+ }
94
+
95
+ #dispatchChange = debounce(0, () => this.on.publish())
96
+
97
+ #resolveMetaPort(now: number) {
98
+ this.metaPort.devices.clear()
99
+ this.metaPort.devices.adds(...this.#connected.keys())
100
+ this.metaPort.resolve(now)
101
+ }
102
+
103
+ #actuateMetaActions(now: number) {
104
+ for (const connected of this.#connected.values()) {
105
+ const actions = connected.metaPort.resolve(now)
106
+ if (actions[metaMode].shimmyNext.down) this.shimmy(connected.device, 1)
107
+ if (actions[metaMode].shimmyPrevious.down) this.shimmy(connected.device, -1)
97
108
  }
98
- const index = Math.max(0, this.ports.length - 1)
99
- return this.portByIndex(index)
109
+ }
110
+
111
+ #resolvePorts(now: number) {
112
+ return this.ports.map(port => {
113
+ port.resolve(now)
114
+ return port
115
+ })
100
116
  }
101
117
  }
102
118
 
@@ -0,0 +1,23 @@
1
+
2
+ import {MetaBindings, metaMode} from "./types.js"
3
+
4
+ export const makeMetaBindings = (): MetaBindings => ({
5
+ [metaMode]: {
6
+ revealOverlay: ["or",
7
+ "Backslash",
8
+ "gamepad.beta",
9
+ "gamepad.gamma",
10
+ ],
11
+ shimmyNext: ["or",
12
+ "BracketRight",
13
+ ["and", ["or", "gamepad.beta", "gamepad.gamma"], "gamepad.right"],
14
+ ["and", ["or", "gamepad.beta", "gamepad.gamma"], "gamepad.bumper.right"],
15
+ ],
16
+ shimmyPrevious: ["or",
17
+ "BracketLeft",
18
+ ["and", ["or", "gamepad.beta", "gamepad.gamma"], "gamepad.left"],
19
+ ["and", ["or", "gamepad.beta", "gamepad.gamma"], "gamepad.bumper.left"],
20
+ ],
21
+ },
22
+ })
23
+
@@ -0,0 +1,15 @@
1
+
2
+ import {Port} from "../port.js"
3
+ import {MetaBindings} from "../types.js"
4
+ import {Device} from "../../devices/device.js"
5
+ import {makeMetaBindings} from "../meta-bindings.js"
6
+
7
+ export class Connected {
8
+ metaPort: Port<MetaBindings>
9
+
10
+ constructor(public device: Device, metaB = makeMetaBindings()) {
11
+ this.metaPort = new Port(metaB)
12
+ this.metaPort.devices.add(device)
13
+ }
14
+ }
15
+
@@ -0,0 +1,26 @@
1
+
2
+ import {SetG} from "@e280/stz"
3
+ import {Bindings} from "../bindings/types.js"
4
+ import {Resolver} from "../bindings/resolver.js"
5
+ import {SampleMap} from "../bindings/sample-map.js"
6
+ import {GroupDevice} from "../devices/infra/group.js"
7
+
8
+ export class Port<B extends Bindings> extends Resolver<B> {
9
+ #group = new GroupDevice()
10
+
11
+ readonly devices = this.#group.devices
12
+ readonly modes = new SetG<keyof B>()
13
+
14
+ constructor(bindings: B) {
15
+ super(bindings)
16
+
17
+ // start with all modes enabled by default
18
+ this.modes.adds(...Object.keys(bindings))
19
+ }
20
+
21
+ resolve(now = Date.now()) {
22
+ const sampleMap = new SampleMap(this.#group.samples())
23
+ return super.resolve(now, this.modes, sampleMap)
24
+ }
25
+ }
26
+
@@ -0,0 +1,13 @@
1
+
2
+ import {AsBindings, Atom} from "../bindings/types.js"
3
+
4
+ export const metaMode = "meta" as const
5
+
6
+ export type MetaBindings = AsBindings<{
7
+ [metaMode]: {
8
+ revealOverlay: Atom
9
+ shimmyNext: Atom
10
+ shimmyPrevious: Atom
11
+ }
12
+ }>
13
+
package/s/core/index.ts CHANGED
@@ -1,19 +1,19 @@
1
1
 
2
+ export * from "./bindings/action.js"
3
+ export * from "./bindings/resolver.js"
4
+ export * from "./bindings/sample-map.js"
2
5
  export * from "./bindings/types.js"
3
6
 
4
- export * as controllers from "./controllers/standard/index.js"
5
- export * from "./controllers/infra/group.js"
6
- export * from "./controllers/infra/sampler.js"
7
- export * from "./controllers/standard/index.js"
8
- export * from "./controllers/utils/modprefix.js"
9
- export * from "./controllers/controller.js"
10
- export * from "./controllers/types.js"
7
+ export * from "./devices/infra/group.js"
8
+ export * from "./devices/infra/sampler.js"
9
+ export * from "./devices/standard/index.js"
10
+ export * as devices from "./devices/standard/index.js"
11
+ export * from "./devices/auto-gamepads.js"
12
+ export * from "./devices/device.js"
13
+ export * from "./devices/types.js"
11
14
 
12
- export * from "./hub/auto-gamepads.js"
13
- export * from "./hub/bindings.js"
14
15
  export * from "./hub/hub.js"
15
-
16
- export * from "./port/action.js"
17
- export * from "./port/port.js"
18
- export * from "./port/types.js"
16
+ export * from "./hub/meta-bindings.js"
17
+ export * from "./hub/port.js"
18
+ export * from "./hub/types.js"
19
19
 
@@ -1,10 +1,11 @@
1
1
 
2
2
  import {Hub} from "../hub/hub.js"
3
- import {Port} from "../port/port.js"
3
+ import {Port} from "../hub/port.js"
4
+ import {Device} from "../devices/device.js"
4
5
  import {asBindings} from "../bindings/types.js"
5
- import {hubBindings} from "../hub/bindings.js"
6
- import {Controller} from "../controllers/controller.js"
7
- import {SamplerController} from "../controllers/infra/sampler.js"
6
+ import {Resolver} from "../bindings/resolver.js"
7
+ import {SampleMap} from "../bindings/sample-map.js"
8
+ import {SamplerDevice} from "../devices/infra/sampler.js"
8
9
 
9
10
  export class TestTime {
10
11
  frame = 0
@@ -17,34 +18,38 @@ export class TestTime {
17
18
  export function testBindings() {
18
19
  return asBindings({
19
20
  basic: {
20
- jump: [{lenses: [{code: "Space"}]}],
21
- shoot: [{lenses: [{code: "pointer.button.left"}]}],
21
+ jump: "Space",
22
+ shoot: "pointer.button.left",
22
23
  },
23
24
  })
24
25
  }
25
26
 
26
- export function testConnect<C extends Controller>(switchboard: Hub<any>, controller: C) {
27
- switchboard.plug(controller)
28
- return controller
27
+ export function testPlug<C extends Device>(hub: Hub<any>, device: C) {
28
+ hub.plug(device)
29
+ return device
29
30
  }
30
31
 
31
32
  export function testSetupAlpha() {
32
33
  const time = new TestTime()
33
- const controller = new SamplerController()
34
- const port = new Port(testBindings())
35
- port.modes.add("basic")
36
- port.controllers.add(controller)
37
- return {controller, port, time}
34
+ const device = new SamplerDevice()
35
+ const resolver = new Resolver(testBindings())
36
+ const modes = new Set(Object.keys(resolver.bindings))
37
+ const resolve = () => resolver.resolve(
38
+ time.now,
39
+ modes as any,
40
+ new SampleMap(device.samples())
41
+ )
42
+ return {device, resolver, resolve, time}
38
43
  }
39
44
 
40
45
  export function testSetupBravo() {
41
46
  const time = new TestTime()
42
47
  const port = () => {
43
- const port = new Port(hubBindings(testBindings()))
44
- port.modes.adds(Hub.mode, "basic")
48
+ const port = new Port(testBindings())
49
+ port.modes.adds("basic")
45
50
  return port
46
51
  }
47
52
  const hub = new Hub([port(), port(), port(), port()])
48
- return {hub: hub, time}
53
+ return {hub, time}
49
54
  }
50
55
 
package/s/deck/deck.ts ADDED
@@ -0,0 +1,77 @@
1
+
2
+ import {Kv} from "@e280/kv"
3
+ import {disposer, ob, range} from "@e280/stz"
4
+
5
+ import {Db} from "./parts/db.js"
6
+ import {Hub} from "../core/hub/hub.js"
7
+ import {Port} from "../core/hub/port.js"
8
+ import {Bindings} from "../core/bindings/types.js"
9
+ import {mergeBindings} from "./parts/merge-bindings.js"
10
+ import {MetaBindings, metaMode} from "../core/hub/types.js"
11
+ import {autoGamepads} from "../core/devices/auto-gamepads.js"
12
+ import {DeckOverlay} from "./views/deck-overlay/component.js"
13
+ import {makeMetaBindings} from "../core/hub/meta-bindings.js"
14
+ import {DeviceSkins} from "./parts/device-skins/device-skin.js"
15
+ import {OverlayVisibility} from "./parts/overlay-visibility.js"
16
+ import {PrimaryDevice} from "../core/devices/standard/primary.js"
17
+ import { dom } from "@e280/sly"
18
+
19
+ export type DeckOptions<B extends Bindings, MB extends MetaBindings = any> = {
20
+ kv: Kv
21
+ bindings: B
22
+ portCount: number
23
+ metaBindings?: MB
24
+ }
25
+
26
+ export class Deck<B extends Bindings, MB extends MetaBindings = any> {
27
+ static async load<B extends Bindings, MB extends MetaBindings = any>(options: DeckOptions<B, MB>) {
28
+ const db = await Db.load(options.kv.store("catalog"))
29
+
30
+ const ports = range(options.portCount)
31
+ .map(index => db.$catalog().getProfileForPort(index))
32
+ .map(profile => mergeBindings(options.bindings, profile?.bindings))
33
+ .map(bindings => new Port<B>(bindings as B))
34
+
35
+ const hub = new Hub<B>(
36
+ ports,
37
+ db.$catalog().metaBindings
38
+ ?? options.metaBindings
39
+ ?? makeMetaBindings(),
40
+ )
41
+
42
+ return new this(hub, db)
43
+ }
44
+
45
+ dispose = disposer()
46
+ deviceSkins = new DeviceSkins()
47
+ overlayVisibility: OverlayVisibility
48
+ primaryDevice = new PrimaryDevice()
49
+
50
+ views = ob({DeckOverlay}).map(fn => fn(this))
51
+ components = ob(this.views).map(v => v.component().props(_c => []))
52
+
53
+ registerComponents() {
54
+ dom.register(this.components)
55
+ }
56
+
57
+ constructor(
58
+ public hub: Hub<B, MB>,
59
+ public db: Db,
60
+ ) {
61
+
62
+ this.overlayVisibility = new OverlayVisibility(hub, this.deviceSkins)
63
+
64
+ // meta reveal overlay
65
+ this.dispose.schedule(
66
+ hub.metaPort.actions[metaMode].revealOverlay.on(action => {
67
+ if (action.pressed)
68
+ this.overlayVisibility.bump()
69
+ })
70
+ )
71
+ }
72
+
73
+ get catalog() {
74
+ return this.db.$catalog()
75
+ }
76
+ }
77
+
@@ -0,0 +1,14 @@
1
+
2
+ export * from "./parts/device-skins/device-icons.js"
3
+ export * from "./parts/device-skins/device-skin.js"
4
+ export * from "./parts/catalog.js"
5
+ export * from "./parts/db.js"
6
+ export * from "./parts/local-storage-kv.js"
7
+ export * from "./parts/merge-bindings.js"
8
+ export * from "./parts/overlay-visibility.js"
9
+
10
+ export * from "./views/deck-overlay/component.js"
11
+ export * from "./views/deck-overlay/style.css.js"
12
+
13
+ export * from "./deck.js"
14
+