summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorStanislav Senotrusov <senotrusov@gmail.com>2025-09-13 01:11:30 +0200
committerGitHub <noreply@github.com>2025-09-13 01:11:30 +0200
commitadbf7c8663cfbc91fca78d3504fa8f73ce4bd23a (patch)
tree256109b294056eeda4d2f4ed3098a3c9493be9a1 /src/managers/input/InputManager.cpp
parent797bfe905e78ab04b03cd114e7330ff2e2ac76f9 (diff)
input: handle tablet active area scaling when axes swap due to rotation (#11661)
Some tablet rotation modes (90°, 270°, and flipped variants) swap the X and Y axes. This change adjusts the effective physical size based on axis orientation to ensure tablet active area coordinates are normalized correctly.
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index fa6acf15..ea164842 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1787,8 +1787,13 @@ void CInputManager::setTabletConfigs() {
const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(NAME, "active_area_size", "input:tablet:active_area_size");
const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(NAME, "active_area_position", "input:tablet:active_area_position");
if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) {
- t->m_activeArea = CBox{ACTIVE_AREA_POS.x / t->aq()->physicalSize.x, ACTIVE_AREA_POS.y / t->aq()->physicalSize.y,
- (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t->aq()->physicalSize.x, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t->aq()->physicalSize.y};
+ // Rotations with an odd index (90 and 270 degrees, and their flipped variants) swap the X and Y axes.
+ // Use swapped dimensions when the axes are rotated, otherwise keep the original ones.
+ const Vector2D effectivePhysicalSize = (ROTATION % 2) ? Vector2D{t->aq()->physicalSize.y, t->aq()->physicalSize.x} : t->aq()->physicalSize;
+
+ // Scale the active area coordinates into normalized space (0–1) using the effective dimensions.
+ t->m_activeArea = CBox{ACTIVE_AREA_POS.x / effectivePhysicalSize.x, ACTIVE_AREA_POS.y / effectivePhysicalSize.y,
+ (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / effectivePhysicalSize.x, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / effectivePhysicalSize.y};
}
}
}