Can't configure stylus buttons

Specs:

  • Arch Linux (KDE, Plasma)
  • Framework 12
  • Framework Stylus

The buttons on my stylus don’t remap correctly.
When I go to Settings->Drawing Tablet->Pen and change the buttons to Right-Click for Lower and Middle-Click for Upper, the lower button either doesn’t change or does nothing and the upper button uses the lower button mapping.
I’ve tried other mappings and it does the same.

Also, yes I’ve looked else-where and no I haven’t found any solutions or otherwise.

1 Like

Exact same issue here on Fedora (GNOME) which makes me think it’s an issue with kernel support for the pen. I’ve only tried it on USI 2.0, but I hear linux has solid mpp support too, and the pen can communicate both I believe. I’ll try changing the option later and see what happens

2 Likes

Ive tried changing that in BIOS, it didn’t seem to effect anything.
I’m waiting for a response from framework support also, they had me run some tests and are looking through some logs I sent them.

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

1 Like

Oh, yeah, that looks like it can be programmed!

Only, would need the full output. | grep 'BTN' is suppressing the line you need, which comes right before.

$ sudo evtest | grep -B 1 'ENTER'
Event: time 1761531282.885687, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1c
Event: time 1761531282.885687, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0

The line with (MSC_SCAN), value 1c, you need that value, the “1c” in this example.

I remap a bunch of keys on my keyboard using that. Provided the stylus keys have a unique value, I believe you could assign them to anything you wish.

Could you, or anyone else interested, do
sudo evtest | grep -B 1 'BTN'
And what keyboard keys or mouse keys would you like the stylus keys to be?

Looks like it’s doing the same for me, it’s always set to BTN_TOOL_RUBBER
I’ll pass this on to the support ticket I have open to see if that helps them figure out why this is.

Can you do
sudo evtest | grep -B 1 'BTN'
and give the output?

How to change the key function would come after. What keyboard or mouse keys would you like them to be?

--
Event: time 1761533141.415430, -------------- SYN_REPORT ------------
Event: time 1761533141.419434, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 0
--
Event: time 1761533141.419444, -------------- SYN_REPORT ------------
Event: time 1761533141.422848, type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value 1
--
Event: time 1761533141.670594, -------------- SYN_REPORT ------------
Event: time 1761533141.674592, type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value 0
--
Event: time 1761533141.674602, -------------- SYN_REPORT ------------
Event: time 1761533141.678120, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 1
--
Event: time 1761533142.402831, -------------- SYN_REPORT ------------
Event: time 1761533142.406070, type 1 (EV_KEY), code 320 (BTN_TOOL_PEN), value 0
^C

I’d like them to be mouse middle and right click

1 Like

No MSC_SCAN value. :grimacing:
I’m afraid that all the keys I remap are done using the scancode value.

Ah, didn’t know what part of the output you wanted. It does give MSC_SCAN for the upper button I have set to g for testing:

Event: time 1761533129.709155, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0044
Event: time 1761533129.709155, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 1
g--
Event: time 1761533129.844179, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0044
Event: time 1761533129.844179, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 0
--
Event: time 1761533133.807725, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0044
Event: time 1761533133.807725, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 1
g--
Event: time 1761533133.972881, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0044
Event: time 1761533133.972881, type 1 (EV_KEY), code 331 (BTN_STYLUS), value 0
--
1 Like

Oh, they do have scancodes! The sun, it reappears! :sun_behind_small_cloud:

Can you give the codes for the other keys?

I’ll go look at my notes on how remapping is done.

What do you mean by other keys? Which ones?

BTN_TOOL_RUBBER, and BTN_TOOL_PEN.

Aren’t they in the first log I posted?

Not the line with the scancodes. The line needed says (MSC_SCAN) value XXXXX. The Xs is the scancode.

I’m not sure it gives those RUBBER and PEN

Well, you should be able to map the one which does provide a scancode at least.

Place the following into /etc/udev/hwdb.d/90-FWL12_stylus_buttons.hwdb

# Framework Laptop 12 - map stylus keys - https://community.frame.work/t/-/76815
evdev:atkbd:*FrameworkLaptop12*
 KEYBOARD_KEY_d0044=btn_middle
 #KEYBOARD_KEY_XXXXX=btn_right
 #KEYBOARD_KEY_XXXXX=f23

after charges, rebuild database with
sudo udevadm hwdb --update && sudo udevadm trigger --sysname-match="event*"

Or, use a one-liner to do it all in one go:

sudo echo -e "# Framework Laptop 12 - map stylus keys\r\nevdev:atkbd:*FrameworkLaptop12*\r\n KEYBOARD_KEY_d0044=btn_middle\r\n #KEYBOARD_KEY_XXXXX=btn_right\r\n #KEYBOARD_KEY_XXXXX=f23" >> /etc/udev/hwdb.d/90-FWL12_stylus_buttons.hwdb && sleep 5 && sudo udevadm hwdb --update && sudo udevadm trigger --sysname-match="event*"

Oh wait, the one that does show a scancode I can map normally.
It’s the lower button (closest to tip) that refuses to change

I’m running into the same issue. The bottom button is fixed as eraser, and KDE Plasma only “sees” the top button and only lets you reassign that one. It seems that this is a longer-standing issue with styluses on Linux:

I don’t know whether the Framework Stylus is actually sending the bottom button as an “eraser” button or as a regular button. But in `evtest` I see events for an eraser (rubber) button when I press it.

1 Like

The most resent reply I’ve got from fw support says something similar, check quote below.

Essentially both buttons should be remappable in software. In firmware, both buttons have a defined default purpose (lower being eraser and upper being right click), but the upper button is also visible as “BTN_STYLUS” while the lower button’s inputs are always seen as eraser before going through whatever is remapping them.

They also said if it’s not a fw bug, it will be a kde/linux bug, I’m waiting for a reply from them doing testing.

1 Like