Files
gen1recomp/tests/engine/platform_ps4_test.lua
T
Tomas Morello c073009099 PS4 platform support (LÖVE for PS4, GoldHEN), as platform capabilities
PS4 is described in Platform by what it can do, and the launcher asks for
those capabilities instead of checking console names:

- Platform: ps4 flag, console, no child processes, save-directory ROM import,
  no self-updater or remote fetch.  Three new capabilities:
  padNavigation ("pointer" on NX, "focus" on Xbox and PS4),
  systemQuit (iOS, PS4: no in-app Quit button) and
  inboxTransfer ("mtp" on NX, "ftp" on PS4).
- RomImporter: isNX means the Switch again.  The save-directory inbox flow
  ("Scan again", transfer hints) asks _inboxImport(); fixtures that only set
  isNX keep the NX flow.  Pad focus navigation follows padNavigation, so PS4
  gets Xbox's D-pad focus ring by default (Triangle still toggles the cursor).
  Inbox hints gain FTP variants; the NX strings are unchanged.  Custom
  Carts (.g1rcart) import rescans imports/carts/ on PS4 as on NX.
- LauncherView: Quit button and header layout follow systemQuit; import label,
  drop hint and open-folder follow the inbox capability.  pcall around the
  footer invert shader so a driver rejecting it cannot abort the boot.
- conf.lua: fixed 1920x1080 window (single EGL surface on the console);
  VideoMode/FaithfulRes: fixed display; Performance: balanced tier.
- tests/engine/platform_ps4_test.lua: the capability matrix for PS4, NX,
  Xbox, iOS and desktop.
2026-09-29 18:58:03 -03:00

68 lines
2.4 KiB
Lua

-- PS4 capability detection, and the launcher capabilities it shares with or
-- keeps apart from NX / Xbox / iOS / desktop.
-- Self-contained: luajit tests/engine/platform_ps4_test.lua
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.harness")
local eq = T.eq
local savedLove = _G.love
local function withOS(osName, pickFile, fn)
_G.love = {
system = {
getOS = function() return osName end,
pickFile = pickFile,
},
}
package.loaded["src.core.Platform"] = nil
local Platform = require("src.core.Platform")
Platform._resetForTests()
local ok, err = pcall(fn, Platform)
_G.love = savedLove
package.loaded["src.core.Platform"] = nil
if not ok then error(err) end
end
-- PS4: the Switch's inbox import, Xbox's focus navigation, iOS's system quit.
withOS("PS4", nil, function(Platform)
local caps = Platform.detect()
eq(caps.ps4, true, "PS4 flag")
eq(caps.nx, false, "PS4 is not NX")
eq(caps.console, true, "PS4 console")
eq(caps.romImportMode, "save-directory", "PS4 imports through the inbox")
eq(caps.canSpawnProcess, false, "PS4 cannot spawn processes")
eq(caps.networkValidated, false, "PS4 has no self-updater")
eq(Platform.isPS4(), true, "isPS4 convenience")
eq(Platform.isNX(), false, "isNX false on PS4")
eq(Platform.padNavigation(), "focus", "PS4 pad drives the focus ring")
eq(Platform.systemQuit(), true, "PS4: the PS button owns quitting")
eq(Platform.inboxTransfer(), "ftp", "PS4 inbox hints say FTP")
end)
withOS("NX", nil, function(Platform)
eq(Platform.padNavigation(), "pointer", "NX pad drives the virtual cursor")
eq(Platform.systemQuit(), false, "NX keeps the Quit button")
eq(Platform.inboxTransfer(), "mtp", "NX inbox hints say MTP")
end)
withOS("UWP", function() end, function(Platform)
eq(Platform.padNavigation(), "focus", "Xbox pad drives the focus ring")
eq(Platform.systemQuit(), false, "Xbox keeps the Quit button")
eq(Platform.inboxTransfer(), nil, "Xbox has no inbox")
end)
withOS("iOS", function() end, function(Platform)
eq(Platform.systemQuit(), true, "iOS: Home owns quitting")
eq(Platform.padNavigation(), nil, "iOS pad cursor stays latent")
end)
withOS("OS X", nil, function(Platform)
eq(Platform.padNavigation(), nil, "desktop pad cursor stays latent")
eq(Platform.systemQuit(), false, "desktop keeps the Quit button")
eq(Platform.inboxTransfer(), nil, "desktop has no inbox")
end)
T.finish()