diff --git a/meta/hl.meta.lua b/meta/hl.meta.lua index 6e34ff344..1c4ce38ef 100644 --- a/meta/hl.meta.lua +++ b/meta/hl.meta.lua @@ -263,6 +263,7 @@ ---| "input.tablet.absolute_region_position" ---| "input.tablet.active_area_position" ---| "input.tablet.active_area_size" +---| "input.tablet.enabled" ---| "input.tablet.left_handed" ---| "input.tablet.output" ---| "input.tablet.region_position" @@ -1133,6 +1134,7 @@ hl = {} ---@field ['input.tablet.absolute_region_position'] boolean ---@field ['input.tablet.active_area_position'] HL.Vec2Like ---@field ['input.tablet.active_area_size'] HL.Vec2Like +---@field ['input.tablet.enabled'] boolean ---@field ['input.tablet.left_handed'] boolean ---@field ['input.tablet.output'] string ---@field ['input.tablet.region_position'] HL.Vec2Like diff --git a/src/config/values/ConfigValues.cpp b/src/config/values/ConfigValues.cpp index abf8ecab5..737e9ef71 100644 --- a/src/config/values/ConfigValues.cpp +++ b/src/config/values/ConfigValues.cpp @@ -331,7 +331,7 @@ std::vector> Values::getConfigValues() { MS("input:touchdevice:transform", "Transform the input from touchdevices.", 0, {.min = 0, .max = 6, .refresh = Supplementary::REFRESH_INPUT_DEVICES}), MS("input:touchdevice:output", "The monitor to bind touch devices.", "[[Auto]]", {.refresh = Supplementary::REFRESH_INPUT_DEVICES}), MS("input:touchdevice:enabled", "Whether input is enabled for touch devices.", true, {.refresh = Supplementary::REFRESH_INPUT_DEVICES}), - + MS("input:tablet:enabled", "enable/disable tablet input", true, {.refresh = Supplementary::REFRESH_INPUT_DEVICES}), /* * input:virtualkeyboard: */ diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index a2fec15c2..a72d8c53a 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -7,6 +7,10 @@ #include "../../protocols/PointerConstraints.hpp" #include "../../protocols/core/DataDevice.hpp" #include "../../event/EventBus.hpp" +#include "../../config/ConfigManager.hpp" +static bool isTabletEnabled(const SP& tab) { + return Config::mgr()->getDeviceInt(tab->m_hlName, "enabled", "input:tablet:enabled") != 0; +} static void unfocusTool(SP tool) { if (!tool->getSurface()) @@ -105,14 +109,17 @@ static Vector2D transformToActiveRegion(const Vector2D pos, const CBox activeAre return newPos; } - void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { + + const auto PTAB = e.tablet; + if (!isTabletEnabled(PTAB)) + return; + Event::SCallbackInfo info; Event::bus()->m_events.input.tablet.axis.emit(e, info); if (info.cancelled) return; - const auto PTAB = e.tablet; const auto PTOOL = ensureTabletToolPresent(e.tool); if (PTOOL->m_active && (e.updatedAxes & (CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X | CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_Y))) { @@ -176,12 +183,17 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { } void CInputManager::onTabletTip(CTablet::STipEvent e) { + + const auto PTAB = e.tablet; + + if (!isTabletEnabled(PTAB)) + return; + Event::SCallbackInfo info; Event::bus()->m_events.input.tablet.tip.emit(e, info); if (info.cancelled) return; - const auto PTAB = e.tablet; const auto PTOOL = ensureTabletToolPresent(e.tool); const auto POS = e.tip; @@ -204,6 +216,11 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) { } void CInputManager::onTabletButton(CTablet::SButtonEvent e) { + + const auto PTAB = e.tablet; + if (!isTabletEnabled(PTAB)) + return; + Event::SCallbackInfo info; Event::bus()->m_events.input.tablet.button.emit(e, info); if (info.cancelled) @@ -223,12 +240,16 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) { } void CInputManager::onTabletProximity(CTablet::SProximityEvent e) { + + const auto PTAB = e.tablet; + if (!isTabletEnabled(PTAB)) + return; + Event::SCallbackInfo info; Event::bus()->m_events.input.tablet.proximity.emit(e, info); if (info.cancelled) return; - const auto PTAB = e.tablet; const auto PTOOL = ensureTabletToolPresent(e.tool); PTOOL->m_active = e.in;