The Wacom 524C device triggers a kernel bug in the InRange and Invert handling. Every time BTN_TOUCH is set/unset the device also sets/unsets BTN_TOOL_PEN even when we nominally have the eraser in proximity.
The event sequence effectively looks like this:
# on prox in BTN_TOOL_RUBBER 1 -- SYN_REPORT --- # on tip down BTN_TOOL_PEN 1 BTN_TOUCH 1 -- SYN_REPORT --- # on tip up BTN_TOUCH 0 BTN_TOOL_PEN 0 -- SYN_REPORT --- # on prox out BTN_TOOL_RUBBER 1 -- SYN_REPORT ---
To work around this, bias our duplicate tool detection code towards the eraser - if we have an eraser in-prox already and the pen goes in-prox, ignore it and continue with the eraser. But if we have a pen in-prox and the eraser goes in-prox as well, force a prox-out for the pen and put the eraser in-prox.
Recording originally from https://github.com/linuxwacom/xf86-input-wacom/issues/186
This sits on top of !723 (merged), only the top commit matters here