From eed989b34992a489e4769fd261ea24122a06293d Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Tue, 11 Jun 2013 21:54:36 +0200 Subject: [PATCH 1/4] Add support for Kobo runtime detection, and its single touch protocol. --- frontend/ui/device.lua | 6 +++++- frontend/ui/gesturedetector.lua | 5 +++++ frontend/ui/inputevent.lua | 32 +++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 8653f62f9..39daef5de 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -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) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index c58b3a93f..b08d75ae3 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -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 diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index 6c3688519..98f622556 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -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 From 5c0dc66e11145d3fc812a82b16060dde3decd543 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Thu, 13 Jun 2013 03:26:03 -0400 Subject: [PATCH 2/4] add eventAdjustHook for kobo --- frontend/ui/inputevent.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index 98f622556..9d04b626f 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -268,7 +268,7 @@ function Input:init() self.event_map[10020] = "Charging" self.event_map[10021] = "NotCharging" - if util.isEmulated()==1 then + if util.isEmulated() == 1 then self:initKeyMap() os.remove("emu_event") os.execute("mkfifo emu_event") @@ -317,6 +317,16 @@ function Input:init() Device:setTouchInputDev("/dev/input/event1") input.open("/dev/input/event0") -- Light button and sleep slider print("Auto-detected Kobo") + function Input:eventAdjustHook(ev) + if ev.type == EV_ABS then + if ev.code == ABS_X then + ev.code = ABS_Y + elseif ev.code == ABS_Y then + ev.code = ABS_X + end + end + return ev + end elseif dev_mod == "Kindle4" then print(_("Auto-detected Kindle 4")) self:adjustKindle4EventMap() From 70178aaf57ab7f939dedc954ff9a1ad4cf497fc5 Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Thu, 13 Jun 2013 10:31:57 +0200 Subject: [PATCH 3/4] Fixed coordinates swapping and gesture detection. --- frontend/ui/gesturedetector.lua | 5 ----- frontend/ui/inputevent.lua | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index b08d75ae3..c58b3a93f 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -1,5 +1,4 @@ require "ui/geometry" -require "ui/device" GestureRange = { ges = nil, @@ -603,10 +602,6 @@ 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 diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index 9d04b626f..f29835c51 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -2,6 +2,7 @@ require "ui/event" require "ui/device" require "ui/time" require "ui/gesturedetector" +require "ui/geometry" -- constants from EV_SYN = 0 @@ -323,6 +324,7 @@ function Input:init() ev.code = ABS_Y elseif ev.code == ABS_Y then ev.code = ABS_X + ev.value = Screen.width - ev.value end end return ev From fc2d607d78c0f24b420d04416765ad3e56b96c4f Mon Sep 17 00:00:00 2001 From: Giorgio Micotti Date: Thu, 13 Jun 2013 11:32:49 +0200 Subject: [PATCH 4/4] Fixed Landscape input handling. --- frontend/ui/inputevent.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index f29835c51..95480d57c 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -323,8 +323,14 @@ function Input:init() if ev.code == ABS_X then ev.code = ABS_Y elseif ev.code == ABS_Y then - ev.code = ABS_X - ev.value = Screen.width - ev.value + ev.code = ABS_X + -- We always have to substract from the physical x, + -- regardless of the orientation + if (Screen.width