add dummy device & rename runtimectl:setDevice to runtimectl:init

pull/4721/head
Qingping Hou 5 years ago committed by Frans de Jonge
parent 8513778990
commit 855c8c2569

@ -0,0 +1,26 @@
local Generic = require("device/generic/device")
local logger = require("logger")
local function yes() return true end
local function no() return false end
local Device = Generic:new{
model = "dummy",
hasKeyboard = no,
hasKeys = no,
isTouchDevice = no,
needsScreenRefreshAfterResume = no,
hasColorScreen = yes,
hasEinkScreen = no,
}
function Device:init()
self.screen = require("ffi/framebuffer_SDL2_0"):new{
dummy = true,
device = self,
debug = logger.dbg,
}
Generic.init(self)
end
return Device

@ -6,7 +6,20 @@ local Runtimectl = {
is_bgr = false,
}
function Runtimectl:setDevice(device)
--[[
Initialize runtimectl with settings from device.
The following key is required for a device object:
* hasBGRFrameBuffer: function() -> boolean
* screen: object with following methods:
* getWidth() -> int
* getHeight() -> int
* getDPI() -> int
* getSize() -> Rect
* scaleBySize(int) -> int
]]--
function Runtimectl:init(device)
self.screen = device.screen
self.isAndroid = device.isAndroid
self.isKindle = device.isKindle

@ -37,7 +37,7 @@ end
-- setup various runtime control
local Runtimectl = require("runtimectl")
local Device = require("device")
Runtimectl:setDevice(Device)
Runtimectl:init(Device)
local Font = require("ui/font")
Font:setScreen(Device.screen)

Loading…
Cancel
Save