mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-15 07:41:21 +02:00
05f1e3852c
Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.2 KiB
Lua
55 lines
1.2 KiB
Lua
-- Platform capability detection for NX / mobile / desktop.
|
|
|
|
local Platform = {}
|
|
|
|
local cached
|
|
|
|
local function compute()
|
|
local osName = (love and love.system and love.system.getOS and love.system.getOS())
|
|
or "Unknown"
|
|
local nx = osName == "NX"
|
|
local mobile = osName == "Android" or osName == "iOS"
|
|
local nativePicker = love and love.system
|
|
and type(love.system.pickFile) == "function"
|
|
return {
|
|
os = osName,
|
|
nx = nx,
|
|
mobile = mobile,
|
|
console = nx,
|
|
hasNativePicker = nativePicker,
|
|
canSpawnProcess = osName == "OS X" or osName == "Windows" or osName == "Linux",
|
|
romImportMode = nx and "save-directory"
|
|
or (nativePicker and "native-picker")
|
|
or "desktop",
|
|
networkValidated = not nx,
|
|
}
|
|
end
|
|
|
|
function Platform.detect()
|
|
if not cached then cached = compute() end
|
|
return cached
|
|
end
|
|
|
|
function Platform.isNX()
|
|
return Platform.detect().nx
|
|
end
|
|
|
|
function Platform.romImportMode()
|
|
return Platform.detect().romImportMode
|
|
end
|
|
|
|
function Platform.canSpawnProcess()
|
|
return Platform.detect().canSpawnProcess
|
|
end
|
|
|
|
function Platform.networkValidated()
|
|
return Platform.detect().networkValidated
|
|
end
|
|
|
|
-- Tests may swap love.system between cases.
|
|
function Platform._resetForTests()
|
|
cached = nil
|
|
end
|
|
|
|
return Platform
|