|
|
|
@ -1,11 +1,24 @@
|
|
|
|
|
local Generic = require("device/generic/device") -- <= look at this file!
|
|
|
|
|
local TimeVal = require("ui/timeval")
|
|
|
|
|
local logger = require("logger")
|
|
|
|
|
|
|
|
|
|
local function yes() return true end
|
|
|
|
|
local function no() return false end
|
|
|
|
|
|
|
|
|
|
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 screen_width = 1404 -- unscaled_size_check: ignore
|
|
|
|
|
local screen_height = 1872 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_width = 15725 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_height = 20967 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_scale_x = screen_width / wacom_width
|
|
|
|
|
local wacom_scale_y = screen_height / wacom_height
|
|
|
|
|
|
|
|
|
|
local Remarkable = Generic:new{
|
|
|
|
|
model = "reMarkable",
|
|
|
|
|
isRemarkable = yes,
|
|
|
|
|
hasKeys = yes,
|
|
|
|
|
needsScreenRefreshAfterResume = no,
|
|
|
|
@ -17,39 +30,61 @@ local Remarkable = Generic:new{
|
|
|
|
|
display_dpi = 226,
|
|
|
|
|
-- Despite the SoC supporting it, it's finicky in practice (#6772)
|
|
|
|
|
canHWInvert = no,
|
|
|
|
|
home_dir = "/mnt/root",
|
|
|
|
|
home_dir = "/home/root",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 screen_width = 1404 -- unscaled_size_check: ignore
|
|
|
|
|
local screen_height = 1872 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_width = 15725 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_height = 20967 -- unscaled_size_check: ignore
|
|
|
|
|
local wacom_scale_x = screen_width / wacom_width
|
|
|
|
|
local wacom_scale_y = screen_height / wacom_height
|
|
|
|
|
local mt_width = 767 -- unscaled_size_check: ignore
|
|
|
|
|
local mt_height = 1023 -- unscaled_size_check: ignore
|
|
|
|
|
local mt_scale_x = screen_width / mt_width
|
|
|
|
|
local mt_scale_y = screen_height / mt_height
|
|
|
|
|
local adjustTouchEvt = function(self, ev)
|
|
|
|
|
local Remarkable1 = Remarkable:new{
|
|
|
|
|
model = "reMarkable",
|
|
|
|
|
mt_width = 767, -- unscaled_size_check: ignore
|
|
|
|
|
mt_height = 1023, -- unscaled_size_check: ignore
|
|
|
|
|
input_wacom = "/dev/input/event0",
|
|
|
|
|
input_ts = "/dev/input/event1",
|
|
|
|
|
input_buttons = "/dev/input/event2",
|
|
|
|
|
battery_path = "/sys/class/power_supply/bq27441-0/capacity",
|
|
|
|
|
status_path = "/sys/class/power_supply/bq27441-0/status",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Remarkable1:adjustTouchEvent(ev, by)
|
|
|
|
|
if ev.type == EV_ABS then
|
|
|
|
|
ev.time = TimeVal:now()
|
|
|
|
|
-- Mirror X and Y and scale up both X & Y as touch input is different res from
|
|
|
|
|
-- display
|
|
|
|
|
if ev.code == ABS_MT_POSITION_X then
|
|
|
|
|
ev.value = (Remarkable1.mt_width - ev.value) * by.mt_scale_x
|
|
|
|
|
end
|
|
|
|
|
if ev.code == ABS_MT_POSITION_Y then
|
|
|
|
|
ev.value = (Remarkable1.mt_height - ev.value) * by.mt_scale_y
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local Remarkable2 = Remarkable:new{
|
|
|
|
|
model = "reMarkable 2",
|
|
|
|
|
mt_width = 1403, -- unscaled_size_check: ignore
|
|
|
|
|
mt_height = 1871, -- unscaled_size_check: ignore
|
|
|
|
|
input_wacom = "/dev/input/event1",
|
|
|
|
|
input_ts = "/dev/input/event2",
|
|
|
|
|
input_buttons = "/dev/input/event0",
|
|
|
|
|
battery_path = "/sys/class/power_supply/max77818_battery/capacity",
|
|
|
|
|
status_path = "/sys/class/power_supply/max77818-charger/status",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Remarkable2:adjustTouchEvent(ev, by)
|
|
|
|
|
if ev.type == EV_ABS then
|
|
|
|
|
-- Mirror X and scale up both X & Y as touch input is different res from
|
|
|
|
|
ev.time = TimeVal:now()
|
|
|
|
|
-- Mirror Y and scale up both X & Y as touch input is different res from
|
|
|
|
|
-- display
|
|
|
|
|
if ev.code == ABS_MT_POSITION_X then
|
|
|
|
|
ev.value = (mt_width - ev.value) * mt_scale_x
|
|
|
|
|
ev.value = (ev.value) * by.mt_scale_x
|
|
|
|
|
end
|
|
|
|
|
if ev.code == ABS_MT_POSITION_Y then
|
|
|
|
|
ev.value = (mt_height - ev.value) * mt_scale_y
|
|
|
|
|
ev.value = (Remarkable2.mt_height - ev.value) * by.mt_scale_y
|
|
|
|
|
end
|
|
|
|
|
-- The Wacom input layer is non-multi-touch and
|
|
|
|
|
-- uses its own scaling factor.
|
|
|
|
|
-- The X and Y coordinates are swapped, and the (real) Y
|
|
|
|
|
-- coordinate has to be inverted.
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local adjustAbsEvt = function(self, ev)
|
|
|
|
|
if ev.type == EV_ABS then
|
|
|
|
|
if ev.code == ABS_X then
|
|
|
|
|
ev.code = ABS_Y
|
|
|
|
|
ev.value = (wacom_height - ev.value) * wacom_scale_y
|
|
|
|
@ -60,18 +95,29 @@ local adjustTouchEvt = function(self, ev)
|
|
|
|
|
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.powerd = require("device/remarkable/powerd"):new{
|
|
|
|
|
device = self,
|
|
|
|
|
capacity_file = self.battery_path,
|
|
|
|
|
status_file = self.status_path,
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
self.input.open(self.input_wacom) -- Wacom
|
|
|
|
|
self.input.open(self.input_ts) -- Touchscreen
|
|
|
|
|
self.input.open(self.input_buttons) -- Buttons
|
|
|
|
|
|
|
|
|
|
local scalex = screen_width / self.mt_width
|
|
|
|
|
local scaley = screen_height / self.mt_height
|
|
|
|
|
|
|
|
|
|
self.input:registerEventAdjustHook(adjustAbsEvt)
|
|
|
|
|
self.input:registerEventAdjustHook(self.adjustTouchEvent, {mt_scale_x=scalex, mt_scale_y=scaley})
|
|
|
|
|
|
|
|
|
|
-- USB plug/unplug, battery charge/not charging are generated as fake events
|
|
|
|
|
self.input.open("fake_events")
|
|
|
|
|
|
|
|
|
@ -118,5 +164,20 @@ function Remarkable:reboot()
|
|
|
|
|
os.execute("systemctl reboot")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Remarkable
|
|
|
|
|
local f = io.open("/sys/devices/soc0/machine")
|
|
|
|
|
if not f then error("missing sysfs entry for a remarkable") end
|
|
|
|
|
|
|
|
|
|
local deviceType = f:read("*line")
|
|
|
|
|
f:close()
|
|
|
|
|
|
|
|
|
|
logger.info("deviceType: ", deviceType)
|
|
|
|
|
|
|
|
|
|
if deviceType == "reMarkable 2.0" then
|
|
|
|
|
if not os.getenv("RM2FB_SHIM") then
|
|
|
|
|
error("reMarkable2 requires RM2FB to work (https://github.com/ddvk/remarkable2-framebuffer)")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Remarkable2
|
|
|
|
|
else
|
|
|
|
|
return Remarkable1
|
|
|
|
|
end
|
|
|
|
|