mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
788ccac561
* Get rid of the `canToggleGSensor` Device cap, it's now mandatory for `hasGSensor` devices. (This means Kindles can now toggle the gyro, fix #9136).
* This also means that `Device:toggleGSensor` is now implemented by `Generic`.
* Update the Screen & Gyro rotation constants to be clearer (c.f., https://github.com/koreader/koreader-base/pull/1568) (/!\ This might conceivably break some `rotation_map` user-patches).
* Input: Move the platform-specific gyro handling to Device implementations, and let Input only handle a single, custom protocol (`EV_MSC:MSC_GYRO`).
* Input: Refine the `rotation_map` disable method implemented in 43b021d37c
. Instead of directly poking at the internal field, use a new method, `disableRotationMap` (/!\ Again, this might break some `rotation_map` user-patches).
* Input: Minor tweaks to event adjust hooks to make them more modular, allowing the Kobo implementation to build and use a single composite hook. API compatibility maintained with wrappers.
56 lines
2.7 KiB
Lua
56 lines
2.7 KiB
Lua
describe("gesturedetector module", function()
|
|
local GestureDetector
|
|
setup(function()
|
|
require("commonrequire")
|
|
GestureDetector = require("device/gesturedetector")
|
|
end)
|
|
|
|
describe("adjustGesCoordinate", function()
|
|
local function adjustTest(ges_type, direction, rotation_mode)
|
|
local ges = {
|
|
ges = ges_type,
|
|
direction = direction,
|
|
multiswipe_directions = direction,
|
|
}
|
|
GestureDetector.screen = {
|
|
DEVICE_ROTATED_UPRIGHT = 0,
|
|
DEVICE_ROTATED_CLOCKWISE = 1,
|
|
DEVICE_ROTATED_UPSIDE_DOWN = 2,
|
|
DEVICE_ROTATED_COUNTER_CLOCKWISE = 3,
|
|
}
|
|
GestureDetector.screen.getTouchRotation = function() return rotation_mode end
|
|
|
|
return GestureDetector:adjustGesCoordinate(ges).direction
|
|
end
|
|
|
|
it("should not translate rotation 0", function()
|
|
assert.are.equal("north", adjustTest("swipe", "north", 0))
|
|
assert.are.equal("north", adjustTest("multiswipe", "north", 0))
|
|
assert.are.equal("north", adjustTest("pan", "north", 0))
|
|
assert.are.equal("north", adjustTest("two_finger_swipe", "north", 0))
|
|
assert.are.equal("north", adjustTest("two_finger_pan", "north", 0))
|
|
end)
|
|
it("should translate rotation 270", function()
|
|
assert.are.equal("west", adjustTest("swipe", "north", 3))
|
|
assert.are.equal("west", adjustTest("multiswipe", "north", 3))
|
|
assert.are.equal("west", adjustTest("pan", "north", 3))
|
|
assert.are.equal("west", adjustTest("two_finger_swipe", "north", 3))
|
|
assert.are.equal("west", adjustTest("two_finger_pan", "north", 3))
|
|
end)
|
|
it("should translate rotation 180", function()
|
|
assert.are.equal("south", adjustTest("swipe", "north", 2))
|
|
assert.are.equal("south", adjustTest("multiswipe", "north", 2))
|
|
assert.are.equal("south", adjustTest("pan", "north", 2))
|
|
assert.are.equal("south", adjustTest("two_finger_swipe", "north", 2))
|
|
assert.are.equal("south", adjustTest("two_finger_pan", "north", 2))
|
|
end)
|
|
it("should translate rotation 90", function()
|
|
assert.are.equal("east", adjustTest("swipe", "north", 1))
|
|
assert.are.equal("east", adjustTest("multiswipe", "north", 1))
|
|
assert.are.equal("east", adjustTest("pan", "north", 1))
|
|
assert.are.equal("east", adjustTest("two_finger_swipe", "north", 1))
|
|
assert.are.equal("east", adjustTest("two_finger_pan", "north", 1))
|
|
end)
|
|
end)
|
|
end)
|