@benev/tact 0.1.0-3 → 0.1.0-5

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