diff options
| author | ppenguin <hieronymusv@gmail.com> | 2023-01-15 20:38:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-15 20:38:58 +0100 |
| commit | 040e99fd174e46614e9dc37a77bad67b930ac5e9 (patch) | |
| tree | 690a1cfb82422d9ac9d0924c1e3d6b6baee39161 /src/managers/input/InputManager.cpp | |
| parent | b5b436e01ddb5d5200f55be3deed8f4fade0574c (diff) | |
Add tablets calibration matrix for dynamic rotation with 2-in1/tablet PC usage (#1319)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index be148e89..d1f24884 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1144,23 +1144,6 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) { } void CInputManager::setTouchDeviceConfigs() { - // The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix` - static const float MATRICES[8][6] = {{// normal - 1, 0, 0, 0, 1, 0}, - {// rotation 90° - 0, -1, 1, 1, 0, 0}, - {// rotation 180° - -1, 0, 1, 0, -1, 1}, - {// rotation 270° - 0, 1, 0, -1, 0, 1}, - {// flipped - -1, 0, 1, 0, 1, 0}, - {// flipped + rotation 90° - 0, 1, 0, 1, 0, 0}, - {// flipped + rotation 180° - 1, 0, 0, 0, -1, 1}, - {// flipped + rotation 270° - 0, -1, 1, -1, 0, 1}}; for (auto& m : m_lTouchDevices) { const auto PTOUCHDEV = &m; @@ -1186,11 +1169,16 @@ 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 (wlr_input_device_is_libinput(t.wlrDevice)) { + const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(t.wlrDevice); - if (PMONITOR) { + const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(t.name, "transform") : g_pConfigManager->getInt("input:tablet:transform"), 0, 7); + Debug::log(LOG, "Setting calibration matrix for device %s", t.name); + libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); + + const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(t.name, "output") : g_pConfigManager->getString("input:tablet:output"); + const auto PMONITOR = g_pCompositor->getMonitorFromString(OUTPUT); + if (!OUTPUT.empty() && OUTPUT != STRVAL_EMPTY && 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); } |
