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/inputevent.lua b/frontend/ui/inputevent.lua index 6c3688519..95480d57c 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 @@ -18,6 +19,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 @@ -263,7 +269,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") @@ -271,9 +277,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 +313,28 @@ 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") + 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 + -- We always have to substract from the physical x, + -- regardless of the orientation + if (Screen.width