Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pen button mappings do not work as expected #1250

Open
1over137 opened this issue Oct 11, 2024 · 8 comments
Open

Pen button mappings do not work as expected #1250

1over137 opened this issue Oct 11, 2024 · 8 comments
Labels
input input related issues

Comments

@1over137
Copy link

1over137 commented Oct 11, 2024

Describe the bug
By default, I have my button 1 mapped to eraser toggle, and button 2 to selection. However, as soon as I use either the shape or text tool, the mapping is changed to toggling that instead. The mapping options in the UI has no effect. The only way I can get my eraser back is by resetting all the data associated with rnote (rm -rf .var/app/com.github.flxzt.rnote/).

To Reproduce
Steps to reproduce the behavior:

  1. Set button 1 to eraser
  2. Use the shape tool
  3. Draw again
  4. Press the button and observe that it is now toggling the shape tool.

Expected behavior
The mapping should not change just by using a tool

Console Output
Run the app in the terminal with flatpak --env=RUST_LOG=rnote=debug --env=RUST_BACKTRACE=1 run com.github.flxzt.rnote
and post the output.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Flatpak, Rnote 0.11.0, Gentoo running GNOME Wayland

X1 yoga 6th gen. Same result with both the built-in pen and an external Wacom AES pen.

@Doublonmousse
Copy link
Collaborator

Is the mapping done inside rnote or inside the gnome pen settings ?

Can you share a screenshot of the settings page ?

Might be related to #1104 (if a button is seen as an eraser, what's currently in the settings will have no effect and you'll have to keep the eraser pressed, draw, change the tool to the one you want then release the button currently). I have a PR to have this editable in the settings page (and also lock the mode of the eraser)

@Doublonmousse Doublonmousse added the input input related issues label Oct 12, 2024
@1over137
Copy link
Author

1over137 commented Oct 12, 2024

This is a strange thing. I couldn't reproduce it at all yesterday, but today it happened again with both pens.

Interestingly it does not happen for the second (top) button, which stays normal, only the lower one (mapped to eraser) breaks.

All settings are just defaults. Gnome's pen button maps only to mouse buttons.
Screenshot from 2024-10-12 08-13-52
Screenshot from 2024-10-12 08-13-01

I did some further digging and I noticed that it is not necessary to delete the whole folder, only this file: glib-2.0/settings/keyfile:
The broken version has the following content

[com/github/flxzt/rnote]
active-stroke-color=(0.64399999380111694, 0.11299999803304672, 0.17499999701976776, 1.0)
active-fill-color=(0.0, 0.0, 0.0, 0.0)
engine-config='{"document":{"x":0.0,"y":0.0,"width":2200.0,"height":70452.691,"format":{"width":2200.0,"height":1633.0,"dpi":192.0,"orientation":"landscape","border_color":{"r":0.871,"g":0.867,"b":0.855,"a":1.0},"show_borders":true,"show_origin_indicator":true},"background":{"color":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"pattern":"none","pattern_size":[37.0,34.0],"pattern_color":{"r":0.8,"g":0.9,"b":1.0,"a":1.0}},"layout":"continuous_vertical","snap_positions":false},"pens_config":{"brush_config":{"builder_type":"modeled","style":"solid","marker_options":{"stroke_width":12.0,"stroke_color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"fill_color":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"pressure_curve":"const"},"solid_options":{"stroke_width":5.0,"stroke_color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"fill_color":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"pressure_curve":"linear"},"textured_options":{"seed":5174676337856650925,"stroke_width":6.0,"stroke_color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"density":5.0,"distribution":"Normal","pressure_curve":"linear"}},"shaper_config":{"builder_type":"line","style":"smooth","smooth_options":{"stroke_width":2.0,"stroke_color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"fill_color":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"pressure_curve":"linear"},"rough_options":{"stroke_color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"stroke_width":2.4,"fill_color":{"r":0.0,"g":0.0,"b":0.0,"a":0.0},"fill_style":"hachure","hachure_angle":-0.716,"seed":22433579972408199},"constraints":{"enabled":false,"ratios":["one_to_one","horizontal","vertical"]}},"typewriter_config":{"text_style":{"font_family":"serif","font_size":32.0,"font_weight":500,"font_style":"regular","color":{"r":0.644,"g":0.113,"b":0.175,"a":1.0},"max_width":null,"alignment":"start","ranged_text_attributes":[]},"text_width":600.0},"eraser_config":{"width":12.0,"style":"trash_colliding_strokes"},"selector_config":{"style":"rectangle","resize_lock_aspectratio":false},"tools_config":{"style":"verticalspace"}},"penholder":{"shortcuts":{"mouse_secondary_button":{"change_pen_style":{"style":"shaper","mode":"temporary"}},"stylus_primary_button":{"change_pen_style":{"style":"eraser","mode":"temporary"}},"drawing_pad_button_1":{"change_pen_style":{"style":"shaper","mode":"permanent"}},"drawing_pad_button_2":{"change_pen_style":{"style":"typewriter","mode":"permanent"}},"drawing_pad_button_0":{"change_pen_style":{"style":"brush","mode":"permanent"}},"drawing_pad_button_3":{"change_pen_style":{"style":"eraser","mode":"permanent"}},"stylus_secondary_button":{"change_pen_style":{"style":"selector","mode":"temporary"}},"touch_two_finger_long_press":{"change_pen_style":{"style":"eraser","mode":"toggle"}},"keyboard_ctrl_space":{"change_pen_style":{"style":"tools","mode":"toggle"}}},"pen_mode_state":{"pen_mode":"pen","penmode_pen_style":"eraser","penmode_eraser_style":"eraser"}},"import_prefs":{"pdf_import_prefs":{"page_width_perc":50.0,"page_spacing":"continuous","pages_type":"vector","bitmap_scalefactor":1.8,"page_borders":true,"adjust_document":true},"xopp_import_prefs":{"pages_type":96.0}},"export_prefs":{"doc_export_prefs":{"with_background":true,"with_pattern":true,"optimize_printing":false,"export_format":"pdf","page_order":"row_major"},"doc_pages_export_prefs":{"with_background":true,"with_pattern":true,"optimize_printing":false,"export_format":"svg","page_order":"row_major","bitmap_scalefactor":1.8,"jpg_quality":85},"selection_export_prefs":{"with_background":true,"with_pattern":false,"optimize_printing":false,"export_format":"svg","bitmap_scalefactor":1.8,"jpg_quality":85,"margin":12.0}},"pen_sounds":false,"optimize_epd":false}'
is-maximized=true
workspace-list=[(b'/home/<username>', 'folder-symbolic', 442479871, 'default')]
selected-workspace-index=0
window-width=800
window-height=600
sidebar-show=false

@Doublonmousse
Copy link
Collaborator

Actually your first button on your stylus buttons does NOT act as a button but as a separate pen entirely when pressed (seen as an eraser most likely. Hence from the OS pov and rnote when you press it it detects an entirely different device !). Indeed

  • You have two pens listed
  • What you probably change by removing the file is this :
        "pen_mode_state": {
            "pen_mode": "pen",
            "penmode_pen_style": "eraser",
            "penmode_eraser_style": "eraser"
        }

Hence the two tools that are mapped to the two types of pens : pen and eraser.

If you run rnote with flatpak --env=RUST_LOG=rnote=debug --env=RUST_BACKTRACE=1 run com.github.flxzt.rnote and look at the output while drawing, you'll seen pen_mode = Some(eraser) appear when pressing on the first button (and pen_mode = Some(Pen) otherwise wherether the second button is pressed or not).

So it's effectively #1104 (with #1119 to fix it though still some polish to do there).
Tool mapping for pen/eraser can be changed (and won't affect the stylus button mapping, as long as it's actually what we get for info !) and isn't (yet) shown in the settings.

Do this :

if a button is seen as an eraser, what's currently in the settings will have no effect and you'll have to keep the eraser pressed, draw, change the tool to the one you want then release the button currently)

To change the mapping for now

@1over137
Copy link
Author

Thanks, I was able to fix the mapping for now. I always thought that the two pens listed there is just because of the fact that I do have two physical pens, so that was confusing.

@Doublonmousse
Copy link
Collaborator

Oh right I missed the "two physical pens" part. Maybe both have their first button mapped to the eraser (instead of ... you know, the first button).

To me this is a bug/wrong mapping in libinput

@1over137
Copy link
Author

After fumbling around somewhat a little more, a third pen (based on the larger pen which has tilt and pressure) appeared on Gnome's setting panel, so I would assume your theory is true. Both pens behave the same in rnote though, and mapping the eraser to another tool in one pen also affects the other.

@d3nnis77
Copy link

d3nnis77 commented Oct 21, 2024

To me this is a bug/wrong mapping in libinput

I believe it isn´t. I have the same bug (HP Envy x360 with HP MPP pen) and I for once never had this bug with Xournal++ and while the bug occurs (rnote having first button mapped to pen instead of eraser), Xournal still functions as expected (button toggling eraser).

@RayJW
Copy link
Contributor

RayJW commented Oct 21, 2024

Just to chime in, I recently had to dig into libwacom and the GNOME settings to get my pen and tablet working. From what I learnt this is kind of a Rnote issue but also, it isn't. Basically, Rnote maps the primary button action to what GNOME interprets as the right mouse button click, and the secondary action corresponds to the middle mouse button click. So, you have to set up your pens accordingly in your DE stylus settings for the actions to be mapped like you want them to.

To me this is a bug/wrong mapping in libinput

I believe it isn´t. I have the same bug (HP Envy x360 with HP MPP pen) and I for once never had this bug with Xournal++ and while the bug occurs (rnote having first button mapped to pen instead of eraser), Xournal still functions as expected (button toggling eraser).

If I understood your problem correctly, you just have to keep the eraser button pressed and while doing that switching to the eraser tool. Now every time the eraser should be active as long as you keep the button pressed. As already mentioned, this behaviour can't be changed by Rnote, this is a weird stylus firmware behaviour Microsoft enforced upon the manufacturers, and it is impossible for the OS to map something exclusively to this button. Every time one presses the eraser button, the stylus reports itself as leaving the proximity of the screen and a second totally unrelated pen entering the proximity. So libwacom has to handle that as two different pens in one, which is why the button can't just be mapped to something. You can check by running sudo libwacom debug-events. There you can see that every time you press the eraser button, a different stylus (reported as BTN_ERASER or something like that). More info around the reasons for this limitation can be found here, for example.

Repository owner deleted a comment Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input input related issues
Projects
None yet
Development

No branches or pull requests

4 participants