neonucleus/data/OpenOS/boot/91_gpu.lua
IonutParau 687cfebd00 testing version of LuaBIOS and OpenOS
people were having issues getting them to work so now we promote consistency
2025-06-28 20:41:49 +02:00

25 lines
795 B
Lua

local event = require("event")
local function onComponentAvailable(_, componentType)
local component = require("component")
local tty = require("tty")
if (componentType == "screen" and component.isAvailable("gpu")) or
(componentType == "gpu" and component.isAvailable("screen"))
then
local gpu, screen = component.gpu, component.screen
local screen_address = screen.address
if gpu.getScreen() ~= screen_address then
gpu.bind(screen_address)
end
local depth = math.floor(2^(gpu.getDepth()))
os.setenv("TERM", "term-"..depth.."color")
event.push("gpu_bound", gpu.address, screen_address)
if tty.gpu() ~= gpu then
tty.bind(gpu)
event.push("term_available")
end
end
end
event.listen("component_available", onComponentAvailable)