mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:05:59 +01:00
input: Add options to set tablet's active area (#5199)
* Add options to set tablet's active area * Set tablet's active area in `setTabletConfigs` * Fix formatting for new variables in ConfigManager * Report tablet's physical size with hyprctl
This commit is contained in:
parent
0dfdb6678f
commit
059e85ae69
5 changed files with 25 additions and 6 deletions
|
@ -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});
|
||||
|
@ -558,6 +560,8 @@ CConfigManager::CConfigManager() {
|
|||
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});
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -217,6 +217,8 @@ struct STablet {
|
|||
|
||||
std::string boundOutput = "";
|
||||
|
||||
CBox activeArea;
|
||||
|
||||
//
|
||||
bool operator==(const STablet& b) const {
|
||||
return wlrDevice == b.wlrDevice;
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue