mirror of
https://github.com/koreader/koreader
synced 2024-11-04 12:00:25 +00:00
67627ce2d9
Touchscreen is mirrored in X & Y and has a different resolution from the eink panel. Uses systemd for time/date/suspend/poweroff/reboot Two systemd units for platform integration. button-listen is a very simple launcher. to-do: add support for wifi by implementing a wpa supplicant dbus client. Authored-by: Thomas Spurden <tcrs@users.noreply.github.com>
117 lines
3.4 KiB
Lua
117 lines
3.4 KiB
Lua
local Generic = require("device/generic/device") -- <= look at this file!
|
|
local logger = require("logger")
|
|
local TimeVal = require("ui/timeval")
|
|
local ffi = require("ffi")
|
|
|
|
local function yes() return true end
|
|
local function no() return false end
|
|
|
|
local Remarkable = Generic:new{
|
|
model = "reMarkable",
|
|
isRemarkable = yes,
|
|
hasKeys = yes,
|
|
hasOTAUpdates = yes,
|
|
canReboot = yes,
|
|
canPowerOff = yes,
|
|
isTouchDevice = yes,
|
|
hasKeys = yes,
|
|
hasFrontlight = no,
|
|
display_dpi = 226,
|
|
}
|
|
|
|
local EV_ABS = 3
|
|
local ABS_X = 00
|
|
local ABS_Y = 01
|
|
local ABS_MT_POSITION_X = 53
|
|
local ABS_MT_POSITION_Y = 54
|
|
-- Resolutions from libremarkable src/framebuffer/common.rs
|
|
local mt_width = 767
|
|
local mt_height = 1023
|
|
local mt_scale_x = 1404 / mt_width
|
|
local mt_scale_y = 1872 / mt_height
|
|
local adjustTouchEvt = function(self, ev)
|
|
if ev.type == EV_ABS then
|
|
-- Mirror X and scale up both X & Y as touch input is different res from
|
|
-- display
|
|
if ev.code == ABS_X or ev.code == ABS_MT_POSITION_X then
|
|
ev.value = (mt_width - ev.value) * mt_scale_x
|
|
end
|
|
if ev.code == ABS_Y or ev.code == ABS_MT_POSITION_Y then
|
|
ev.value = (mt_height - ev.value) * mt_scale_y
|
|
end
|
|
end
|
|
end
|
|
|
|
function Remarkable:init()
|
|
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = logger.dbg}
|
|
self.powerd = require("device/remarkable/powerd"):new{device = self}
|
|
self.input = require("device/input"):new{
|
|
device = self,
|
|
event_map = require("device/remarkable/event_map"),
|
|
}
|
|
|
|
self.input.open("/dev/input/event0") -- Wacom
|
|
self.input.open("/dev/input/event1") -- Touchscreen
|
|
self.input.open("/dev/input/event2") -- Buttons
|
|
self.input:registerEventAdjustHook(adjustTouchEvt)
|
|
-- USB plug/unplug, battery charge/not charging are generated as fake events
|
|
self.input.open("fake_events")
|
|
|
|
local rotation_mode = self.screen.ORIENTATION_PORTRAIT
|
|
self.screen.native_rotation_mode = rotation_mode
|
|
self.screen.cur_rotation_mode = rotation_mode
|
|
|
|
Generic.init(self)
|
|
end
|
|
|
|
function Remarkable:supportsScreensaver() return true end
|
|
|
|
function Remarkable:setDateTime(year, month, day, hour, min, sec)
|
|
if hour == nil or min == nil then return true end
|
|
local command
|
|
if year and month and day then
|
|
command = string.format("timedatectl set-time '%d-%d-%d %d:%d:%d'", year, month, day, hour, min, sec)
|
|
else
|
|
command = string.format("timedatectl set-time '%d:%d'",hour, min)
|
|
end
|
|
return os.execute(command) == 0
|
|
end
|
|
|
|
function Remarkable:intoScreenSaver()
|
|
local Screensaver = require("ui/screensaver")
|
|
if self.screen_saver_mode == false then
|
|
Screensaver:show()
|
|
end
|
|
self.powerd:beforeSuspend()
|
|
self.screen_saver_mode = true
|
|
end
|
|
|
|
function Remarkable:outofScreenSaver()
|
|
if self.screen_saver_mode == true then
|
|
local Screensaver = require("ui/screensaver")
|
|
Screensaver:close()
|
|
local UIManager = require("ui/uimanager")
|
|
UIManager:nextTick(function() UIManager:setDirty("all", "full") end)
|
|
end
|
|
self.powerd:afterResume()
|
|
self.screen_saver_mode = false
|
|
end
|
|
|
|
function Remarkable:suspend()
|
|
os.execute("systemctl suspend")
|
|
end
|
|
|
|
function Remarkable:resume()
|
|
end
|
|
|
|
function Remarkable:powerOff()
|
|
os.execute("systemctl poweroff")
|
|
end
|
|
|
|
function Remarkable:reboot()
|
|
os.execute("systemctl reboot")
|
|
end
|
|
|
|
return Remarkable
|
|
|