2015-01-09 14:10:25 +00:00
|
|
|
local Generic = require("device/generic/device") -- <= look at this file!
|
2016-12-29 08:10:38 +00:00
|
|
|
local logger = require("logger")
|
2017-10-22 16:08:53 +00:00
|
|
|
local ffi = require("ffi")
|
2020-08-30 15:27:37 +00:00
|
|
|
local C = ffi.C
|
2017-10-22 16:08:53 +00:00
|
|
|
local inkview = ffi.load("inkview")
|
2020-08-30 15:27:37 +00:00
|
|
|
local band = require("bit").band
|
2020-08-30 16:36:41 +00:00
|
|
|
local util = require("util")
|
2015-01-09 14:10:25 +00:00
|
|
|
|
2020-08-30 15:27:37 +00:00
|
|
|
require("ffi/posix_h")
|
|
|
|
require("ffi/linux_input_h")
|
|
|
|
require("ffi/inkview_h")
|
|
|
|
|
|
|
|
-- FIXME: Signal ffi/input.lua (brought in by device/input later on) that we want to use poll mode backend.
|
|
|
|
-- Remove this once backend becomes poll-only.
|
|
|
|
_G.POCKETBOOK_FFI = true
|
2017-10-22 16:08:53 +00:00
|
|
|
|
2015-01-09 14:10:25 +00:00
|
|
|
local function yes() return true end
|
2017-12-02 09:28:11 +00:00
|
|
|
local function no() return false end
|
2015-01-09 14:10:25 +00:00
|
|
|
|
2020-09-01 15:52:16 +00:00
|
|
|
local ext_path = "/mnt/ext1/system/config/extensions.cfg"
|
|
|
|
local app_name = "koreader.app"
|
2016-06-12 18:50:30 +00:00
|
|
|
|
2015-01-09 14:10:25 +00:00
|
|
|
local PocketBook = Generic:new{
|
2015-01-12 16:14:56 +00:00
|
|
|
model = "PocketBook",
|
|
|
|
isPocketBook = yes,
|
2018-10-06 05:55:35 +00:00
|
|
|
hasOTAUpdates = yes,
|
2019-03-12 06:05:43 +00:00
|
|
|
hasWifiToggle = yes,
|
2020-05-19 18:07:18 +00:00
|
|
|
isTouchDevice = yes,
|
|
|
|
hasKeys = yes,
|
|
|
|
hasFrontlight = yes,
|
2020-06-19 07:41:50 +00:00
|
|
|
canSuspend = no,
|
2020-09-02 21:35:59 +00:00
|
|
|
canReboot = yes,
|
2020-09-01 19:43:21 +00:00
|
|
|
canPowerOff = yes,
|
2020-08-30 15:27:37 +00:00
|
|
|
needsScreenRefreshAfterResume = no,
|
2020-06-19 07:41:50 +00:00
|
|
|
home_dir = "/mnt/ext1",
|
2020-08-19 20:41:10 +00:00
|
|
|
|
|
|
|
-- all devices that have warmth lights use inkview api
|
|
|
|
hasNaturalLightApi = yes,
|
2020-09-19 17:05:35 +00:00
|
|
|
|
2020-09-27 19:35:03 +00:00
|
|
|
-- NOTE: Apparently, HW inversion is a pipedream on PB (#6669), ... well, on sunxi chipsets anyway.
|
|
|
|
-- For which we now probe in fbinfoOverride() and tweak the flag to "no".
|
|
|
|
-- NTX chipsets *should* work (PB631), but in case it doesn't on your device, set this to "no" in here.
|
|
|
|
canHWInvert = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
|
2020-10-17 10:59:24 +00:00
|
|
|
-- If we can access the necessary devices, input events can be handled directly.
|
|
|
|
-- This improves latency (~40ms), as well as power usage - we can spend more time asleep,
|
|
|
|
-- instead of busy looping at 50Hz the way inkview insists on doing.
|
|
|
|
-- In case this method fails (no root), we fallback to classic inkview api.
|
|
|
|
raw_input = nil, --[[{
|
|
|
|
-- value or function to adjust touch matrix orientiation.
|
|
|
|
touch_rotation = -3+4,
|
|
|
|
-- Works same as input.event_map, but for raw input EV_KEY translation
|
|
|
|
keymap = { [scan] = event },
|
|
|
|
}]]
|
|
|
|
-- Runtime state: whether raw input is actually used
|
|
|
|
is_using_raw_input = nil,
|
|
|
|
|
2020-09-22 20:04:37 +00:00
|
|
|
-- Private per-model kludges
|
|
|
|
_fb_init = function() end,
|
|
|
|
_model_init = function() end,
|
2015-01-09 14:10:25 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 19:43:21 +00:00
|
|
|
-- Helper to try load externally signalled book whenever we're brought to foreground
|
|
|
|
local function tryOpenBook()
|
|
|
|
local path = os.getenv("KO_PATH_OPEN_BOOK")
|
|
|
|
if not path then return end
|
|
|
|
local fi = io.open(path, "r")
|
|
|
|
if not fi then return end
|
|
|
|
local fn = fi:read("*line")
|
|
|
|
fi:close()
|
|
|
|
os.remove(path)
|
|
|
|
if fn and util.pathExists(fn) then
|
|
|
|
require("apps/reader/readerui"):showReader(fn)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-27 19:35:03 +00:00
|
|
|
local function isB288(fb)
|
|
|
|
-- No real header exists for this, see https://github.com/koreader/koreader-base/issues/1202/
|
|
|
|
local B288_POLL_FOR_UPDATE_COMPLETE = 0x80044655
|
|
|
|
-- On NXT that has a real MXC driver, it returns -EINVAL
|
|
|
|
return C.ioctl(fb.fd, B288_POLL_FOR_UPDATE_COMPLETE, ffi.new("uint32_t[1]")) == 0
|
|
|
|
end
|
|
|
|
|
2015-01-09 14:10:25 +00:00
|
|
|
function PocketBook:init()
|
2020-10-17 10:59:24 +00:00
|
|
|
local raw_input = self.raw_input
|
|
|
|
local touch_rotation = raw_input and raw_input.touch_rotation or 0
|
|
|
|
|
2020-09-22 20:04:37 +00:00
|
|
|
self.screen = require("ffi/framebuffer_mxcfb"):new {
|
|
|
|
device = self,
|
|
|
|
debug = logger.dbg,
|
2020-09-27 19:35:03 +00:00
|
|
|
fbinfoOverride = function(fb, finfo, vinfo)
|
|
|
|
-- Device model caps *can* set both to indicate that either will work to get correct orientation.
|
|
|
|
-- But for FB backend, the flags are mutually exclusive, so we nuke one of em later.
|
|
|
|
fb.is_always_portrait = self.isAlwaysPortrait()
|
|
|
|
fb.forced_rotation = self.usingForcedRotation()
|
|
|
|
-- Tweak combination of alwaysPortrait/hwRot/hwInvert flags depending on probed HW.
|
|
|
|
if isB288(fb) then
|
|
|
|
logger.dbg("mxcfb: Detected B288 chipset, disabling HW rotation and invert")
|
|
|
|
fb.forced_rotation = nil
|
|
|
|
self.canHWInvert = no
|
|
|
|
elseif fb.forced_rotation then
|
|
|
|
fb.is_always_portrait = false
|
|
|
|
end
|
|
|
|
return self._fb_init(fb, finfo, vinfo)
|
|
|
|
end,
|
2020-10-17 10:59:24 +00:00
|
|
|
-- raw touch input orientiation is different from the screen
|
|
|
|
getTouchRotation = function(fb)
|
|
|
|
if type(touch_rotation) == "function" then
|
|
|
|
return touch_rotation(self, fb:getRotationMode())
|
|
|
|
end
|
|
|
|
return (4 + fb:getRotationMode() + touch_rotation) % 4
|
|
|
|
end,
|
2020-09-22 20:04:37 +00:00
|
|
|
}
|
2020-08-30 15:27:37 +00:00
|
|
|
|
|
|
|
-- Whenever we lose focus, but also get suspended for real (we can't reliably tell atm),
|
|
|
|
-- plugins need to be notified to stop doing foreground stuff, and vice versa. To this end,
|
|
|
|
-- we maintain pseudo suspended state just to keep plugins happy, even though it's not
|
|
|
|
-- related real to suspend states.
|
|
|
|
local quasiSuspended
|
|
|
|
|
2018-01-06 12:14:26 +00:00
|
|
|
self.input = require("device/input"):new{
|
|
|
|
device = self,
|
2020-10-17 10:59:24 +00:00
|
|
|
raw_input = raw_input,
|
|
|
|
event_map = setmetatable({
|
2020-08-30 15:27:37 +00:00
|
|
|
[C.KEY_MENU] = "Menu",
|
|
|
|
[C.KEY_PREV] = "LPgBack",
|
|
|
|
[C.KEY_NEXT] = "LPgFwd",
|
|
|
|
[C.KEY_UP] = "Up",
|
|
|
|
[C.KEY_DOWN] = "Down",
|
|
|
|
[C.KEY_LEFT] = "Left",
|
|
|
|
[C.KEY_RIGHT] = "Right",
|
|
|
|
[C.KEY_OK] = "Press",
|
2020-10-17 10:59:24 +00:00
|
|
|
}, {__index=raw_input and raw_input.keymap or {}}),
|
2018-01-06 12:14:26 +00:00
|
|
|
handleMiscEv = function(this, ev)
|
2020-08-30 15:27:37 +00:00
|
|
|
local ui = require("ui/uimanager")
|
|
|
|
if ev.code == C.EVT_HIDE or ev.code == C.EVT_BACKGROUND then
|
|
|
|
ui:flushSettings()
|
|
|
|
if not quasiSuspended then
|
|
|
|
quasiSuspended = true
|
|
|
|
return "Suspend"
|
|
|
|
end
|
|
|
|
elseif ev.code == C.EVT_FOREGROUND or ev.code == C.EVT_SHOW then
|
2020-09-01 19:43:21 +00:00
|
|
|
tryOpenBook()
|
2020-09-19 17:05:35 +00:00
|
|
|
ui:setDirty('all', 'ui')
|
2020-08-30 15:27:37 +00:00
|
|
|
if quasiSuspended then
|
|
|
|
quasiSuspended = false
|
2018-01-06 12:14:26 +00:00
|
|
|
return "Resume"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- in contrast to kobo/kindle, pocketbook-devices do not use linux/input
|
|
|
|
-- events directly. To be able to use input.lua nevertheless, we make
|
|
|
|
-- inkview-events look like linux/input events or handle them directly
|
|
|
|
-- here.
|
|
|
|
-- Unhandled events will leave Input:waitEvent() as "GenericInput"
|
2015-01-15 14:23:03 +00:00
|
|
|
self.input:registerEventAdjustHook(function(_input, ev)
|
2020-08-30 15:27:37 +00:00
|
|
|
if ev.type == C.EVT_KEYDOWN or ev.type == C.EVT_KEYUP then
|
|
|
|
ev.value = ev.type == C.EVT_KEYDOWN and 1 or 0
|
|
|
|
ev.type = C.EV_KEY
|
2018-01-06 12:14:26 +00:00
|
|
|
end
|
|
|
|
|
2020-08-30 15:27:37 +00:00
|
|
|
-- handle C.EVT_BACKGROUND and C.EVT_FOREGROUND as MiscEvent as this makes
|
2018-01-06 12:14:26 +00:00
|
|
|
-- it easy to return a string directly which can be used in
|
|
|
|
-- uimanager.lua as event_handler index.
|
2020-08-30 15:27:37 +00:00
|
|
|
if ev.type == C.EVT_BACKGROUND or ev.type == C.EVT_FOREGROUND
|
|
|
|
or ev.type == C.EVT_SHOW or ev.type == C.EVT_HIDE then
|
2018-01-06 12:14:26 +00:00
|
|
|
ev.code = ev.type
|
2020-08-30 15:27:37 +00:00
|
|
|
ev.type = C.EV_MSC -- handle as MiscEvent, see above
|
2018-01-06 12:14:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- auto shutdown event from inkview framework, gracefully close
|
|
|
|
-- everything and let the framework shutdown the device
|
2020-08-30 15:27:37 +00:00
|
|
|
if ev.type == C.EVT_EXIT then
|
2016-06-14 07:00:50 +00:00
|
|
|
require("ui/uimanager"):broadcastEvent(
|
|
|
|
require("ui/event"):new("Close"))
|
2015-01-15 14:23:03 +00:00
|
|
|
end
|
2015-01-09 14:10:25 +00:00
|
|
|
end)
|
|
|
|
|
2020-09-22 20:04:37 +00:00
|
|
|
self._model_init()
|
2020-10-17 10:59:24 +00:00
|
|
|
if (not self.input.raw_input) or (not pcall(self.input.open, self.input, self.raw_input)) then
|
|
|
|
inkview.OpenScreen()
|
|
|
|
-- Raw mode open failed (no permissions?), so we'll run the usual way.
|
|
|
|
-- Disable touch coordinate translation as inkview will do that.
|
|
|
|
self.input.raw_input = nil
|
|
|
|
self.input:open()
|
|
|
|
touch_rotation = 0
|
|
|
|
else
|
|
|
|
self.canSuspend = yes
|
|
|
|
end
|
|
|
|
self.powerd = require("device/pocketbook/powerd"):new{device = self}
|
2020-08-30 15:27:37 +00:00
|
|
|
self:setAutoStandby(true)
|
2015-01-09 14:10:25 +00:00
|
|
|
Generic.init(self)
|
|
|
|
end
|
|
|
|
|
2020-09-01 15:52:16 +00:00
|
|
|
function PocketBook:notifyBookState(title, document)
|
|
|
|
local fn = document and document.file or nil
|
|
|
|
logger.dbg("Notify book state", title or "[nil]", fn or "[nil]")
|
|
|
|
os.remove("/tmp/.current")
|
|
|
|
if fn then
|
|
|
|
local fo = io.open("/tmp/.current", "w+")
|
|
|
|
fo:write(fn)
|
|
|
|
fo:close()
|
|
|
|
end
|
|
|
|
inkview.SetSubtaskInfo(inkview.GetCurrentTask(), 0, title and (title .. " - koreader") or "koreader", fn)
|
|
|
|
end
|
|
|
|
|
2017-09-18 17:04:36 +00:00
|
|
|
function PocketBook:setDateTime(year, month, day, hour, min, sec)
|
2017-08-15 17:54:02 +00:00
|
|
|
if hour == nil or min == nil then return true end
|
2020-08-30 15:27:37 +00:00
|
|
|
-- If the device is rooted, we might actually have a fighting chance to change os clock.
|
|
|
|
local su = "/mnt/secure/su"
|
|
|
|
su = util.pathExists(su) and (su .. " ") or ""
|
2017-09-18 17:04:36 +00:00
|
|
|
local command
|
|
|
|
if year and month and day then
|
2020-08-30 15:27:37 +00:00
|
|
|
command = string.format(su .. "/bin/date -s '%d-%d-%d %d:%d:%d'", year, month, day, hour, min, sec)
|
2017-09-18 17:04:36 +00:00
|
|
|
else
|
2020-08-30 15:27:37 +00:00
|
|
|
command = string.format(su .. "/bin/date -s '%d:%d'",hour, min)
|
2017-09-18 17:04:36 +00:00
|
|
|
end
|
|
|
|
if os.execute(command) == 0 then
|
2020-08-30 15:27:37 +00:00
|
|
|
os.execute(su .. '/sbin/hwclock -u -w')
|
2017-08-15 17:54:02 +00:00
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-01 15:52:16 +00:00
|
|
|
-- Predicate, so no self
|
|
|
|
function PocketBook.canAssociateFileExtensions()
|
|
|
|
local f = io.open(ext_path, "r")
|
|
|
|
if not f then return true end
|
|
|
|
local l = f:read("*line")
|
|
|
|
f:close()
|
|
|
|
if l and not l:match("^#koreader") then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function PocketBook:associateFileExtensions(assoc)
|
|
|
|
-- First load the system-wide table, from which we'll snoop file types and icons
|
|
|
|
local info = {}
|
|
|
|
for l in io.lines("/ebrmain/config/extensions.cfg") do
|
|
|
|
local m = { l:match("^([^:]*):([^:]*):([^:]*):([^:]*):(.*)") }
|
|
|
|
info[m[1]] = m
|
|
|
|
end
|
|
|
|
local res = {"#koreader"}
|
|
|
|
for k,v in pairs(assoc) do
|
|
|
|
local t = info[k]
|
|
|
|
if t then
|
|
|
|
-- A system entry exists, so just change app, and reuse the rest
|
2020-09-02 20:44:38 +00:00
|
|
|
t[4] = app_name .. "," .. t[4]
|
2020-09-01 15:52:16 +00:00
|
|
|
else
|
|
|
|
-- Doesn't exist, so hallucinate up something
|
|
|
|
-- TBD: We have document opener in 'v', maybe consult mime in there?
|
|
|
|
local bn = k:match("%a+"):upper()
|
|
|
|
t = { k, '@' .. bn .. '_file', "1", app_name, "ICON_" .. bn }
|
|
|
|
end
|
|
|
|
table.insert(res, table.concat(t, ":"))
|
|
|
|
end
|
|
|
|
local out = io.open(ext_path, "w+")
|
|
|
|
out:write(table.concat(res, "\n"))
|
|
|
|
out:close()
|
|
|
|
end
|
|
|
|
|
2020-08-30 15:27:37 +00:00
|
|
|
function PocketBook:setAutoStandby(isAllowed)
|
|
|
|
inkview.iv_sleepmode(isAllowed and 1 or 0)
|
|
|
|
end
|
|
|
|
|
2020-09-01 19:43:21 +00:00
|
|
|
function PocketBook:powerOff()
|
|
|
|
inkview.PowerOff()
|
|
|
|
end
|
|
|
|
|
2020-10-17 10:59:24 +00:00
|
|
|
function PocketBook:suspend()
|
|
|
|
inkview.SendGlobalRequest(C.REQ_KEYLOCK)
|
|
|
|
end
|
|
|
|
|
2020-09-02 21:35:59 +00:00
|
|
|
function PocketBook:reboot()
|
|
|
|
inkview.iv_ipc_request(C.MSG_REBOOT, 1, nil, 0, 0)
|
|
|
|
end
|
|
|
|
|
2016-06-12 18:50:30 +00:00
|
|
|
function PocketBook:initNetworkManager(NetworkMgr)
|
2019-03-12 06:05:43 +00:00
|
|
|
function NetworkMgr:turnOnWifi(complete_callback)
|
2020-08-30 15:27:37 +00:00
|
|
|
if inkview.NetConnect(nil) ~= C.NET_OK then
|
2019-03-12 06:05:43 +00:00
|
|
|
logger.info('NetConnect failed')
|
|
|
|
end
|
|
|
|
if complete_callback then
|
|
|
|
complete_callback()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function NetworkMgr:turnOffWifi(complete_callback)
|
|
|
|
inkview.NetDisconnect()
|
|
|
|
if complete_callback then
|
|
|
|
complete_callback()
|
|
|
|
end
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
|
|
|
|
2019-03-12 06:05:43 +00:00
|
|
|
function NetworkMgr:isWifiOn()
|
2020-08-30 15:27:37 +00:00
|
|
|
return band(inkview.QueryNetwork(), C.CONNECTED) ~= 0
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-22 16:08:53 +00:00
|
|
|
function PocketBook:getSoftwareVersion()
|
|
|
|
return ffi.string(inkview.GetSoftwareVersion())
|
|
|
|
end
|
|
|
|
|
|
|
|
function PocketBook:getDeviceModel()
|
|
|
|
return ffi.string(inkview.GetDeviceModel())
|
|
|
|
end
|
|
|
|
|
2020-09-22 20:04:37 +00:00
|
|
|
-- Pocketbook HW rotation modes start from landsape, CCW
|
2020-09-27 19:35:03 +00:00
|
|
|
local function landscape_ccw() return {
|
2020-09-22 20:04:37 +00:00
|
|
|
1, 0, 3, 2, -- PORTRAIT, LANDSCAPE, PORTRAIT_180, LANDSCAPE_180
|
|
|
|
every_paint = true, -- inkview will try to steal the rot mode frequently
|
|
|
|
restore = false, -- no need, because everything using inkview forces 3 on focus
|
|
|
|
default = nil, -- usually 3
|
2020-09-27 19:35:03 +00:00
|
|
|
} end
|
2020-09-22 20:04:37 +00:00
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Mini (515)
|
2020-05-24 13:58:43 +00:00
|
|
|
local PocketBook515 = PocketBook:new{
|
|
|
|
model = "PB515",
|
|
|
|
display_dpi = 200,
|
|
|
|
isTouchDevice = no,
|
2020-08-23 09:15:49 +00:00
|
|
|
hasFrontlight = no,
|
2020-05-25 10:23:43 +00:00
|
|
|
hasDPad = yes,
|
2020-05-26 15:43:44 +00:00
|
|
|
hasFewKeys = yes,
|
2020-05-24 13:58:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 08:09:54 +00:00
|
|
|
-- PocketBook 606 (606)
|
|
|
|
local PocketBook606 = PocketBook:new{
|
|
|
|
model = "PB606",
|
|
|
|
display_dpi = 212,
|
|
|
|
isTouchDevice = no,
|
|
|
|
hasFrontlight = no,
|
|
|
|
hasDPad = yes,
|
|
|
|
hasFewKeys = yes,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Basic (611)
|
|
|
|
local PocketBook611 = PocketBook:new{
|
|
|
|
model = "PB611",
|
|
|
|
display_dpi = 167,
|
|
|
|
isTouchDevice = no,
|
|
|
|
hasFrontlight = no,
|
|
|
|
hasDPad = yes,
|
|
|
|
hasFewKeys = yes,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook Basic (613)
|
2020-05-26 15:07:41 +00:00
|
|
|
local PocketBook613 = PocketBook:new{
|
|
|
|
model = "PB613B",
|
|
|
|
display_dpi = 167,
|
|
|
|
isTouchDevice = no,
|
|
|
|
hasWifiToggle = no,
|
2020-08-07 21:02:30 +00:00
|
|
|
hasFrontlight = no,
|
2020-05-26 15:07:41 +00:00
|
|
|
hasDPad = yes,
|
2020-05-26 15:43:44 +00:00
|
|
|
hasFewKeys = yes,
|
2020-05-26 15:07:41 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Basic 2 / Basic 3 (614/614W)
|
2020-06-26 14:15:49 +00:00
|
|
|
local PocketBook614W = PocketBook:new{
|
|
|
|
model = "PB614W",
|
|
|
|
display_dpi = 167,
|
|
|
|
isTouchDevice = no,
|
|
|
|
hasFrontlight = no,
|
|
|
|
hasDPad = yes,
|
|
|
|
hasFewKeys = yes,
|
|
|
|
}
|
|
|
|
|
2020-08-19 12:49:17 +00:00
|
|
|
-- PocketBook Basic Lux / 615 Plus (615/615W)
|
2020-08-07 21:02:30 +00:00
|
|
|
local PocketBook615 = PocketBook:new{
|
|
|
|
model = "PBBLux",
|
2020-05-24 13:58:43 +00:00
|
|
|
display_dpi = 212,
|
2020-05-26 15:07:41 +00:00
|
|
|
isTouchDevice = no,
|
|
|
|
hasDPad = yes,
|
2020-05-26 15:43:44 +00:00
|
|
|
hasFewKeys = yes,
|
2020-05-24 13:58:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 12:49:17 +00:00
|
|
|
-- PocketBook Basic Lux 2 (616/616W)
|
2020-08-07 21:02:30 +00:00
|
|
|
local PocketBook616 = PocketBook:new{
|
|
|
|
model = "PBBLux2",
|
2018-11-26 14:19:00 +00:00
|
|
|
display_dpi = 212,
|
2020-08-07 21:02:30 +00:00
|
|
|
isTouchDevice = no,
|
|
|
|
hasDPad = yes,
|
|
|
|
hasFewKeys = yes,
|
2018-11-26 14:19:00 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch (622)
|
|
|
|
local PocketBook622 = PocketBook:new{
|
|
|
|
model = "PBTouch",
|
|
|
|
display_dpi = 167,
|
|
|
|
hasFrontlight = no,
|
2018-12-25 23:56:02 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch Lux (623)
|
|
|
|
local PocketBook623 = PocketBook:new{
|
|
|
|
model = "PBTouchLux",
|
2017-11-07 19:51:52 +00:00
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Basic Touch (624)
|
2017-12-02 09:28:11 +00:00
|
|
|
local PocketBook624 = PocketBook:new{
|
2019-01-13 23:49:29 +00:00
|
|
|
model = "PBBasicTouch",
|
2020-08-07 21:02:30 +00:00
|
|
|
display_dpi = 167,
|
2017-12-02 09:28:11 +00:00
|
|
|
hasFrontlight = no,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Basic Touch 2 (625)
|
2019-01-08 02:46:32 +00:00
|
|
|
local PocketBook625 = PocketBook:new{
|
2019-01-13 23:49:29 +00:00
|
|
|
model = "PBBasicTouch2",
|
2020-08-07 21:02:30 +00:00
|
|
|
display_dpi = 167,
|
2019-01-08 02:46:32 +00:00
|
|
|
hasFrontlight = no,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch Lux 2 / Touch Lux 3 (626)
|
|
|
|
local PocketBook626 = PocketBook:new{
|
|
|
|
model = "PBLux3",
|
|
|
|
display_dpi = 212,
|
2019-07-15 12:39:37 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch Lux 4 (627)
|
|
|
|
local PocketBook627 = PocketBook:new{
|
|
|
|
model = "PBLux4",
|
2017-12-10 19:02:34 +00:00
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch Lux 5 (628)
|
|
|
|
local PocketBook628 = PocketBook:new{
|
|
|
|
model = "PBTouchLux5",
|
|
|
|
display_dpi = 212,
|
2020-09-27 19:35:03 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2020-08-19 20:41:10 +00:00
|
|
|
hasNaturalLight = yes,
|
2018-04-04 16:26:44 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Sense / Sense 2 (630)
|
|
|
|
local PocketBook630 = PocketBook:new{
|
|
|
|
model = "PBSense",
|
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook Touch HD / Touch HD 2 (631)
|
|
|
|
local PocketBook631 = PocketBook:new{
|
|
|
|
model = "PBTouchHD",
|
2019-09-18 13:21:04 +00:00
|
|
|
display_dpi = 300,
|
2020-08-19 20:41:10 +00:00
|
|
|
-- see https://github.com/koreader/koreader/pull/6531#issuecomment-676629182
|
|
|
|
hasNaturalLight = function() return inkview.GetFrontlightColor() >= 0 end,
|
2019-09-18 13:21:04 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Touch HD Plus / Touch HD 3 (632)
|
|
|
|
local PocketBook632 = PocketBook:new{
|
|
|
|
model = "PBTouchHDPlus",
|
|
|
|
display_dpi = 300,
|
2020-09-27 19:35:03 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2020-08-19 20:41:10 +00:00
|
|
|
hasNaturalLight = yes,
|
2020-02-22 08:09:18 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Color (633)
|
|
|
|
local PocketBook633 = PocketBook:new{
|
|
|
|
model = "PBColor",
|
|
|
|
display_dpi = 300,
|
|
|
|
hasColorScreen = yes,
|
|
|
|
canUseCBB = no, -- 24bpp
|
2020-09-27 19:35:03 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2018-11-23 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Aqua (640)
|
|
|
|
local PocketBook640 = PocketBook:new{
|
|
|
|
model = "PBAqua",
|
|
|
|
display_dpi = 167,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook Aqua 2 (641)
|
2019-01-05 08:02:45 +00:00
|
|
|
local PocketBook641 = PocketBook:new{
|
2019-01-13 23:49:29 +00:00
|
|
|
model = "PBAqua2",
|
2019-01-05 08:02:45 +00:00
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook Ultra (650)
|
|
|
|
local PocketBook650 = PocketBook:new{
|
|
|
|
model = "PBUltra",
|
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook InkPad 3 (740)
|
|
|
|
local PocketBook740 = PocketBook:new{
|
|
|
|
model = "PBInkPad3",
|
|
|
|
display_dpi = 300,
|
2020-09-30 21:27:40 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2020-08-19 20:41:10 +00:00
|
|
|
hasNaturalLight = yes,
|
2020-08-07 21:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook InkPad 3 Pro (740_2)
|
|
|
|
local PocketBook740_2 = PocketBook:new{
|
|
|
|
model = "PBInkPad3Pro",
|
|
|
|
display_dpi = 300,
|
2020-09-27 19:35:03 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2020-08-19 20:41:10 +00:00
|
|
|
hasNaturalLight = yes,
|
2020-10-17 10:59:24 +00:00
|
|
|
raw_input = {
|
|
|
|
touch_rotation = -1,
|
|
|
|
keymap = {
|
|
|
|
[115] = "Menu",
|
|
|
|
[109] = "LPgFwd",
|
|
|
|
[104] = "LPgBack",
|
|
|
|
}
|
|
|
|
}
|
2020-08-07 21:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook Color Lux (801)
|
2018-09-30 19:37:14 +00:00
|
|
|
local PocketBookColorLux = PocketBook:new{
|
2019-01-13 23:49:29 +00:00
|
|
|
model = "PBColorLux",
|
2020-08-07 21:02:30 +00:00
|
|
|
display_dpi = 125,
|
2018-09-30 19:37:14 +00:00
|
|
|
hasColorScreen = yes,
|
2019-05-02 02:27:48 +00:00
|
|
|
canUseCBB = no, -- 24bpp
|
2018-09-30 19:37:14 +00:00
|
|
|
}
|
2020-09-22 20:04:37 +00:00
|
|
|
function PocketBookColorLux:_model_init()
|
|
|
|
self.screen.blitbuffer_rotation_mode = self.screen.ORIENTATION_PORTRAIT
|
|
|
|
self.screen.native_rotation_mode = self.screen.ORIENTATION_PORTRAIT
|
|
|
|
end
|
|
|
|
function PocketBookColorLux._fb_init(fb,finfo,vinfo)
|
|
|
|
-- Pocketbook Color Lux reports bits_per_pixel = 8, but actually uses an RGB24 framebuffer
|
|
|
|
vinfo.bits_per_pixel = 24
|
|
|
|
vinfo.xres = vinfo.xres / 3
|
|
|
|
fb.refresh_pixel_size = 3
|
|
|
|
end
|
2018-09-30 19:37:14 +00:00
|
|
|
|
2020-08-07 21:02:30 +00:00
|
|
|
-- PocketBook InkPad / InkPad 2 (840)
|
|
|
|
local PocketBook840 = PocketBook:new{
|
|
|
|
model = "PBInkPad",
|
|
|
|
display_dpi = 250,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- PocketBook InkPad X (1040)
|
|
|
|
local PocketBook1040 = PocketBook:new{
|
|
|
|
model = "PB1040",
|
|
|
|
display_dpi = 227,
|
2020-09-30 22:10:22 +00:00
|
|
|
isAlwaysPortrait = yes,
|
2020-09-22 20:04:37 +00:00
|
|
|
usingForcedRotation = landscape_ccw,
|
2020-08-19 20:41:10 +00:00
|
|
|
hasNaturalLight = yes,
|
2020-08-07 21:02:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 16:08:53 +00:00
|
|
|
logger.info('SoftwareVersion: ', PocketBook:getSoftwareVersion())
|
|
|
|
|
|
|
|
local codename = PocketBook:getDeviceModel()
|
|
|
|
|
2020-05-24 13:58:43 +00:00
|
|
|
if codename == "PocketBook 515" then
|
|
|
|
return PocketBook515
|
2020-08-20 08:09:54 +00:00
|
|
|
elseif codename == "PB606" or codename == "PocketBook 606" then
|
|
|
|
return PocketBook606
|
2020-08-07 21:02:30 +00:00
|
|
|
elseif codename == "PocketBook 611" then
|
|
|
|
return PocketBook611
|
2020-05-26 15:07:41 +00:00
|
|
|
elseif codename == "PocketBook 613" then
|
|
|
|
return PocketBook613
|
2020-08-19 12:49:17 +00:00
|
|
|
elseif codename == "PocketBook 614" or codename == "PocketBook 614W" then
|
2020-06-26 14:15:49 +00:00
|
|
|
return PocketBook614W
|
2020-08-19 12:49:17 +00:00
|
|
|
elseif codename == "PB615" or codename == "PB615W" or
|
|
|
|
codename == "PocketBook 615" or codename == "PocketBook 615W" then
|
2020-08-07 21:02:30 +00:00
|
|
|
return PocketBook615
|
2020-08-19 12:49:17 +00:00
|
|
|
elseif codename == "PB616" or codename == "PB616W" or
|
|
|
|
codename == "PocketBook 616" or codename == "PocketBook 616W" then
|
2020-05-24 13:58:43 +00:00
|
|
|
return PocketBook616
|
|
|
|
elseif codename == "PocketBook 622" then
|
2019-07-15 12:39:37 +00:00
|
|
|
return PocketBook622
|
|
|
|
elseif codename == "PocketBook 623" then
|
2019-01-13 11:34:53 +00:00
|
|
|
return PocketBook623
|
|
|
|
elseif codename == "PocketBook 624" then
|
|
|
|
return PocketBook624
|
|
|
|
elseif codename == "PB625" then
|
|
|
|
return PocketBook625
|
2019-08-16 20:59:36 +00:00
|
|
|
elseif codename == "PB626" or codename == "PB626(2)-TL3" or
|
|
|
|
codename == "PocketBook 626" then
|
2019-01-13 11:34:53 +00:00
|
|
|
return PocketBook626
|
2018-11-26 14:19:00 +00:00
|
|
|
elseif codename == "PB627" then
|
|
|
|
return PocketBook627
|
2020-08-07 21:02:30 +00:00
|
|
|
elseif codename == "PB628" then
|
|
|
|
return PocketBook628
|
2019-01-13 11:34:53 +00:00
|
|
|
elseif codename == "PocketBook 630" then
|
|
|
|
return PocketBook630
|
2020-08-07 21:02:30 +00:00
|
|
|
elseif codename == "PB631" or codename == "PocketBook 631" then
|
2017-10-22 16:08:53 +00:00
|
|
|
return PocketBook631
|
2018-12-25 23:56:02 +00:00
|
|
|
elseif codename == "PB632" then
|
|
|
|
return PocketBook632
|
2020-08-07 21:02:30 +00:00
|
|
|
elseif codename == "PB633" then
|
|
|
|
return PocketBook633
|
2020-08-20 08:09:54 +00:00
|
|
|
elseif codename == "PB640" or codename == "PocketBook 640" then
|
2020-08-07 21:02:30 +00:00
|
|
|
return PocketBook640
|
2019-01-05 08:02:45 +00:00
|
|
|
elseif codename == "PB641" then
|
|
|
|
return PocketBook641
|
2020-08-20 08:09:54 +00:00
|
|
|
elseif codename == "PB650" or codename == "PocketBook 650" then
|
2020-08-07 21:02:30 +00:00
|
|
|
return PocketBook650
|
2018-04-04 16:26:44 +00:00
|
|
|
elseif codename == "PB740" then
|
|
|
|
return PocketBook740
|
2019-09-18 13:21:04 +00:00
|
|
|
elseif codename == "PB740-2" then
|
|
|
|
return PocketBook740_2
|
2019-01-13 11:34:53 +00:00
|
|
|
elseif codename == "PocketBook 840" then
|
|
|
|
return PocketBook840
|
2020-08-07 21:02:30 +00:00
|
|
|
elseif codename == "PB1040" then
|
|
|
|
return PocketBook1040
|
2018-09-30 19:37:14 +00:00
|
|
|
elseif codename == "PocketBook Color Lux" then
|
|
|
|
return PocketBookColorLux
|
2017-10-22 16:08:53 +00:00
|
|
|
else
|
|
|
|
error("unrecognized PocketBook model " .. codename)
|
|
|
|
end
|