summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp12
-rw-r--r--src/debug/HyprCtl.cpp2
-rw-r--r--src/helpers/WLClasses.hpp2
-rw-r--r--src/managers/input/InputManager.cpp7
-rw-r--r--src/managers/input/Tablets.cpp8
5 files changed, 25 insertions, 6 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 7925da64..f0af317a 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -478,6 +478,8 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("input:tablet:region_size", Hyprlang::VEC2{0, 0});
m_pConfig->addConfigValue("input:tablet:relative_input", Hyprlang::INT{0});
m_pConfig->addConfigValue("input:tablet:left_handed", Hyprlang::INT{0});
+ m_pConfig->addConfigValue("input:tablet:active_area_position", Hyprlang::VEC2{0, 0});
+ m_pConfig->addConfigValue("input:tablet:active_area_size", Hyprlang::VEC2{0, 0});
m_pConfig->addConfigValue("binds:pass_mouse_when_bound", Hyprlang::INT{0});
m_pConfig->addConfigValue("binds:scroll_event_delay", Hyprlang::INT{300});
@@ -554,10 +556,12 @@ CConfigManager::CConfigManager() {
m_pConfig->addSpecialConfigValue("device", "scroll_points", {STRVAL_EMPTY});
m_pConfig->addSpecialConfigValue("device", "transform", Hyprlang::INT{0});
m_pConfig->addSpecialConfigValue("device", "output", {STRVAL_EMPTY});
- m_pConfig->addSpecialConfigValue("device", "enabled", Hyprlang::INT{1}); // only for mice, touchpads, and touchdevices
- m_pConfig->addSpecialConfigValue("device", "region_position", Hyprlang::VEC2{0, 0}); // only for tablets
- m_pConfig->addSpecialConfigValue("device", "region_size", Hyprlang::VEC2{0, 0}); // only for tablets
- m_pConfig->addSpecialConfigValue("device", "relative_input", Hyprlang::INT{0}); // only for tablets
+ m_pConfig->addSpecialConfigValue("device", "enabled", Hyprlang::INT{1}); // only for mice, touchpads, and touchdevices
+ m_pConfig->addSpecialConfigValue("device", "region_position", Hyprlang::VEC2{0, 0}); // only for tablets
+ m_pConfig->addSpecialConfigValue("device", "region_size", Hyprlang::VEC2{0, 0}); // only for tablets
+ m_pConfig->addSpecialConfigValue("device", "relative_input", Hyprlang::INT{0}); // only for tablets
+ m_pConfig->addSpecialConfigValue("device", "active_area_position", Hyprlang::VEC2{0, 0}); // only for tablets
+ m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets
// keywords
m_pConfig->registerHandler(&::handleRawExec, "exec", {false});
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 211b532e..903b7d7f 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -657,7 +657,7 @@ std::string devicesRequest(eHyprCtlOutputFormat format, std::string request) {
}
for (auto& d : g_pInputManager->m_lTablets) {
- result += std::format("\tTablet at {:x}:\n\t\t{}\n", (uintptr_t)&d, d.name);
+ result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", (uintptr_t)&d, d.name, d.wlrTablet->width_mm, d.wlrTablet->height_mm);
}
for (auto& d : g_pInputManager->m_lTabletTools) {
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index a2e72282..dbe8d389 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -217,6 +217,8 @@ struct STablet {
std::string boundOutput = "";
+ CBox activeArea;
+
//
bool operator==(const STablet& b) const {
return wlrDevice == b.wlrDevice;
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 7d820c8f..94e6abec 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1438,6 +1438,13 @@ void CInputManager::setTabletConfigs() {
auto regionBox = CBox{REGION_POS.x, REGION_POS.y, REGION_SIZE.x, REGION_SIZE.y};
if (!regionBox.empty())
wlr_cursor_map_input_to_region(g_pCompositor->m_sWLRCursor, t.wlrDevice, regionBox.pWlr());
+
+ const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(t.name, "active_area_size", "input:tablet:active_area_size");
+ const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(t.name, "active_area_position", "input:tablet:active_area_position");
+ if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) {
+ t.activeArea = CBox{ACTIVE_AREA_POS.x / t.wlrTablet->width_mm, ACTIVE_AREA_POS.y / t.wlrTablet->height_mm,
+ (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t.wlrTablet->width_mm, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t.wlrTablet->height_mm};
+ }
}
}
}
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 387212c7..9252fca4 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -51,8 +51,14 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
if (PTAB->relativeInput)
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, dx, dy);
- else
+ else {
+ // Calculate transformations if active area is set
+ if (!PTAB->activeArea.empty()) {
+ x = (x - PTAB->activeArea.x) / (PTAB->activeArea.w - PTAB->activeArea.x);
+ y = (y - PTAB->activeArea.y) / (PTAB->activeArea.h - PTAB->activeArea.y);
+ }
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
+ }
g_pInputManager->simulateMouseMovement();
g_pInputManager->focusTablet(PTAB, EVENT->tool, true);