Remap Stylus Buttons

Has anyone found a way to remap stylus buttons on Ubuntu? Most solutions I’ve found rely on a known tablet to be connected to the laptop to be able to remap that specific tablets stylus, but won’t work if you’re just using a stylus with the laptop screen itself.

I’m using the Lenovo Precision Pen 2 right now and the best solution I’ve found is to use a really janky input switcher on the stylus buttons but surely there’s a better way?

Having the same issue with an old Microsoft surface pen on Fedora with KDE Plasma. There’s some options in KDE that say they remap the stylus buttons, but that doesn’t actually seem to do anything. Put both buttons on right click but still only getting left clicks. Eraser works as it should, at least.

All the remapping software I can find are frustrating in one way or another… I’m close to buckling down and learning how to code some garbage myself to fix it.