2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Merge pull request #1676 from chrox/kobo_touch_probe

fix #1608 by adding touch coordinates detection
This commit is contained in:
Qingping Hou 2015-10-18 01:07:24 -07:00
commit b6298d78d9
10 changed files with 105 additions and 4 deletions

View File

@ -38,7 +38,7 @@ UBUNTUTOUCH_SDL_DIR:=$(UBUNTUTOUCH_DIR)/ubuntu-touch-sdl
WIN32_DIR=$(PLATFORM_DIR)/win32
# files to link from main directory
INSTALL_FILES=reader.lua frontend resources defaults.lua datastorage.lua l10n \
INSTALL_FILES=reader.lua frontend resources defaults.lua datastorage.lua l10n utils \
git-rev README.md COPYING
# for gettext
@ -309,6 +309,7 @@ pot:
mkdir -p $(TEMPLATE_DIR)
$(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \
`find plugins -iname "*.lua"` \
`find utils -iname "*.lua"` \
> $(TEMPLATE_DIR)/$(DOMAIN).pot
# push source file to Transifex
$(MAKE) -i -C l10n bootstrap push

View File

@ -112,7 +112,7 @@ if G_reader_settings:readSetting("night_mode") then
Screen:toggleNightMode()
end
-- restore kobo frontlight settings
-- restore kobo frontlight settings and probe kobo touch coordinates
if Device:isKobo() then
local powerd = Device:getPowerDevice()
if powerd and powerd.restore_settings then
@ -121,6 +121,9 @@ if Device:isKobo() then
powerd:setIntensityWithoutHW(intensity)
-- powerd:setIntensity(intensity)
end
if Device:getCodeName() == "trilogy" then
require("utils/kobo_touch_probe")
end
end
if ARGV[argidx] and ARGV[argidx] ~= "" then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

97
utils/kobo_touch_probe.lua Executable file
View File

@ -0,0 +1,97 @@
-- touch probe utility
-- usage: ./luajit util/kobo_touch_probe.lua
require "defaults"
package.path = "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
local DocSettings = require("docsettings")
local _ = require("gettext")
-- read settings and check for language override
-- has to be done before requiring other files because
-- they might call gettext on load
G_reader_settings = DocSettings:open(".reader")
local lang_locale = G_reader_settings:readSetting("language")
if lang_locale then
_.changeLang(lang_locale)
end
local InputContainer = require("ui/widget/container/inputcontainer")
local CenterContainer = require("ui/widget/container/centercontainer")
local RightContainer = require("ui/widget/container/rightcontainer")
local OverlapGroup = require("ui/widget/overlapgroup")
local ImageWidget = require("ui/widget/imagewidget")
local TextWidget = require("ui/widget/textwidget")
local GestureRange = require("ui/gesturerange")
local UIManager = require("ui/uimanager")
local Blitbuffer = require("ffi/blitbuffer")
local Geom = require("ui/geometry")
local Device = require("device")
local Screen = require("device").screen
local Input = require("device").input
local Font = require("ui/font")
local DEBUG = require("dbg")
--DEBUG:turnOn()
local TouchProbe = InputContainer:new{
}
function TouchProbe:init()
self.ges_events = {
TapProbe = {
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
}
},
}
local image_widget = ImageWidget:new{
file = "resources/kobo-touch-probe.png",
}
self[1] = OverlapGroup:new{
dimen = Screen:getSize(),
CenterContainer:new{
dimen = Screen:getSize(),
TextWidget:new{
text = _("Tap the upper right corner"),
face = Font:getFace("cfont", 30),
},
},
RightContainer:new{
dimen = {
h = image_widget:getSize().h,
w = Screen:getSize().w,
},
image_widget,
},
}
end
function TouchProbe:onTapProbe(arg, ges)
--DEBUG("onTapProbe", ges)
local need_to_switch_xy = ges.pos.x < ges.pos.y
--DEBUG("Need to switch xy", need_to_switch_xy)
G_reader_settings:saveSetting("kobo_touch_switch_xy", need_to_switch_xy)
G_reader_settings:close()
if need_to_switch_xy then
Input:registerEventAdjustHook(Input.adjustTouchSwitchXY)
end
UIManager:quit()
end
-- if user has not set KOBO_TOUCH_MIRRORED yet
if KOBO_TOUCH_MIRRORED == nil then
local switch_xy = G_reader_settings:readSetting("kobo_touch_switch_xy")
-- and has no probe before
if switch_xy == nil then
UIManager:show(TouchProbe:new{})
UIManager:run()
-- otherwise, we will use probed result
else
KOBO_TOUCH_MIRRORED = switch_xy
end
end

View File

@ -3,8 +3,8 @@
require "defaults"
print(package.path)
package.path = "?.lua;common/?.lua;frontend/?.lua"
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so"
package.path = "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
package.cpath = "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
local DocSettings = require("docsettings")
local _ = require("gettext")