This commit is contained in:
Visal Vijay 2026-05-06 16:49:34 +01:00 committed by GitHub
commit 222f19b5e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 5 deletions

View file

@ -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

View file

@ -331,7 +331,7 @@ std::vector<SP<IValue>> Values::getConfigValues() {
MS<Int>("input:touchdevice:transform", "Transform the input from touchdevices.", 0, {.min = 0, .max = 6, .refresh = Supplementary::REFRESH_INPUT_DEVICES}),
MS<String>("input:touchdevice:output", "The monitor to bind touch devices.", "[[Auto]]", {.refresh = Supplementary::REFRESH_INPUT_DEVICES}),
MS<Bool>("input:touchdevice:enabled", "Whether input is enabled for touch devices.", true, {.refresh = Supplementary::REFRESH_INPUT_DEVICES}),
MS<Bool>("input:tablet:enabled", "enable/disable tablet input", true, {.refresh = Supplementary::REFRESH_INPUT_DEVICES}),
/*
* input:virtualkeyboard:
*/

View file

@ -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<CTablet>& tab) {
return Config::mgr()->getDeviceInt(tab->m_hlName, "enabled", "input:tablet:enabled") != 0;
}
static void unfocusTool(SP<CTabletTool> 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;