diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 045a96a80..7d4ada08c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -200,8 +200,8 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) { cfgValues["left_handed"].intValue = 0; cfgValues["scroll_method"].strValue = STRVAL_EMPTY; cfgValues["scroll_button"].intValue = 0; - cfgValues["touch_transform"].intValue = 0; - cfgValues["touch_output"].strValue = STRVAL_EMPTY; + cfgValues["transform"].intValue = 0; + cfgValues["output"].strValue = STRVAL_EMPTY; cfgValues["enabled"].intValue = 1; // only for mice / touchpads } @@ -298,6 +298,11 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s auto it = deviceConfigs.find(DEVICE); if (it->second.find(CONFIGVAR) == it->second.end()) { + if (it->second.contains("touch_output") || it->second.contains("touch_transform")) { + parseError = "touch_output and touch_transform have been changed to output and transform respectively"; + return; + } + parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field."; return; } @@ -1229,6 +1234,7 @@ void CConfigManager::loadConfigLoadVars() { g_pInputManager->setKeyboardLayout(); g_pInputManager->setPointerConfigs(); g_pInputManager->setTouchDeviceConfigs(); + g_pInputManager->setTabletConfigs(); } // Calculate the internal vars @@ -1534,6 +1540,7 @@ void CConfigManager::dispatchExecOnce() { g_pInputManager->setKeyboardLayout(); g_pInputManager->setPointerConfigs(); g_pInputManager->setTouchDeviceConfigs(); + g_pInputManager->setTabletConfigs(); // set ws names again for (auto& ws : g_pCompositor->m_vWorkspaces) { diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index d888b751d..e0d4d845e 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -551,6 +551,7 @@ std::string dispatchKeyword(std::string in) { g_pInputManager->setKeyboardLayout(); // update kb layout g_pInputManager->setPointerConfigs(); // update mouse cfgs g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs + g_pInputManager->setTabletConfigs(); // update tablets } if (COMMAND.contains("general:layout")) diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 417a9d068..881f677c7 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -253,6 +253,7 @@ struct STabletTool { struct STabletPad { wlr_tablet_v2_tablet_pad* wlrTabletPadV2 = nullptr; STablet* pTabletParent = nullptr; + wlr_input_device* pWlrDevice = nullptr; std::string name = ""; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index db883fea2..43fc66cfe 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1147,10 +1147,10 @@ void CInputManager::setTouchDeviceConfigs() { const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice); const int ROTATION = - std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7); + std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7); libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); - const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "touch_output") : g_pConfigManager->getString("input:touchdevice:output"); + const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "output") : g_pConfigManager->getString("input:touchdevice:output"); if (!OUTPUT.empty() && OUTPUT != STRVAL_EMPTY) PTOUCHDEV->boundOutput = OUTPUT; else @@ -1159,6 +1159,22 @@ void CInputManager::setTouchDeviceConfigs() { } } +void CInputManager::setTabletConfigs() { + for (auto& t : m_lTablets) { + const auto HASCONFIG = g_pConfigManager->deviceConfigExists(t.name); + + if (HASCONFIG) { + const auto OUTPUT = g_pConfigManager->getDeviceString(t.name, "output"); + const auto PMONITOR = g_pCompositor->getMonitorFromString(OUTPUT); + + if (PMONITOR) { + wlr_cursor_map_input_to_output(g_pCompositor->m_sWLRCursor, t.wlrDevice, PMONITOR->output); + wlr_cursor_map_input_to_region(g_pCompositor->m_sWLRCursor, t.wlrDevice, nullptr); + } + } + } +} + void CInputManager::destroyTouchDevice(STouchDevice* pDevice) { Debug::log(LOG, "Touch device at %x removed", pDevice); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 460b5ac2c..91783f38f 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -60,6 +60,7 @@ class CInputManager { void setKeyboardLayout(); void setPointerConfigs(); void setTouchDeviceConfigs(); + void setTabletConfigs(); void updateDragIcon(); void updateCapabilities(); diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 00cedb09e..10a850c5b 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -137,6 +137,8 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { } }, PNEWTABLET, "Tablet"); + + setTabletConfigs(); } STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) { @@ -176,6 +178,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { } PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice); + PNEWPAD->pWlrDevice = pDevice; PNEWPAD->hyprListener_Button.initCallback( &wlr_tablet_pad_from_input_device(pDevice)->events.button,