From 76b58c38e71c3690fdd216667ad6fc7f0322e56b Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 14 May 2016 01:16:23 -0700 Subject: [PATCH 1/2] doc: update koreader naming convention in readme --- README.md | 10 +++++----- base | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7e1f6883..cb9098bca 100644 --- a/README.md +++ b/README.md @@ -103,19 +103,19 @@ brew install nasm binutils libtool autoconf automake sdl2 ``` A recent version of Android SDK/NDK and `ant` are needed in order to build -Koreader for Android devices. +KOReader for Android devices. ``` sudo apt-get install ant ``` -In order to build Koreader package for Ubuntu Touch, the `click` package management +In order to build KOReader package for Ubuntu Touch, the `click` package management tool is needed, Ubuntu users can install it with: ``` sudo apt-get install click ``` You might also need SDL library packages if you want to compile and run -Koreader on Linux PC. Fedora users can install `SDL` and `SDL-devel` package. +KOReader on Linux PC. Fedora users can install `SDL` and `SDL-devel` package. Ubuntu users probably need to install `libsdl2-dev` package: Getting the source @@ -179,7 +179,7 @@ If you want to compile the emulator for Windows run: ./kodev build win32 ``` -To run Koreader on your developing machine: +To run KOReader on your developing machine: ``` ./kodev run ``` @@ -218,7 +218,7 @@ Translation =========== Please refer to [l10n's README][l10n-readme] to grab the latest translations -from [the Koreader project on Transifex][koreader-transifex] with this command: +from [the KOReader project on Transifex][koreader-transifex] with this command: ``` make po ``` diff --git a/base b/base index 02ba8e107..8aef7200f 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 02ba8e1073de9b39c157e297e73a1e6e45d07552 +Subproject commit 8aef7200f14a2410d06042ba46fd4ceb1c179aad From 82a3e0f9ad9416119248f177a3dc7b2bcec79fc5 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 23 May 2016 22:38:08 -0700 Subject: [PATCH 2/2] automatically adjust ev time for kobo touch --- README.md | 4 +++ frontend/device/input.lua | 7 ---- frontend/device/kobo/device.lua | 38 ++++++++++++++++++++- kodev | 3 +- spec/unit/device_spec.lua | 60 +++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cb9098bca..1e2177ba6 100644 --- a/README.md +++ b/README.md @@ -190,11 +190,15 @@ To run unit tests: ./kodev test front ``` +NOTE: Extra dependencies for tests: busted and ansicolors from luarocks + To run Lua static analysis: ``` make static-check ``` +NOTE: Extra dependencies for tests: luacheck from luarocks + You may need to checkout the [travis config file][travis-conf] to setup up a proper testing environment. Briefly, you need to install `luarocks` and then install `busted` with `luarocks`. The "eng" language data file for diff --git a/frontend/device/input.lua b/frontend/device/input.lua index 016be3b90..4edccbac7 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -214,13 +214,6 @@ function Input:adjustTouchTranslate(ev, by) end end -function Input:adjustTouchAlyssum(ev) - ev.time = TimeVal:now() - if ev.type == EV_ABS and ev.code == ABS_MT_TRACKING_ID then - ev.value = ev.value - 1 - end -end - function Input:setTimeout(cb, tv_out) local item = { callback = cb, diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 84504fe6d..8f43f12da 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -1,4 +1,5 @@ local Generic = require("device/generic/device") +local TimeVal = require("ui/timeval") local Geom = require("ui/geometry") local dbg = require("dbg") @@ -26,6 +27,10 @@ local KoboTrilogy = Kobo:new{ model = "Kobo_trilogy", needsTouchScreenProbe = yes, touch_switch_xy = false, + -- Some Kobo Touch models' kernel does not generate touch event with epoch + -- timestamp. This flag will probe for those models and setup event adjust + -- hook accordingly + touch_probe_ev_epoch_time = true, hasKeys = yes, } @@ -133,6 +138,31 @@ function Kobo:init() end end +local probeEvEpochTime +-- this function will update itself after the first touch event +probeEvEpochTime = function(self, ev) + -- this check should work if the device has uptime less than 10 years + if ev.time.sec <= 315569260 then + -- time is seconds since boot, force it to epoch + probeEvEpochTime = function(_, _ev) + _ev.time = TimeVal:now() + end + probeEvEpochTime(nil, ev) + else + -- time is already epoch time, no need to do anything + probeEvEpochTime = function(_, _) end + end +end + +local ABS_MT_TRACKING_ID = 57 +local EV_ABS = 3 +local adjustTouchAlyssum = function(self, ev) + ev.time = TimeVal:now() + if ev.type == EV_ABS and ev.code == ABS_MT_TRACKING_ID then + ev.value = ev.value - 1 + end +end + function Kobo:initEventAdjustHooks() -- it's called KOBO_TOUCH_MIRRORED in defaults.lua, but what it -- actually did in its original implementation was to switch X/Y. @@ -153,7 +183,13 @@ function Kobo:initEventAdjustHooks() end if self.touch_alyssum_protocol then - self.input:registerEventAdjustHook(self.input.adjustTouchAlyssum) + self.input:registerEventAdjustHook(adjustTouchAlyssum) + end + + if self.touch_probe_ev_epoch_time then + self.input:registerEventAdjustHook(function(_, ev) + probeEvEpochTime(_, ev) + end) end if self.touch_phoenix_protocol then diff --git a/kodev b/kodev index 09e689d4b..70dd30ccb 100755 --- a/kodev +++ b/kodev @@ -321,7 +321,8 @@ OPTIONS: if [ ! -z "$2" ]; then test_path="${test_path}/$2" fi - busted --lua="./luajit ${opts}" \ + + busted --lua="./luajit" ${opts} \ --no-auto-insulate \ --lazy \ -o "./spec/$1/unit/verbose_print" \ diff --git a/spec/unit/device_spec.lua b/spec/unit/device_spec.lua index bfdc4b0ba..c45013008 100644 --- a/spec/unit/device_spec.lua +++ b/spec/unit/device_spec.lua @@ -15,7 +15,9 @@ describe("device module", function() end) describe("kobo", function() + local TimeVal setup(function() + TimeVal = require("ui/timeval") mock_fb = { new = function() return { @@ -63,6 +65,7 @@ describe("device module", function() kobo_dev:init() local Screen = kobo_dev.screen + kobo_dev.touch_probe_ev_epoch_time = false assert.is.same("Kobo_trilogy", kobo_dev.model) assert.truthy(kobo_dev:needsTouchScreenProbe()) G_reader_settings:saveSetting("kobo_touch_switch_xy", true) @@ -93,6 +96,63 @@ describe("device module", function() package.loaded['ffi/framebuffer_mxcfb'] = nil os.getenv:revert() mock_input.open:revert() + -- reset eventAdjustHook + kobo_dev.input.eventAdjustHook = function() end + kobo_dev.touch_probe_ev_epoch_time = true + end) + + it("should setup eventAdjustHooks properly for trilogy with non-epoch ev time", function() + local saved_getenv = os.getenv + stub(os, "getenv") + os.getenv.invokes(function(key) + if key == "PRODUCT" then + return "trilogy" + else + return saved_getenv(key) + end + end) + package.loaded['device/kobo/device'] = nil + package.loaded['ffi/framebuffer_mxcfb'] = mock_fb + mock_input = require('device/input') + stub(mock_input, "open") + + local kobo_dev = require("device/kobo/device") + kobo_dev:init() + local Screen = kobo_dev.screen + + assert.is.same("Kobo_trilogy", kobo_dev.model) + local x, y = Screen:getWidth()-5, 10 + local EV_ABS = 3 + local ABS_X = 00 + local ABS_Y = 01 + -- mirror x, then switch_xy + local ev_x = { + type = EV_ABS, + code = ABS_X, + value = x, + time = {sec = 1000} + } + local ev_y = { + type = EV_ABS, + code = ABS_Y, + value = y, + time = {sec = 1000} + } + + assert.truthy(kobo_dev.touch_probe_ev_epoch_time) + G_reader_settings:saveSetting("kobo_touch_switch_xy", true) + kobo_dev:touchScreenProbe() + + kobo_dev.input:eventAdjustHook(ev_x) + kobo_dev.input:eventAdjustHook(ev_y) + local cur_sec = TimeVal:now().sec + assert.truthy(cur_sec - ev_x.time.sec < 10) + assert.truthy(cur_sec - ev_y.time.sec < 10) + + package.loaded['ffi/framebuffer_mxcfb'] = nil + os.getenv:revert() + mock_input.open:revert() + kobo_dev.input.eventAdjustHook = function() end end) it("should flush book settings before suspend", function()