# Forces a specific touchscreen to be classified as ID_INPUT_TOUCHSCREEN instead of # ID_INPUT_MOUSE. Installed to /etc/udev/rules.d/99-touchscreen-override.rules. # # THE PROBLEM this fixes: some cheap USB touch controllers implement single-touch by # emulating an absolute-position HID mouse (BTN_LEFT + ABS_X/ABS_Y) rather than a # proper HID digitizer (BTN_TOUCH). udev's stock 60-input-id rules (via the # `input_id` builtin) read those capability bits to decide ID_INPUT_TOUCHSCREEN vs. # ID_INPUT_MOUSE, and get it wrong for exactly this class of hardware — libinput then # hands sway a `type:pointer` device instead of `type:touch`, which is what # configs/sway/config's `input type:pointer {}` block degrades gracefully for. # # THE REAL FIX, not just a workaround: re-tag the specific device by its USB # vendor/product ID so udev (and therefore libinput, and therefore sway) treats it as # a genuine touchscreen — full multi-touch/wl_touch semantics, not the single-touch # click-drag ceiling of the type:pointer fallback. # # 99- (not 61- or similar): udev processes rule files in filename order, and the # ID_INPUT_* properties this needs to override are set by the *stock* rules around # priority 60 (60-input-id.rules / 60-persistent-input.rules, packaged with udev # itself). A rule that runs after them can overwrite what they set; one that runs # before cannot. 99 guarantees "after." # # SETUP — do this once real touch-panel hardware is chosen: # 1. Plug the touchscreen in, find its input event node: # ls -l /dev/input/by-id/ # or: libinput list-devices # 2. Get its USB vendor/product ID: # udevadm info -a /dev/input/eventN | grep -m1 -E 'idVendor|idProduct' # (walk up with -p if the input node itself has no idVendor/idProduct attrs — # udev's ATTRS{} match below walks the parent chain automatically either way) # 3. Replace the 0000/0000 placeholders below with the real values (lowercase hex, # no "0x" prefix — exactly as `udevadm info` prints them). # 4. udevadm control --reload-rules && udevadm trigger # 5. Confirm: `udevadm info /dev/input/eventN | grep ID_INPUT` should now show # ID_INPUT_TOUCHSCREEN=1 and no ID_INPUT_MOUSE=1. `swaymsg reload` afterward so # sway re-evaluates the device against configs/sway/config's `input type:touch` # block instead of `input type:pointer`. # # Ships as an inert template: 0000:0000 matches no real hardware, so this file does # nothing on an unconfigured image — the type:pointer fallback in configs/sway/config # is what makes an unconfigured (or not-yet-matched) touchscreen usable in the # meantime, not this file. SUBSYSTEM=="input", ATTRS{idVendor}=="0000", ATTRS{idProduct}=="0000", ENV{ID_INPUT_TOUCHSCREEN}="1", ENV{ID_INPUT_MOUSE}=""