diff options
| author | clamydo <13063485+clamydo@users.noreply.github.com> | 2025-02-09 15:30:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-09 15:30:30 +0100 |
| commit | 56f6f61596a547cdcdfb7aa7c3550e380b487ee3 (patch) | |
| tree | 8320ba5e508716e75721d435a67218510725df1c /src/managers/input/Tablets.cpp | |
| parent | 8e10ddb592977ef2e1836e75b0e5550ba8fb56f0 (diff) | |
tablet: take `active_area_size` into account when sending tip event (#9325)
* fixes #9322, take `active_area_size` into account when sending tip event
* check if `relative_input` is set
As suggested by @y47s5s68tq870r7tc1xpp755pabopg
* refactoring active area in own function to keep it DRY
* coding style
* making transformation static
---------
Co-authored-by: clamydo <clamydo@users.noreply.github.com>
Diffstat (limited to 'src/managers/input/Tablets.cpp')
| -rw-r--r-- | src/managers/input/Tablets.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 0952a7d4..e1a2f2aa 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -88,6 +88,20 @@ static void refocusTablet(SP<CTablet> tab, SP<CTabletTool> tool, bool motion = f PROTO::tablet->motion(tool, local); } +static Vector2D transformToActiveRegion(const Vector2D pos, const CBox activeArea) { + auto newPos = pos; + + //Calculate transformations if active area is set + if (!activeArea.empty()) { + if (!std::isnan(pos.x)) + newPos.x = (pos.x - activeArea.x) / (activeArea.w - activeArea.x); + if (!std::isnan(pos.y)) + newPos.y = (pos.y - activeArea.y) / (activeArea.h - activeArea.y); + } + + return newPos; +} + void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { const auto PTAB = e.tablet; const auto PTOOL = ensureTabletToolPresent(e.tool); @@ -113,16 +127,9 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { if (PTAB->relativeInput) g_pPointerManager->move(delta); - else { - //Calculate transformations if active area is set - if (!PTAB->activeArea.empty()) { - if (!std::isnan(x)) - x = (x - PTAB->activeArea.x) / (PTAB->activeArea.w - PTAB->activeArea.x); - if (!std::isnan(y)) - y = (y - PTAB->activeArea.y) / (PTAB->activeArea.h - PTAB->activeArea.y); - } - g_pPointerManager->warpAbsolute({x, y}, PTAB); - } + else + g_pPointerManager->warpAbsolute(transformToActiveRegion({x, y}, PTAB->activeArea), PTAB); + break; } } @@ -160,7 +167,12 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) { const auto PTAB = e.tablet; const auto PTOOL = ensureTabletToolPresent(e.tool); const auto POS = e.tip; - g_pPointerManager->warpAbsolute(POS, PTAB); + + if (PTAB->relativeInput) + g_pPointerManager->move({0, 0}); + else + g_pPointerManager->warpAbsolute(transformToActiveRegion(POS, PTAB->activeArea), PTAB); + refocusTablet(PTAB, PTOOL, true); if (e.in) |
