feat(input): native gamepad + touch + mouse-position hardware bindings (#51)
Wire the macOS platform side of the #50 device layer, feeding the same state buffers the read APIs consume — no API changes, purely OS glue. - mouse: cocoa.ll reads the live cursor via mouseLocationOutsideOfEventStream, converted to framebuffer pixels and y-flipped, so windowed games get Input.mouse_x/y without injection (W_mx/W_my were never written before). - gamepad: win_pad polls GCController.controllers each frame, packing extended- gamepad buttons (SDL_GameControllerButton order) and thumbsticks (16.16 fixed, Y negated for SDL convention) into in_pad_*. Windowed builds now load GameController via -needed_framework (its classes are reached by name, so a plain -framework link dead-strips it); DCE'd in headless builds. - touch: the view's NSTouch phase handlers snapshot the touching set into in_touch_* (normalizedPosition -> framebuffer pixels). Web platform.js gains zero-fill stubs for win_held/mouse/pad/touch so a windowed wasm build resolves the device-layer imports. New test asserts the windowed link loads GameController. Reseeded; full + selfhost suites green (79 + 29). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
53bb441f23
commit
d6ca320269
10 changed files with 15159 additions and 14652 deletions
|
|
@ -239,6 +239,27 @@ function input_device_commit(k: int, replaying: int) -> void {
|
|||
let mbuf = words(4) # [x, y, button-mask, wheel]
|
||||
win_mouse(mbuf)
|
||||
in_mx = mbuf[0]; in_my = mbuf[1]; in_mbtn = mbuf[2]; in_wheel = mbuf[3]
|
||||
# #51 — feed the platform gamepad + touch state into the same buffers the
|
||||
# read APIs use. Each is windowed-only glue (win_pad / win_touch are DCE'd
|
||||
# in a headless build); on hardware they overwrite the injected state.
|
||||
let pbuf = words(IN_PADS * 6) # [conn, mask, lx, ly, rx, ry]/pad
|
||||
win_pad(pbuf)
|
||||
var pi = 0
|
||||
while pi < IN_PADS {
|
||||
let pb = pi * 6
|
||||
input_set_pad(pi, pbuf[pb] != 0, pbuf[pb + 1],
|
||||
as_fixed(pbuf[pb + 2]), as_fixed(pbuf[pb + 3]),
|
||||
as_fixed(pbuf[pb + 4]), as_fixed(pbuf[pb + 5]))
|
||||
pi = pi + 1
|
||||
}
|
||||
let tbuf = words(IN_TOUCH * 3) # [active, x, y]/point
|
||||
win_touch(tbuf)
|
||||
var ti = 0
|
||||
while ti < IN_TOUCH {
|
||||
let tb = ti * 3
|
||||
input_set_touch(ti, tbuf[tb + 1], tbuf[tb + 2], tbuf[tb] != 0)
|
||||
ti = ti + 1
|
||||
}
|
||||
} else {
|
||||
in_set_clear(in_dev)
|
||||
if k > 0 { in_bit_set(in_dev, k, true) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue