mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Add support for Kobo runtime detection, and its single touch protocol.
This commit is contained in:
@@ -21,12 +21,16 @@ function Device:getModel()
|
||||
if cpu_mod == "MX50" then
|
||||
-- for KPW
|
||||
local pw_test_fd = lfs.attributes("/sys/devices/system/fl_tps6116x/fl_tps6116x0/fl_intensity")
|
||||
-- for Kobo
|
||||
local kg_test_fd = lfs.attributes("/bin/kobo_config.sh")
|
||||
-- for KT
|
||||
local kt_test_fd = lfs.attributes("/sys/devices/platform/whitney-button")
|
||||
-- another special file for KT is Neonode zForce touchscreen:
|
||||
-- /sys/devices/platform/zforce.0/
|
||||
if pw_test_fd then
|
||||
self.model = "KindlePaperWhite"
|
||||
elseif kg_test_fd then
|
||||
self.model = "Kobo"
|
||||
elseif kt_test_fd then
|
||||
self.model = "KindleTouch"
|
||||
else
|
||||
@@ -80,7 +84,7 @@ function Device:isTouchDevice()
|
||||
if not self.model then
|
||||
self.model = self:getModel()
|
||||
end
|
||||
return (self.model == "KindlePaperWhite") or (self.model == "KindleTouch") or util.isEmulated()
|
||||
return (self.model == "KindlePaperWhite") or (self.model == "KindleTouch") or (self.model == "Kobo") or util.isEmulated()
|
||||
end
|
||||
|
||||
function Device:setTouchInputDev(dev)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require "ui/geometry"
|
||||
require "ui/device"
|
||||
|
||||
GestureRange = {
|
||||
ges = nil,
|
||||
@@ -602,6 +603,10 @@ end
|
||||
@return adjusted gesture.
|
||||
--]]
|
||||
function GestureDetector:adjustGesCoordinate(ges)
|
||||
local dev_mod = Device:getModel()
|
||||
if dev_mod == "Kobo" then
|
||||
ges.pos.x, ges.pos.y = (Screen.width - ges.pos.y), (ges.pos.x)
|
||||
end
|
||||
if Screen.cur_rotation_mode == 1 then
|
||||
-- in landscape mode
|
||||
if ges.pos then
|
||||
|
||||
@@ -18,6 +18,11 @@ SYN_REPORT = 0
|
||||
SYN_CONFIG = 1
|
||||
SYN_MT_REPORT = 2
|
||||
|
||||
-- For single-touch events (ABS.code).
|
||||
ABS_X = 00
|
||||
ABS_Y = 01
|
||||
ABS_PRESSURE = 24
|
||||
|
||||
-- For multi-touch events (ABS.code).
|
||||
ABS_MT_SLOT = 47
|
||||
ABS_MT_POSITION_X = 53
|
||||
@@ -271,9 +276,11 @@ function Input:init()
|
||||
-- SDL key codes
|
||||
self.event_map = self.sdl_event_map
|
||||
else
|
||||
input.open("fake_events")
|
||||
local dev_mod = Device:getModel()
|
||||
if dev_mod ~= "KindleTouch" then
|
||||
if dev_mod ~= "Kobo" then
|
||||
input.open("fake_events")
|
||||
end
|
||||
if dev_mod ~= "KindleTouch" and dev_mod ~= "Kobo" then
|
||||
-- event0 in KindleTouch is "WM8962 Beep Generator" (useless)
|
||||
Device:setTouchInputDev("/dev/input/event0")
|
||||
input.open("/dev/input/event0")
|
||||
@@ -305,6 +312,11 @@ function Input:init()
|
||||
return ev
|
||||
end
|
||||
print(_("Auto-detected Kindle Touch"))
|
||||
elseif dev_mod == "Kobo" then
|
||||
input.open("/dev/input/event1")
|
||||
Device:setTouchInputDev("/dev/input/event1")
|
||||
input.open("/dev/input/event0") -- Light button and sleep slider
|
||||
print("Auto-detected Kobo")
|
||||
elseif dev_mod == "Kindle4" then
|
||||
print(_("Auto-detected Kindle 4"))
|
||||
self:adjustKindle4EventMap()
|
||||
@@ -453,9 +465,9 @@ function Input:handleTouchEv(ev)
|
||||
end
|
||||
end
|
||||
elseif ev.type == EV_ABS then
|
||||
if #self.MTSlots == 0 then
|
||||
table.insert(self.MTSlots, self:getMtSlot(self.cur_slot))
|
||||
end
|
||||
if #self.MTSlots == 0 then
|
||||
table.insert(self.MTSlots, self:getMtSlot(self.cur_slot))
|
||||
end
|
||||
if ev.code == ABS_MT_SLOT then
|
||||
if self.cur_slot ~= ev.value then
|
||||
table.insert(self.MTSlots, self:getMtSlot(ev.value))
|
||||
@@ -463,9 +475,15 @@ function Input:handleTouchEv(ev)
|
||||
self.cur_slot = ev.value
|
||||
elseif ev.code == ABS_MT_TRACKING_ID then
|
||||
self:setCurrentMtSlot("id", ev.value)
|
||||
elseif ev.code == ABS_MT_POSITION_X then
|
||||
elseif ev.code == ABS_PRESSURE then
|
||||
if ev.value ~= 0 then
|
||||
self:setCurrentMtSlot("id", 1)
|
||||
else
|
||||
self:setCurrentMtSlot("id", -1)
|
||||
end
|
||||
elseif ev.code == ABS_MT_POSITION_X or ev.code == ABS_X then
|
||||
self:setCurrentMtSlot("x", ev.value)
|
||||
elseif ev.code == ABS_MT_POSITION_Y then
|
||||
elseif ev.code == ABS_MT_POSITION_Y or ev.code == ABS_Y then
|
||||
self:setCurrentMtSlot("y", ev.value)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user