Merge pull request #2042 from koreader/houqp-master

automatically set proper ev timeval for kobo touch
pull/2032/head v2016.05.29-nightly
Huang Xin 8 years ago
commit e3ff96d108

@ -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
```
@ -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
@ -218,7 +222,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
```

@ -1 +1 @@
Subproject commit 02ba8e1073de9b39c157e297e73a1e6e45d07552
Subproject commit 8aef7200f14a2410d06042ba46fd4ceb1c179aad

@ -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,

@ -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

@ -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" \

@ -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()

Loading…
Cancel
Save