# Keys held through a focus loss (runtime/web/input_web.c release_all, key_down): the focus loss lets every
# held key go and nothing sticks, but a key still down is pressed again by its next autorepeat.  The same
# after a Command press.  A key pressed with Command held never reaches the game, not even by its repeats,
# and one released while the focus was away stays up.
# @in+0x2d4 throttle, @in+0x2c8 steer (+ = left); [[[0x8900ac]+4]+0x30] is the player's input controller.
#   node web/tools/input-suite.mjs <outdir> kb_focus_regain        (the page's input layer)
#   node web/tools/run-suite.mjs --script kb_focus_regain.txt --marker kb_focus_regain_end
# Good: every expect passes.  Before the fix the three "pressed again" expects fail.
0     nstapuntil RETURN MC_Background.fng 120 4000
+200  nstap RETURN                                  # "create a profile?" -> No
+0    waitfng GarageMain.fng 3000
+400  nstapuntil RETURN UI_QRModeSelect.fng 150 3000
+200  nstapuntil RETURN UI_QRTrackSelect.fng 150 1500
+200  nstapuntil RETURN UI_QRModeOptions.fng 150 1500
+200  nstapuntil RETURN UI_QRCarSelect.fng 150 1500
+200  nstapuntil RETURN PC_Loading.fng 150 1500
+0    waitmem 0x8654a4 6 3000
+700  log --- hold Up (throttle) and Left ---
+0    nsdown UP
+0    nsdown LEFT
+240  expect f:[[[0x8900ac]+4]+0x30]+0x2d4 > 0.5
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2c8 > 0.5
+0    log --- focus lost while both keys are held: both go up ---
+0    nsfocus out
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2c8 < 0.5
+180  nsfocus in
+180  log --- focus back, the keys still down: nothing held until they repeat ---
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2c8 < 0.5
+0    nsrepeat UP 3
+0    nsrepeat LEFT 3
+10   log --- their autorepeats press them again ---
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2d4 > 0.5
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2c8 > 0.5
+0    nsup UP
+0    nsup LEFT
+30   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    expect f:[[[0x8900ac]+4]+0x30]+0x2c8 < 0.5
+0    log --- Up held through a Command press: its first repeat after Command presses it again ---
+0    nsdown UP
+60   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 > 0.5
+0    nsdown LCMD
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    nsrepeat UP 2                                 # they carry Command: the browser's
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    nsup LCMD
+0    nsrepeat UP 3
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 > 0.5
+0    nsup UP
+30   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    log --- Up pressed with Command held: its repeats after Command change nothing ---
+0    nsdown LCMD
+4    nsdown UP
+10   nsup LCMD
+0    nsrepeat UP 3
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 < 0.5
+0    nsup UP
+30   log --- Left released while the focus was away: a stray repeat changes nothing ---
+0    nsdown LEFT
+60   expect f:[[[0x8900ac]+4]+0x30]+0x2c8 > 0.5
+0    nsfocus out
+10   nsup LEFT
+180  nsfocus in
+10   nsrepeat LEFT 2
+10   expect f:[[[0x8900ac]+4]+0x30]+0x2c8 < 0.5
+0    log --- and a fresh press still works ---
+0    nsdown UP
+60   expect f:[[[0x8900ac]+4]+0x30]+0x2d4 > 0.5
+0    nsup UP
+30   log kb_focus_regain_end
+10   quit
