tsvm new api: con.setFullscreen

This commit is contained in:
minjaesong
2026-06-20 00:13:55 +09:00
parent eb481b2888
commit 8a046776ad
9 changed files with 195 additions and 46 deletions

View File

@@ -195,6 +195,13 @@ let dec = null
let stage = "open" // breadcrumb for the error log
try {
// Fullscreen raw-keyboard app: one declaration. Under vtmgr it grabs the
// cooked-input feed (so keystrokes typed at this player don't flood the
// shell on exit), and con.poll_keys() in readInput() auto-ignores the
// keyboard while this console is backgrounded; on bare metal it is a no-op.
// Released in the finally below.
con.setFullscreen(true)
dec = mediadec.open(fullPath, decOpts)
const info = dec.info
@@ -265,8 +272,10 @@ try {
// triggered so a held key fires once. Quit + ASCII/colour toggles work even
// without -i; the rest of the transport is interactive-only.
function readInput() {
sys.poke(-40, 1)
const key = sys.peek(-41)
// con.poll_keys() returns the raw key snapshot, but yields all-zeros
// while this console is backgrounded under vtmgr, so a backgrounded
// player never reacts to the foreground console's typing.
const key = con.poll_keys()[0]
if (key == K.BACKSPACE) { quit = true; return }
if (key && key !== lastKey) {
if (key == K.A) { if (aa) toggleAscii() } // inert when aa.mjs is absent
@@ -350,6 +359,7 @@ catch (e) {
errorlevel = 1
}
finally {
con.setFullscreen(false)
if (dec) dec.close()
if (aa && aaCtx) aa.close(aaCtx)
if (errorlevel === 0) con.clear()

View File

@@ -486,6 +486,11 @@ audio.setSampleBank(0) // restore the bank window to bank 0 after probing
// ── Console setup ───────────────────────────────────────────────────────────
con.curs_set(0)
con.clear()
// Fullscreen raw-keyboard app: one declaration. Under vtmgr it grabs the
// dispatcher's cooked-input feed (so the visualiser's keystrokes don't flood the
// shell on exit), and con.poll_keys() below auto-ignores input while this console
// is backgrounded; a no-op on bare metal. Released in the finally.
con.setFullscreen(true)
function mvprn(row, col, ch) { con.mvaddch(row, col, ch) }
function mvtext(row, col, s) { con.move(row, col); print(s) }
@@ -1255,8 +1260,10 @@ try {
// Keyboard polling (mirrors playtad). Backspace exits; Up/Down switch
// to the previous/next song (wrapping) when the file holds more than
// one song. lastNavKey debounces so each press switches exactly once.
sys.poke(-40, 1)
const rawKey = sys.peek(-41)
// con.poll_keys() returns the raw key snapshot, but all-zeros while this
// console is backgrounded under vtmgr, so we never act on another
// console's keys.
const rawKey = con.poll_keys()[0]
if (rawKey === 67) stopReq = true
else if (rawKey !== lastNavKey && song.numSongs > 1) {
if (rawKey === 19) // up = previous song
@@ -1307,6 +1314,7 @@ catch (e) {
errorlevel = 1
}
finally {
con.setFullscreen(false)
audio.stop(PLAYHEAD)
con.move(ROW_BOT_BORDER + 1, 1)
con.curs_set(1)

View File

@@ -6837,6 +6837,12 @@ let exitFlag = false
let pendingExternalDraw = false
while (!exitFlag) {
// Fullscreen app: (re)assert the raw-keyboard grab each frame so cooked chars
// never pile into this pane's ring (they'd flood the shell on exit), and so
// it is re-established after a sub-editor returns. input.withEvent below is
// auto-guarded by con.isActiveConsole(), so a backgrounded editor sees no
// input. Both are no-ops on bare metal. Released in the teardown.
con.setFullscreen(true)
input.withEvent(event => {
if (dispatchMouseEvent(event)) return
if (event[0] !== "key_down") return
@@ -6955,6 +6961,7 @@ while (!exitFlag) {
}
audio.stop(PLAYHEAD)
con.setFullscreen(false)
resetAudioDevice()
sys.free(SCRATCH_PTR)
font.resetLowRom()

View File

@@ -1115,6 +1115,12 @@ let firstRunLatch = true
let pendingPostExecDrain = false
while (!exit) {
// Fullscreen app: (re)assert the raw-keyboard grab each frame so cooked chars
// never pile into this pane's ring (they'd flood the shell on exit), and so
// it is re-established after a launched program returns. input.withEvent
// below is auto-guarded by con.isActiveConsole(); both are no-ops on bare
// metal. Released after the loop.
con.setFullscreen(true)
input.withEvent(event => {
if (dispatchMouseEvent(event)) {
@@ -1160,6 +1166,7 @@ while (!exit) {
}
}
con.setFullscreen(false)
con.curs_set(1)
con.clear()
return 0