I’m not too familiar with this stuff, but I did some testing with the evtest command (on Fedora, with both buttons set to program defined)
If you run this command:
sudo evtest | grep 'BTN'
You get this output when clicking the lower button and then the upper button:
Event: time 1761530637.481570, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 1
Event: time 1761530638.632265, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 0
Event: time 1761530638.635799, type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value 1
Event: time 1761530638.797510, type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value 0
Event: time 1761530638.800958, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 1
Event: time 1761530640.479012, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 1
Event: time 1761530640.613979, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 0
Event: time 1761530641.525806, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 0
It seems that the lower button is always set to eraser for some reason. Not sure how to fix it, but just wanted to put it here anyway