Android: ignore touchscreen by user request (using a hardware key) (#5164)

* android: ignore touchscreen by user request (using a hardware key)
This commit is contained in:
Martín Fernández
2019-08-03 01:02:50 +02:00
committed by GitHub
parent ac15143c14
commit 10456169e5
4 changed files with 20 additions and 2 deletions

2
base

Submodule base updated: 6301277ce8...e6c9594186

View File

@@ -14,6 +14,7 @@ return {
[23] = "Press", -- DPAD_CENTER
[24] = "LPgBack", -- VOLUME_UP
[25] = "LPgFwd", -- VOLUME_DOWN
[27] = "Camera", -- CAMERA
[56] = ".", -- PERIOD
[59] = "Shift", -- SHIFT_LEFT
[60] = "Shift", -- SHIFT_RIGHT

View File

@@ -322,6 +322,23 @@ function Input:handleKeyBoardEv(ev)
return keycode
end
-- The hardware camera button is used in Android to toggle the touchscreen
if keycode == "Camera" and ev.value == EVENT_VALUE_KEY_RELEASE then
local isAndroid, android = pcall(require, "android")
if isAndroid then
-- toggle touchscreen behaviour
android.toggleTouchscreenIgnored()
-- show a toast with the new behaviour
if android.isTouchscreenIgnored() then
android.notification(_("Touchscreen disabled"))
else
android.notification(_("Touchscreen enabled"))
end
end
return
end
if keycode == "Power" then
-- Kobo generates Power keycode only, we need to decide whether it's
-- power-on or power-off ourselves.