Using device name instead of ID for touchpad
* UDEV registers touch pad (e.g., Synaptic) with different IDs on reboots. Instead of hard-coding product/device IDs in config.h, use a string that appears in device name to identify it
This commit is contained in:
parent
51b2f68ba5
commit
cc8f7fb99c
@ -19,7 +19,8 @@ static const float fullscreen_bg[] = COLOR(0x121212ff);
|
|||||||
#define TAGCOUNT (9)
|
#define TAGCOUNT (9)
|
||||||
|
|
||||||
/* control variables */
|
/* control variables */
|
||||||
static int cfg_disable_touch_pad = 1;
|
static int cfg_disable_touchpad = 1;
|
||||||
|
static const char *cfg_touchpad_device_str = "Synaptic";
|
||||||
|
|
||||||
/* logging */
|
/* logging */
|
||||||
static int log_level = WLR_ERROR;
|
static int log_level = WLR_ERROR;
|
||||||
@ -94,15 +95,6 @@ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE
|
|||||||
*/
|
*/
|
||||||
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||||
|
|
||||||
/* Touch device information to filter touch events
|
|
||||||
* Use something like this to obtain info:
|
|
||||||
*
|
|
||||||
* root@host $ udevadm info --tree | grep -a5 Synaptic | grep -E "PRODUCT|NAME"
|
|
||||||
* │ │ ┆ E: PRODUCT=11/2(vendor)/7(product)/1b1
|
|
||||||
* │ │ ┆ E: NAME="SynPS/2 Synaptics TouchPad" */
|
|
||||||
static const uint32_t touch_device_vendor_id = 0x2;
|
|
||||||
static const uint32_t touch_device_product_id = 0x7;
|
|
||||||
|
|
||||||
/* You can choose between:
|
/* You can choose between:
|
||||||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
||||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
||||||
|
32
dwl.c
32
dwl.c
@ -1051,20 +1051,22 @@ createpointer(struct wlr_pointer *pointer)
|
|||||||
libinput_device_config_click_set_method (device, click_method);
|
libinput_device_config_click_set_method (device, click_method);
|
||||||
|
|
||||||
if (libinput_device_config_send_events_get_modes(device)) {
|
if (libinput_device_config_send_events_get_modes(device)) {
|
||||||
if ((cfg_disable_touch_pad)
|
const char *dev_name = libinput_device_get_name(device);
|
||||||
&& ((libinput_device_get_id_vendor(device) == touch_device_vendor_id)
|
if (strstr(dev_name, cfg_touchpad_device_str)) {
|
||||||
&& (libinput_device_get_id_product(device) == touch_device_product_id))) {
|
fprintf(stderr,"DWL::createpointer - %s device %s (%d:%d). Disable=%d\n",
|
||||||
|
cfg_touchpad_device_str,
|
||||||
|
libinput_device_get_name(device),
|
||||||
|
libinput_device_get_id_vendor(device),
|
||||||
|
libinput_device_get_id_product(device),
|
||||||
|
cfg_disable_touchpad);
|
||||||
|
touch_input_device = device; // Capture touchpad device
|
||||||
|
if (cfg_disable_touchpad) {
|
||||||
libinput_device_config_send_events_set_mode(device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
libinput_device_config_send_events_set_mode(device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
||||||
touch_input_device = device;
|
|
||||||
fprintf(stderr,"DWL::createpointer - Disable set to %d events for device %s (%d:%d) == %d:%d\n",
|
|
||||||
cfg_disable_touch_pad,
|
|
||||||
libinput_device_get_name(touch_input_device),
|
|
||||||
libinput_device_get_id_vendor(touch_input_device),
|
|
||||||
libinput_device_get_id_product(touch_input_device), touch_device_vendor_id, touch_device_product_id);
|
|
||||||
} else {
|
} else {
|
||||||
libinput_device_config_send_events_set_mode(device, send_events_mode);
|
libinput_device_config_send_events_set_mode(device, send_events_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (libinput_device_config_accel_is_available(device)) {
|
if (libinput_device_config_accel_is_available(device)) {
|
||||||
libinput_device_config_accel_set_profile(device, accel_profile);
|
libinput_device_config_accel_set_profile(device, accel_profile);
|
||||||
@ -2857,18 +2859,18 @@ tile(Monitor *m)
|
|||||||
|
|
||||||
void
|
void
|
||||||
toggle_touch_input_device(const Arg *arg) {
|
toggle_touch_input_device(const Arg *arg) {
|
||||||
if (cfg_disable_touch_pad) {
|
if (cfg_disable_touchpad) {
|
||||||
libinput_device_config_send_events_set_mode(touch_input_device, send_events_mode);
|
libinput_device_config_send_events_set_mode(touch_input_device, send_events_mode);
|
||||||
cfg_disable_touch_pad = 0;
|
cfg_disable_touchpad = 0;
|
||||||
} else {
|
} else {
|
||||||
libinput_device_config_send_events_set_mode(touch_input_device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
libinput_device_config_send_events_set_mode(touch_input_device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
||||||
cfg_disable_touch_pad = 1;
|
cfg_disable_touchpad = 1;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"DWL::toggle_touch_input_device - Disable set to %d events for device %s (%d:%d) == %d:%d\n",
|
fprintf(stderr,"DWL::toggle_touch_input_device - Disable set to %d events for device %s (%d:%d)\n",
|
||||||
cfg_disable_touch_pad,
|
cfg_disable_touchpad,
|
||||||
libinput_device_get_name(touch_input_device),
|
libinput_device_get_name(touch_input_device),
|
||||||
libinput_device_get_id_vendor(touch_input_device),
|
libinput_device_get_id_vendor(touch_input_device),
|
||||||
libinput_device_get_id_product(touch_input_device), touch_device_vendor_id, touch_device_product_id);
|
libinput_device_get_id_product(touch_input_device));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user