Detecting orientation in lua /love2d looks like this:
function checkOrientation()
local desktopWidth, desktopHeight = love.window.getDesktopDimensions()
if desktopWidth<desktopHeight then MobileOrientation="portrait"
elseif desktopWidth>desktopHeight then MobileOrientation="landscape"
end
end
then in love’s api you can rotate the screen depending on the results with this: love.graphics.rotate(math.pi / 2)
I’m not sure how it is in godot, but there must be some similar api for sure.