godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.54k stars 21.26k forks source link

InputEventMouseMotion: stylus eraser detection not working on Steam OS/X11 #63184

Closed hansemro closed 2 years ago

hansemro commented 2 years ago

Godot version

4.0.dev (6dcc9d11319), 3.x (101cbe5d5bb)

System information

Steam OS (stable, kernel 5.13.0-valve15-1-neptune-02197-gf6ec7ad3762a), Steam Deck with Wacom Intuos Pro M

Issue description

While testing Wacom Intuos Pro M on the Steam Deck, I noticed the eraser end of the stylus did not get recognized in my test program (https://github.com/hansemro/InvertedPenGodotTest). After checking code I referenced for the X11 implementation (https://gitlab.com/gnome/gtk/-/blob/master/gdk/x11/gdkdevicemanager-xi.c#L233-235), I noticed that device name gets converted to all lower case before checking for the word "eraser". Currently, godot does a case-sensitive search for the word "eraser" without converting the device name to lower case, which would explain my problem.

For reference, here is a comparison of xinput command between my Steam Deck and Thinkpad:

xinput command snippet on Steam Deck (in desktop mode):

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
...
⎜   ↳ Wacom Intuos Pro M Pad                    id=25   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Finger                 id=26   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Pen Pen (0x9980b165)   id=27   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Pen Eraser (0x9980b165)        id=28   [slave  pointer  (2)]

xinput command snippet on Thinkpad T440p with Manjaro Linux:

xinput
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Pen stylus             id=10   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Pad pad                id=11   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Finger touch           id=12   [slave  pointer  (2)]
⎜   ↳ Synaptics TM3157-007                      id=13   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=14   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos Pro M Pen eraser             id=17   [slave  pointer  (2)]

Steps to reproduce

Requirements to reproduce:

  1. Run InvertedPenGodotTest demo project (https://github.com/hansemro/InvertedPenGodotTest).
  2. Use eraser end of stylus and observe red background to indicate eraser is NOT being used.

Minimal reproduction project

No response

Calinou commented 2 years ago

Currently, godot does a case-sensitive search for the word "eraser" without converting the device name to lower case, which would explain my problem.

This should be trivial to fix by converting device names to lowercase in Godot before checking for their name against lowercase eraser.