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

spacenav: init package and module #94234

Closed
wants to merge 9 commits into from
Closed

Conversation

lukego
Copy link
Contributor

@lukego lukego commented Jul 30, 2020

Motivation for this change

This PR adds hardware support for the 3Dconnexion Spacemouse (https://www.youtube.com/watch?v=4WBTJhXpnsc) to nixpkgs in general and Blender in particular.

Specifically,

  • Package the Spacenav software packages spacenavd, libspnav, spnavcfg.
  • Add option spacenavSupport to Blender (enabled by default);
  • Patch Blender to recognize the device ID of the hardware unit that I bought in 2020 (have to contact Blender upstream about that patch separately.)

This works great for me! However I have to start spacenavd manually as root. (I tried writing a NixOS module to operate that but my first attempt hasn't worked and I'm a bit of a systemd n00b.)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Supports 3D input devices such as 3Dconnexion Spacemouse.
Builds Blender with support for 3D input devices such as 3Dconexxsion
Spacemouse.

Patched Blender to recognize the device-ID of the wireless Spacemouse
that I bought in 2020. Has to be upstreamed to Blender separately.

Enabled by default even though the feature is obscure because enabling
has low impact (small dependency) while enabling manually has larger
impact (have to compile Blender which takes a long time.)
pkgs/misc/spacenav/libspnav.nix Outdated Show resolved Hide resolved
pkgs/misc/spacenav/spacenavd.nix Outdated Show resolved Hide resolved
pkgs/misc/spacenav/spnavcfg.nix Outdated Show resolved Hide resolved
lukego and others added 3 commits July 30, 2020 16:10
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
@lukego
Copy link
Contributor Author

lukego commented Jul 30, 2020

Oh dear. I applied those suggestions that Github offered me but it seems they were only drafts and not actually working. Sorry, haven't seen this workflow on Github before with being offered changes to adopt, didn't have a workflow for testing/evaluating them beyond a quick eyeball.

Closing this PR because the review process is a bit overwhelming with all the advanced Github features and bot reviews :)

@lukego lukego closed this Jul 30, 2020
@KoviRobi
Copy link
Contributor

KoviRobi commented Aug 5, 2020

I just got a SpacePilot Pro, and am interested in helping you test (and could implement a NixOS module too), we'll see if I can find the time to do so :)

@KoviRobi KoviRobi reopened this Aug 5, 2020
@KoviRobi
Copy link
Contributor

KoviRobi commented Aug 5, 2020

I don't know if there is a better way to suggest changes, but I have a couple of commits on top of yours, at https://github.com/KoviRobi/nixpkgs/commits/spacenav-nixpkgs. I reopened this, as this work is still based you yours, but I can close this and create a new PR if you want.

If you want to fold my changes into yours, you should be able to do (I think)

git remote add kovirobi-spacenav https://github.com/KoviRobi/nixpkgs.git
git fetch kovirobi-spacenav
git rebase kovirobi-spacenav/spacenav-nixpkgs

failing that, you can just git cherry-pick individual commits from mine :)

This runs the driver for 3D mice such as Space Navigator, Space Pilot or
Space mouse.
@KoviRobi
Copy link
Contributor

KoviRobi commented Aug 5, 2020

I have also added a service, which is currently run as root :( but I couldn't get it working otherwise.

It also turns out it works as a joystick out of the box, if you disable the mouse functionality, in which case you can just use the joystick input for OpenSCAD, though sadly not for blender.

@lukego
Copy link
Contributor Author

lukego commented Aug 6, 2020

That's awesome @KoviRobi! I've pulled your commits onto this branch. If my Git-fu is lacking in some respect feel free to open a new PR from a branch of your own and we can close this one.

Copy link
Member

@7c6f434c 7c6f434c left a comment

Choose a reason for hiding this comment

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

Code looks good to me

case 0x256F: // 3Dconnexion
switch (product_id) {
case 0xC62E: // plugged in
- case 0xC62F: // wireless
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this somewhere upstream in blender, and could we fetchpatch from there?

wantedBy = [ "multi-user.target" ];
partOf = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.spacenavd}/bin/spacenavd -d";
Copy link
Contributor

Choose a reason for hiding this comment

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

Last time I played with this, I opened 3 issues:

Copy link
Contributor

Choose a reason for hiding this comment

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

I did manage to get spacenav working with this, but it's worth pointing out that spacenav joystick support is in Linux out of the box, and you can disable the annoying mouse movements with this:

  services.xserver.inputClassSections = [
    ''
      Identifier "3Dconnexion  SpacePilot PRO "
      MatchProduct "3Dconnexion  SpacePilot PRO "
      Driver "evdev"
      Option "Ignore" "on"
    '' ];

But blender doesn't support mouse navigation (openscad does).

  • The config file is something which we could potentially capture with nix, but given it's got a gui configurator and it's very floating-point not easy to calculate you just have to try and see what works, we do definitely want to support that.
  • Good idea
  • I did verify, it works (when it's launched as root, I couldn't make it work non root though :( )

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this could use some documentation, maybe the inputClassSection even a NixOS option.

Can you add some module documentation, like it's done with the nextcloud module?

The config file is something which we could potentially capture with nix, but given it's got a gui configurator and it's very floating-point not easy to calculate you just have to try and see what works, we do definitely want to support that.

So you want to give this some cooking first?

I did verify, it works (when it's launched as root, I couldn't make it work non root though :( )

GUI applications need to be launched as root? Or the spacenav daemon?

Copy link
Contributor

Choose a reason for hiding this comment

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

The spacenav daemon needs to be root -- though you do need write permissions to the /etc/spnav.conf, which currently I think requires a chown.

Also, because my brain is a vegetable today, I forgot your first point, the OP did say they tried to get their patch accepted upstream, not sure if they have heard anything back from them.

I'll have a think about the config file, what I meant though is that it might not be applicable to be captured by nix, as the user might want to change it too often/faster than recompiling the system/with the gui rather than just picking values.

I'll try and remember to look at this in a couple of days when I am more functional, thanks for taking a look at this PR though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Having to no clear separation between user-wanted config and "state/calibration data" would indeed be a problem - let's iterate on that at a later point :-)

@flokli flokli changed the title Spacenav nixpkgs spacenav: init package and module Aug 13, 2020
@prusnak prusnak mentioned this pull request Jan 9, 2021
10 tasks
@prusnak
Copy link
Member

prusnak commented Jan 9, 2021

These three issues are duplicates of each other:

@prusnak prusnak mentioned this pull request Jan 9, 2021
9 tasks
@leenaars
Copy link
Contributor

And there is a version bump for spnavcfg too:

  src = fetchFromGitHub {
    owner = "FreeSpacenav";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-QCHAMua4Wtn+v2fw5VdA29yg+IXHjZzT0f2VoGObFaA=";
  };

@Sohalt
Copy link
Contributor

Sohalt commented Jan 20, 2021

Can you also add the spacenav-cube-example? You can have a look at #75866 for the rationale and implementation.

@flokli
Copy link
Contributor

flokli commented Jun 25, 2021

For posterity: This has been implemented in #118617.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants