@ -984,39 +984,37 @@ end
--- (Translation should be done via registerEventAdjustHook in Device implementations).
--- (Translation should be done via registerEventAdjustHook in Device implementations).
--- This needs to be called *via handleGyroEv* in a handleMiscEv implementation (c.f., Kobo, Kindle or PocketBook).
--- This needs to be called *via handleGyroEv* in a handleMiscEv implementation (c.f., Kobo, Kindle or PocketBook).
function Input : handleMiscGyroEv ( ev )
function Input : handleMiscGyroEv ( ev )
local rotation _mode, screen_mode
local rotation
if ev.value == C.DEVICE_ROTATED_UPRIGHT then
if ev.value == C.DEVICE_ROTATED_UPRIGHT then
-- i.e., UR
-- i.e., UR
rotation_mode = framebuffer.DEVICE_ROTATED_UPRIGHT
rotation = framebuffer.DEVICE_ROTATED_UPRIGHT
screen_mode = " portrait "
elseif ev.value == C.DEVICE_ROTATED_CLOCKWISE then
elseif ev.value == C.DEVICE_ROTATED_CLOCKWISE then
-- i.e., CW
-- i.e., CW
rotation_mode = framebuffer.DEVICE_ROTATED_CLOCKWISE
rotation = framebuffer.DEVICE_ROTATED_CLOCKWISE
screen_mode = " landscape "
elseif ev.value == C.DEVICE_ROTATED_UPSIDE_DOWN then
elseif ev.value == C.DEVICE_ROTATED_UPSIDE_DOWN then
-- i.e., UD
-- i.e., UD
rotation_mode = framebuffer.DEVICE_ROTATED_UPSIDE_DOWN
rotation = framebuffer.DEVICE_ROTATED_UPSIDE_DOWN
screen_mode = " portrait "
elseif ev.value == C.DEVICE_ROTATED_COUNTER_CLOCKWISE then
elseif ev.value == C.DEVICE_ROTATED_COUNTER_CLOCKWISE then
-- i.e., CCW
-- i.e., CCW
rotation_mode = framebuffer.DEVICE_ROTATED_COUNTER_CLOCKWISE
rotation = framebuffer.DEVICE_ROTATED_COUNTER_CLOCKWISE
screen_mode = " landscape "
else
else
-- Discard FRONT/BACK
-- Discard FRONT/BACK
return
return
end
end
local old_rotation _mode = self.device . screen : getRotationMode ( )
local old_rotation = self.device . screen : getRotationMode ( )
if self.device : isGSensorLocked ( ) then
if self.device : isGSensorLocked ( ) then
local old_screen_mode = self.device . screen : getScreenMode ( )
local matching_orientation = bit.band ( rotation , 1 ) == bit.band ( old_rotation , 1 )
if rotation _mode and rotation_mode ~= old_rotation_mode and screen_mode == old_screen_mode then
if rotation and rotation ~= old_rotation and matching_orientation then
-- Cheaper than a full SetRotationMode event, as we don't need to re-layout anything.
-- Cheaper than a full SetRotationMode event, as we don't need to re-layout anything.
self.device . screen : setRotationMode ( rotation _mode )
self.device . screen : setRotationMode ( rotation )
UIManager : onRotation ( )
UIManager : onRotation ( )
end
end
else
else
if rotation_mode and rotation_mode ~= old_rotation_mode then
if rotation and rotation ~= old_rotation then
return Event : new ( " SetRotationMode " , rotation_mode )
-- NOTE: We do *NOT* send a broadcast manually, and instead rely on the main loop's sendEvent:
-- this ensures that only widgets that actually know how to handle a rotation will do so ;).
return Event : new ( " SetRotationMode " , rotation )
end
end
end
end
end
end