fix(input): #87 key_pressed/key_released edges never fired under the frame loop
Since #83 the loop commits the device layer once per frame (input_drive), but a game that ALSO called Input.poll by hand committed a second time in the same frame; input_device_commit copies in_held into in_prev at the top of every commit, so the second commit left in_prev == in_held and the edges (held && !prev) could never see a transition. Fix: an in_have_frame_driver flag. The loop's input_drive sets it; a manual Input.poll under the loop then becomes a no-op returning the frame's key instead of re-committing. An entry-driven harness has no loop, so the flag stays false and each Input.poll commits a frame as before (the #7/#50 record/replay + device tests are unchanged). Frame loop now calls input_drive. Example input_edge (press edge on the down frame, release edge on the up frame). Full suite 110/0, goldens byte-identical, fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
bdf1a97550
commit
0497029dae
6 changed files with 64 additions and 12 deletions
|
|
@ -473,8 +473,8 @@ function emit_game_main() -> void {
|
|||
# mouse and gamepad state). Its return is the frame key, so Input.key still works
|
||||
# and the game no longer has to call Input.poll by hand. A game that uses no Input
|
||||
# runtime keeps the plain rt_poll path, byte-identical.
|
||||
if g_uses_input and (find_fn("input_poll") != null) {
|
||||
let k = emit_bind("call i32 @fn_input_poll()")
|
||||
if g_uses_input and (find_fn("input_drive") != null) {
|
||||
let k = emit_bind("call i32 @fn_input_drive()")
|
||||
emit(" store i32 "); emit(k); emit(", ptr @L_key\n")
|
||||
} else {
|
||||
if (find_fn("rt_poll") != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue