Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ffi/framebuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This will be extended by implementations of this API.
--]]

local Blitbuffer = require("ffi/blitbuffer")
local logger = require("logger")

local fb = {
device = nil, -- points to a device object
Expand Down Expand Up @@ -454,7 +455,9 @@ end
function fb:setRotationMode(mode)
-- This, on the other hand, is responsible for the internal *buffer* rotation,
-- as such, it's inverted compared to the DEVICE_ROTATED_ constants; i.e., it's in 90° CCW steps).
self.bb:rotateAbsolute(-90 * (mode - self.native_rotation_mode - self.blitbuffer_rotation_mode))
local bb_rot = -90 * (mode - self.native_rotation_mode - self.blitbuffer_rotation_mode)
logger.dbg("AROT_DIAG base_fb:setRotationMode mode=", mode, "native=", self.native_rotation_mode, "bb_rot=", self.blitbuffer_rotation_mode, "computed=", bb_rot)
self.bb:rotateAbsolute(bb_rot)
if self.viewport then
self.full_bb:setRotation(self.bb:getRotation())
end
Expand Down
24 changes: 22 additions & 2 deletions ffi/framebuffer_android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local ffi = require("ffi")
local android = require("android")
local BB = require("ffi/blitbuffer")
local C = ffi.C
local logger = require("logger")

--[[ configuration for devices with an electric paper display controller ]]--

Expand Down Expand Up @@ -69,12 +70,28 @@ end

function framebuffer:getRotationMode()
if android.hasNativeRotation() then
return android.orientation.get()
local ao = android.orientation.get()
logger.dbg("AROT_DIAG framebuffer_android:getRotationMode ->", ao)
return ao
else
logger.dbg("AROT_DIAG framebuffer_android:getRotationMode ->", self.cur_rotation_mode, "(cached)")
return self.cur_rotation_mode
end
end

-- Android handles display rotation natively: the window buffer is already
-- rotated by SurfaceFlinger, and touch events arrive in display coordinates.
-- The BB is never rotated (setRotationMode only calls android.orientation.set),
-- so touch coordinates must not be transformed. Return 0 (UR) to skip the
-- translation in GestureDetector:adjustGesCoordinate / input:adjustTouchTranslate.
function framebuffer:getTouchRotation()
if android.hasNativeRotation() then
return 0
else
return framebuffer.parent.getTouchRotation(self)
end
end

function framebuffer:setRotationMode(mode)
if android.hasNativeRotation() then
local key
Expand All @@ -83,7 +100,10 @@ function framebuffer:setRotationMode(mode)
elseif mode == 2 then key = "REVERSE_PORTRAIT"
elseif mode == 3 then key = "REVERSE_LANDSCAPE" end
if key then
android.orientation.set(C["ASCREEN_ORIENTATION_" .. key])
local ao = C["ASCREEN_ORIENTATION_" .. key]
logger.dbg("AROT_DIAG framebuffer_android:setRotationMode mode=", mode, "key=", key, "ao=", ao)
android.orientation.set(ao)
self.cur_rotation_mode = mode
end
else
framebuffer.parent.setRotationMode(self, mode)
Expand Down