How do I configure a Wacom stylus on Ubuntu 17.04?

At the end of the day, this is what I eventually found out that:

  • Layout data for tablets and styluses is handled by the Linux Wacom project and should be contributed to them if it's missing. It includes all the information about the devices, such as the number of buttons.
  • Data for new tablets, once somebody contributes it, is eventually packaged into distros after some time. In fact, the Wacom settings page for my tablet worked since Ubuntu 18.04.
  • Configuration for input devices on Xorg (using libinput) is managed with the xinput tool. By running xinput --list-props <device>, all available settings are listed, and can be configured.
  • On Wayland, everything is more complicated: the input configuration, just as every other display/HID-related setting, is managed by the compositor.
    • GNOME manages them with gsettings: you can see the configuration with dconf-editor inside /org/gnome/desktop/peripherals. GNOME Settings does its work by changing stuff there.
    • On Weston you must change the configuration file (source).
    • Other compositors may behave differently.

Eventually I haven't managed to configure my stylus, but I think it's the stylus' fault: it has two buttons but they're actually not remappable: one acts as the eraser, the other one works as a button. They can't be swapped.