mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
More robust Gyro toggle (#5104)
* Make toggling Gyro events more robust Actually ask to turn it on/off depending on the setting, instead of a blind toggle A quick succession of suspend/resume events could otherwise leave it in an unexpected state (i.e., off when it should have been on).
This commit is contained in:
@@ -696,14 +696,29 @@ function Input:handleMiscEvNTX(ev)
|
||||
end
|
||||
|
||||
-- Allow toggling it at runtime
|
||||
function Input:toggleMiscEvNTX()
|
||||
if self.isNTXAccelHooked then
|
||||
self.handleMiscEv = function() end
|
||||
function Input:toggleMiscEvNTX(toggle)
|
||||
if toggle and toggle == true then
|
||||
-- Honor Gyro events
|
||||
if not self.isNTXAccelHooked then
|
||||
self.handleMiscEv = self.handleMiscEvNTX
|
||||
self.isNTXAccelHooked = true
|
||||
end
|
||||
elseif toggle and toggle == false then
|
||||
-- Ignore Gyro events
|
||||
if self.isNTXAccelHooked then
|
||||
self.handleMiscEv = function() end
|
||||
self.isNTXAccelHooked = false
|
||||
end
|
||||
else
|
||||
self.handleMiscEv = self.handleMiscEvNTX
|
||||
end
|
||||
-- Toggle it
|
||||
if self.isNTXAccelHooked then
|
||||
self.handleMiscEv = function() end
|
||||
else
|
||||
self.handleMiscEv = self.handleMiscEvNTX
|
||||
end
|
||||
|
||||
self.isNTXAccelHooked = not self.isNTXAccelHooked
|
||||
self.isNTXAccelHooked = not self.isNTXAccelHooked
|
||||
end
|
||||
end
|
||||
|
||||
-- helpers for touch event data management:
|
||||
|
||||
Reference in New Issue
Block a user