Skip to content

Commit df17991

Browse files
authored
input: Allow disabling touchscreen input (#4517)
* enable/disable touch device * ConfigManager: update documentation of 'enabled'
1 parent 791e1b9 commit df17991

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/config/ConfigManager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void CConfigManager::setDefaultVars() {
255255
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
256256
configValues["input:touchdevice:transform"].intValue = 0;
257257
configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
258+
configValues["input:touchdevice:enabled"].intValue = 1;
258259
configValues["input:tablet:transform"].intValue = 0;
259260
configValues["input:tablet:output"].strValue = STRVAL_EMPTY;
260261
configValues["input:tablet:region_position"].vecValue = Vector2D();
@@ -320,7 +321,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
320321
cfgValues["scroll_points"].strValue = STRVAL_EMPTY;
321322
cfgValues["transform"].intValue = 0;
322323
cfgValues["output"].strValue = STRVAL_EMPTY;
323-
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
324+
cfgValues["enabled"].intValue = 1; // only for mice, touchpads, and touchdevices
324325
cfgValues["region_position"].vecValue = Vector2D(); // only for tablets
325326
cfgValues["region_size"].vecValue = Vector2D(); // only for tablets
326327
cfgValues["relative_input"].intValue = 0; // only for tablets

src/managers/input/InputManager.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1460,12 +1460,16 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
14601460
}
14611461

14621462
void CInputManager::setTouchDeviceConfigs(STouchDevice* dev) {
1463-
14641463
auto setConfig = [&](STouchDevice* const PTOUCHDEV) -> void {
14651464
if (wlr_input_device_is_libinput(PTOUCHDEV->pWlrDevice)) {
14661465
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(PTOUCHDEV->pWlrDevice);
14671466

1468-
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "transform", "input:touchdevice:transform"), 0, 7);
1467+
const auto ENABLED = g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "enabled", "input:touchdevice:enabled");
1468+
const auto mode = ENABLED ? LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
1469+
if (libinput_device_config_send_events_get_mode(LIBINPUTDEV) != mode)
1470+
libinput_device_config_send_events_set_mode(LIBINPUTDEV, mode);
1471+
1472+
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "transform", "input:touchdevice:transform"), 0, 7);
14691473
if (libinput_device_config_calibration_has_matrix(LIBINPUTDEV))
14701474
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
14711475

0 commit comments

Comments
 (0)