2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/device.lua
Hans-Werner Hilse 3066c86e38 Refactoring hardware abstraction
This is a major overhaul of the hardware abstraction layer.
A few notes:

General platform distinction happens in
  frontend/device.lua
which will delegate everything else to
  frontend/device/<platform_name>/device.lua
which should extend
  frontend/device/generic/device.lua

Screen handling is implemented in
  frontend/device/screen.lua
which includes the *functionality* to support device specifics.
Actually setting up the device specific functionality, however,
is done in the device specific setup code in the relevant
device.lua file.

The same goes for input handling.
2014-11-02 21:19:04 +01:00

30 lines
694 B
Lua

local isAndroid, android = pcall(require, "android")
local util = require("ffi/util")
local function probeDevice()
if util.isEmulated() then
return require("device/emulator/device")
end
if isAndroid then
return require("device/android/device")
end
local kindle_sn = io.open("/proc/usid", "r")
if kindle_sn then
kindle_sn:close()
return require("device/kindle/device")
end
local kg_test_fd = lfs.attributes("/bin/kobo_config.sh")
if kg_test_fd then
return require("device/kobo/device")
end
error("did not find a hardware abstraction for this platform")
end
local dev = probeDevice()
dev:init()
return dev