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

xppen_{3,4}: init at {3.4.9-240131,4.0.4-240815}; nixos/xppen: init #351647

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

gepbird
Copy link
Contributor

@gepbird gepbird commented Oct 27, 2024

Summary

Add the official XP Pen tablet drivers:xppen_3, xppen_4 packages and xppen NixOS module.

Prior work

This PR is based on #285660, thanks for @nasrally's, the reviewers' and the testers' work!

Closes #285660, closes #347984.
Related: #213263, #277176

For reviewers

cc @h7x4, @MinerSebas, @eclairevoyant and @fsnkty for reviewing #285660

Differences to the aforementioned PR for the package:

  • rename from xppen to xppen_3
  • update from 3.4.9 (-231023) to 3.4.9-240131
  • remove libGL dependency as it seems to be unused
  • change qt5.full to qt5.qtbase
  • refactor installPhase, merge with postInstall
  • add maintainer gepbird
  • remove with lib;
  • change meta.platforms from linux to x86_64-linux
  • add meta.sourceProvenance
  • add comment for how to update the package
  • nixfmt and order attrs
  • squash commits, follow conventions

Differences for the NixOS module:

  • fix issue with exporting configuration by giving the /var/lib/pentablet/conf/xppen directory 777 permission
  • add instructions to help users choose between the versions of the package
  • nixfmt

New changes:

  • add xppen_4
  • add release notes for module addition

The derivations for xppen_3 and xppen_4 are almost identical, but I'm not sure how to unify them in by-name, can I get some assistance? This is resolved with the help of https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/README.md#recommendation-for-new-packages-with-multiple-versions.

For testers

I belive this was sufficiently tested by @damiankorcz, many thanks!

I don't have any XP Pen tablets, the most I can do is check whether the GUI opens. If you own a tablet, please test whether this works for you, feel free to ask for help if you're unsure how to do it.

cc @damiankorcz and @misumisumi for testing the version 3 driver
cc @HangedFool for testing the version 4 driver

To test it, you can build your system with this PR and with this extra config and you should see the xppentablet desktop entry or PenTablet binary:

programs.xppen = {
  enable = true;
  package = pkgs.xppen_3; # or `pkgs.xppen_4` for the newer driver
};

Things done

  • Built on platform(s)
    • x86_64-linux
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Oct 27, 2024
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 27, 2024
@damiankorcz
Copy link

damiankorcz commented Oct 27, 2024

Hi @gepbird,
Thanks for picking this up! I finally got some time to test this and overall I could use this fine. Everything I'd need works and can be setup. There are a few issues but for most use cases it should suffice. I tested with the xppen_3 package (will see if the xppen_4 picks up this tablet) and used your repository to temporarily replace my nixpkgs (I don't really know how to individually overlay just these packages over my usual setup).

Here is a general summary:

Working

  • The tablet and pen are detected.
  • Changing button functions on the pen (2 buttons).
  • Changing button functions on the tablet (8 buttons).
  • Battery status displays correctly.
  • Changing the Pressure settings: Hardness and displaying the Current pressure.
  • Mouse mode.
  • Changing Pen Tablet mapping: Full area and Customize active area. Rotation also works.
  • Does seem to retain configuration changes that were saved when fully restarting the app.
  • Exporting config.
  • Checked with Krita: Pressure settings, Disabling pressure, Disable tilt, Disable message and Disable Function Keys options in the XP Pen app impact Krita.
  • Diagnostic tool shows info correctly:
    image

Issues

  1. Can't seem to move the XP Pen app window around. If i use Meta + Left Click drag I can move the window around.
  2. Importing config doesn't seem to work correctly. I only get this in terminal when selecting the file:
"/var/lib/pentablet/conf/xppen/config.xml"
"PenTableLists"
"1.5"
"PenTableLists"
"1.5"

Here is the exported settings that I created with the app then tried to reimport after setting everything back to default: PenTablet_Config_2024-10-27.pcfg.pcfg.zip

  1. The Identity option in the Work area tab doesn't seem to put the screen identifier on each individual screen. It's just bunched up on the screen that the XP Pen app is on.
    image

  2. The Rotation labels seem to disappear when the window is focused:

Unfocused Focused
image image
  1. The Work Area section isn't displaying the monitor layout (you can see that in the 2 screenshots above) but when clicking on Customize screen area option it does show the layout correctly:
    image

I can also see the following messages when interacting with the monitor options in this section:

qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QPixmap::scaled: Pixmap is a null pixmap

So I guess this might be a Wayland issue?

  1. Probably not an issue but when I rebuilt my Nix config and tried to run the app right away the font was missing completely and in some places the characters were replaced with squares. After rebooting the system it was fine since.

Notes

  • I'm using KDE 6.2.2, Wayland, Kernel 6.11.3, Nvidia RTX 2080.
  • Tablet used for testing: XP Pen Deco LW (I used it wirelessly with the provided dongle for all tests).
  • At least on KDE 6.2.2:
    • Settings' Drawing Tablet tab shows that the pen functions are Application-defined.
    • You need to set Map to screen: option to All screens. This is necessary for the XP Pen app's Work area section to map correctly to all your displays. This will let you select which display (or all) you want the tablet to map to in the XP Pen app. If this is set to something else in KDE settings it will map incorrectly since it limits the available area to the screen selected and I guess fits all the calculations within that area. Basically it's broken that way. I doubt this is a NixOS issues and just how it interacts with the KDE settings.

@damiankorcz
Copy link

Just rebuilt with the xppen_4 package and it doesn't detect the tablet wired or wireless. Assuming that it's not listed on the XP Pen Deco LW page (yet) then this is probably intended and not supported.

@nasrally
Copy link
Contributor

Hey! I wrote a commend encouraging you to pick my work up in my PR but got distracted and didn't send it :D So, thanks for picking it up! Glad my work was at least somewhat valuable, really hope you can get it through! :)

@gepbird
Copy link
Contributor Author

gepbird commented Oct 28, 2024

Thanks for your detailed testing @damiankorcz!

I'm happy most of the features work for you.

  1. Can't seem to move the XP Pen app window around. If i use Meta + Left Click drag I can move the window around.

Sad that the app disables default window decorations for their custom design. On a window manager like dwm there are no default decorations and I'm used to using keyboard shortcuts to move a window. However on the first "plug in your tablet" screen I can move the window without the keyboard, by starting to drag it on the top (eg. next to the close button). I think that should work on Plasma, can you check that? Otherwise I'm pretty sure it's an upstream bug.

  1. Importing config doesn't seem to work correctly. I only get this in terminal when selecting the file:
"/var/lib/pentablet/conf/xppen/config.xml"
"PenTableLists"
"1.5"
"PenTableLists"
"1.5"

Here is the exported settings that I created with the app then tried to reimport after setting everything back to default: PenTablet_Config_2024-10-27.pcfg.pcfg.zip

I'll try to do some research on the data you sent, but I think an strace output would also help. To minimize the output of strace, please attach it right before you click on the export/import button, and detach it with Ctrl+C after you observe the issue.

sudo strace -p $(pidof PenTablet | cut -f2) -ff 2> xppen-strace

I'll help with addressing the other issues later, I'm just short on time.

@h7x4 h7x4 added the 8.has: module (new) This PR adds a module in `nixos/` label Oct 28, 2024
@damiankorcz
Copy link

Hi @gepbird,
Here's a stack trace.

xppen-strace.zip

I've clicked on the Settings cog -> Export config -> Navigated to my desktop and saved the file. Then I again clicked on the Settings cog -> Import config -> Selected the file I just exported.

@gepbird
Copy link
Contributor Author

gepbird commented Nov 2, 2024

@damiankorcz Sorry for the late response, I've been busy this week and hopefully have more time next week.

From the strace (system call trace) you sent, I see a lot of access to ~/.config/PenTabletrc file, it seems like the currently loaded configuration. Can you also send that? I'm curious whether it has the same format as the exported .pcfg file. If it does, then we can find out whether the issue is with the exporting or the importing part of a .pcfg file checking how much it differs to the PenTabletrc file.

Does seem to retain configuration changes that were saved when fully restarting the app.

If it saves the config between app restarts, then it must save the modified config in your home folder and not in the priviliged /var/lib/pentablet directory. From the strace, when you import the config, it reads the config then tries to delete /var/lib/pentablet/conf/xppen/config.xml which fails due to permission denied:

xppen-config-deletion

@damiankorcz can you test again if after restarting the app/machine, does the modified config get loaded, or it reverts back to the default? If it works, then I assume they messed up the import config code and only that tries to modify the installed config, in that case try running it as a superuser and check if importing works.

@gepbird
Copy link
Contributor Author

gepbird commented Nov 2, 2024

The Identity option in the Work area tab doesn't seem to put the screen identifier on each individual screen. It's just bunched up on the screen that the XP Pen app is on.

Seems like a Wayland issue. I'm not familiar with that, but my guess it xppen is running inside an Xwayland session, so the application doesn't see all your monitors but only the area it takes up on the screen.

The Rotation labels seem to disappear when the window is focused:

Weird issue, I have no clue how something like that happens.

The Work Area section isn't displaying the monitor layout (you can see that in the 2 screenshots above) but when clicking on Customize screen area option it does show the layout correctly:

Looks like another Wayland issue.

qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QPixmap::scaled: Pixmap is a null pixmap

Interesting, I'll look into this later.

If anyone has some suggestions about these (presumably) Wayland issues, please comment it. And reproduction attempts of these issues on X11 could also help.

@damiankorcz
Copy link

Hi @gepbird,
Thank you for taking the time on this! Much appreciated.

Here's the PenTabletrc file:
PenTabletrc.zip

It seems that the file keeps a reference to the last imported (or exported?) file here so just to be sure it wasn't somehow loading from it I deleted them and when I restarted the app and system, the app seems to keep the settings saved correctly regardless.

As far as I can tell, it is successfully saving and loading the config file to /var/lib/pentablet/conf/xppen/config.xml. In case you want to look into there, here are the 3 files in that folder:
Archive.zip

  1. config.xml - As far as I can tell is the current app config it loads as it starts up. These are mentioned when running PenTablet in the terminal:
Function  LoadConfig success

*a little lower down*

open file "/var/lib/pentablet/conf/xppen/config.xml
  1. language.ini - Translation strings for different languages.
  2. name_config.ini - List of PIDs for all supported devices / dongles.

When trying to run the app as sudo from the terminal I get the following and the app doesn't start:

[damian@nixos-desktop:~]$ sudo PenTablet
[sudo] password for damian: 
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QtLockedFile::lock(): file is not opened
QtLockedFile::lock(): file is not opened

Looks like the app is actually running under Wayland not Xwayland. I did a simple test with xeyes and ran xlsclients -l to confirm this.

When I have a chance I'll try getting X11 on my system and see how much of this can be replicated so we know if Wayland is to blame.

@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from 7b5930a to 1bcff45 Compare November 3, 2024 09:29
@gepbird
Copy link
Contributor Author

gepbird commented Nov 3, 2024

As far as I can tell, it is successfully saving and loading the config file to /var/lib/pentablet/conf/xppen/config.xml.

You're right, your config differs from the default. At first I thought only root can edit this file then I checked its permissions:

~ ❯ stat /var/lib/pentablet/conf/xppen/config.xml 
  File: /var/lib/pentablet/conf/xppen/config.xml
  Size: 191313    	Blocks: 376        IO Block: 4096   regular file
Device: 0,30	Inode: 350807306   Links: 1
Access: (0666/-rw-rw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
...
~ ❯ stat /var/lib/pentablet/conf/xppen           
  File: /var/lib/pentablet/conf/xppen
  Size: 74        	Blocks: 0          IO Block: 4096   directory
Device: 0,30	Inode: 350807305   Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
...

From this, other people can write to the file (that's why the app modifying this config works), but can't delete it (that's why importing doesn't work, it tries to delete the old config and put there the new one):

~echo foo >> /var/lib/pentablet/conf/xppen/config.xml
~ ❯ rm /var/lib/pentablet/conf/xppen/config.xml     
rm: cannot remove '/var/lib/pentablet/conf/xppen/config.xml': Permission denied

I've updated the PR to set the permissions correctly. I know 777 looks insecure, but our other options are putting these files in the user's home (this should be done in home-manager, not in nixpkgs) or creating a user for xppen which seems like unnecessary complexity.

@damiankorcz Please either

  1. fix the permission manually with sudo chmod 777 /var/lib/pentablet/conf/xppen
  2. remove /var/lib/pentablet, force pull the changes to this PR and rebuild your system

Then try importing a config and see if it works.

@damiankorcz
Copy link

Hi @gepbird,
I did the sudo chmod 777 /var/lib/pentablet/conf/xppen command and importing now works correctly. I tested by exporting my current config, reseting everything back to default, restarting the app and importing the file. I saved it and restarted the app again and it persisted.

@gepbird
Copy link
Contributor Author

gepbird commented Nov 4, 2024

@damiankorcz I checked some documentation related to OpenGL and Wayland in nixpkgs and added some dependencies. Can you check if it fixes any of the previous issues, for example the "screen identifier" or the "rotation labels" issue? If it does, would you mind narrowing it down to the specific dependency(ies) that fixed it?

@damiankorcz
Copy link

Hi @gepbird,

I've checked and at least on Wayland it didn't seem to make a difference to any of those issues.

I've also just switched to X11 to test and it looks like:

  1. The Screen identifier does go to each screen correctly.
  2. In the Work area tab and Customize screen area option, the monitors are displayed correctly as you can see in this screenshot:
    image
    So I can only assume something on Wayland is stopping the app from capturing the screen content.
  3. The rotation labels still disappear when the window is focused so it might be worth checking if that is a bug with the app on other distros.

Everything else seems to work fine like it does on Wayland.

@damiankorcz
Copy link

Worth pointing out that the issues on Wayland are mostly visual in the app but the options still work correctly. Just slightly inconvenient when selecting which monitor you want the tablet to map to. But the dropdown lists all monitors correctly and it works. Same with the rotation indicators. You can just click off the app and see which one you want and select it. For both cases (for me with 4 screens) I just have to trial and error 4 options. You will likely do this once and be set. Perfectly serviceable if we can't find a solution.

@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from a982cff to 1bcff45 Compare November 4, 2024 21:17
@gepbird
Copy link
Contributor Author

gepbird commented Nov 4, 2024

Thanks a lot for testing, so apart from a few minor visual issues, the v3 driver seems to work well.

I don't think we have people who have time to test the v4 driver, a previous iteration of it was tested and worked with a few issues that the NixOS module solves.

Other than the xppen_3 and xppen_4 derivations being almost the same with with many duplicated code, I think this is done. This is also done.

@gepbird gepbird requested review from h7x4, MinerSebas and fsnkty November 4, 2024 21:23
@gepbird

This comment was marked as off-topic.

@gepbird

This comment was marked as off-topic.

@damiankorcz
Copy link

Hi @gepbird,
I got my system to build correctly again with the latest unstable branch. The apple-sdk issue appears to be with the syncplay app so I removed it for now.

Now, I've tried what you suggested to get the XP Pen stuff working but now I'm getting error: attribute 'currentSystem' missing for the xppen.nix file. Any ideas?

Thanks for helping me with this again. Much appreciated!

@gepbird

This comment was marked as off-topic.

@damiankorcz
Copy link

@gepbird That did it thank you! I tried something along those lines and couldn't quite figure out the syntax 😅 Also, I had to add config.allowUnfree = true; alongside the inherit for it to build correctly.
https://github.com/damiankorcz/nix-config/blob/main/common/software/xppen.nix

Now to hope this gets merged soon 🙏

@gepbird
Copy link
Contributor Author

gepbird commented Nov 17, 2024

cc @h7x4, @MinerSebas, @eclairevoyant and @fsnkty for reviewing #285660

@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from 3d5f652 to 5419706 Compare November 23, 2024 18:15
@gepbird

This comment was marked as outdated.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4872

Copy link
Member

@fsnkty fsnkty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing obviously wrong to me but personally unable to test

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Nov 28, 2024
@D3st0ny
Copy link

D3st0ny commented Dec 1, 2024

Are there any bluetooth tablets support in driver? Or xppen doesn't support bt for linux, cuz my deco pro lw (gen 2) works only in wired mode.

@damiankorcz
Copy link

Are there any bluetooth tablets support in driver? Or xppen doesn't support bt for linux, cuz my deco pro lw (gen 2) works only in wired mode.

Looking at the XP Pen website for your tablet there are both the Version 3 and Version 4 available so you could try with the other version from what you tried. My standard Deco LW works fine wireless and wired with the provided dongle. Possibly you have to re-pair the tablet with the dongle. Though mine worked fine and last I had it paired in Windows 11.

https://www.xp-pen.com/download/deco-pro-gen-2-series.html

@gepbird
Copy link
Contributor Author

gepbird commented Dec 1, 2024

Are there any bluetooth tablets support in driver? Or xppen doesn't support bt for linux, cuz my deco pro lw (gen 2) works only in wired mode.

@D3st0ny are you using NixOS with Bluetooth enabled and do other other softwares work with Bluetooth? If so, try this PR again, I added some related dependencies (not sure if they are being picked up at all or if I did it correctly, I don't know much about it).

My standard Deco LW works fine wireless and wired with the provided dongle

@damiankorcz does Bluetooth work for you with this PR on NixOS?

@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from 39e1c50 to 5652742 Compare December 1, 2024 19:38
@D3st0ny
Copy link

D3st0ny commented Dec 1, 2024

Looking at the XP Pen website for your tablet there are both the Version 3 and Version 4 available so you could try with the other version from what you tried.

Actually tried both versions

@D3st0ny are you using NixOS with Bluetooth enabled and do other other softwares work with Bluetooth? If so, try this PR again, I added some related dependencies (not sure if they are being picked up at all or if I did it correctly, I don't know much about it).

Tablet itself connects and actually works via bluetooth without driver, but i cant remap any pen buttons cuz driver doesn't detect it that way (can via inputremapper, but with pain in ass), will try soon

@damiankorcz
Copy link

@gepbird I just updated and it's still working fine on my end. I think if I recall correctly, the dongle uses Bluetooth but doesn't show up as an ordinary Bluetooth device in the system. On the Windows side, I used a separate tool that XP Pen provided to do the pairing. I think that can be done within the app now but I haven't had to re-pair since so I'm not sure.

@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Dec 1, 2024
@gepbird
Copy link
Contributor Author

gepbird commented Dec 2, 2024

@damiankorcz Thanks, so this package's bluetooth features worked for you without additional bluetooth dependencies.

Then I don't have high hopes the bluetooth dependencies will help you @D3st0ny, I will remove them after you try it out.

Edit: I removed it earlier

@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from 5652742 to 5419706 Compare December 4, 2024 22:09
@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Dec 5, 2024
@gepbird gepbird force-pushed the xppen-init-v3-v4-nixos-module branch from 5419706 to 93e171b Compare December 8, 2024 00:33
@gepbird
Copy link
Contributor Author

gepbird commented Dec 8, 2024

Fixed a merge conflict with the release notes.

@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants