flathub / org.blender.Blender

https://flathub.org/apps/details/org.blender.Blender
17 stars 26 forks source link

spacenavd not working with blender .. Is this compiled with spacenav support? #18

Closed japrogramer closed 1 year ago

japrogramer commented 6 years ago

hello I am on linux, I run blender from the flathub flatpak like this

$XAUTHORITY=$HOME/.Xauthority sudo spacenavd -v -d
$flatpak run org.blender.Blender

is it because it runs in a jail that it cant detect the magic sauce that spacenavd is doing

bochecha commented 6 years ago

What if you run Blender with the following command?

$ flatpak run --device=all org.blender.Blender
bochecha commented 6 years ago

Seems another problem is that we build Blender with -DWITH_INPUT_NDOF:BOOL=OFF.

To enable that, we'd have to add the Spacenav libraries to the build.

I'll try to have a go at this.

bochecha commented 6 years ago

@japrogramer Since I don't have the spacenab hardware I can't reproduce the problem or try to debug it.

However, maybe you can help me. :slightly_smiling_face:

I'd like you to do the following, if possible:

  1. uninstall Blender from Flathub:

    $ flatpak uninstall org.blender.Blender
  2. download and install a bundle I just made (from #19) for testing purposes:

    $ wget https://www.daitauha.fr/static/blender.flatpak
    $ flatpak install --user blender.flatpak
    Installing for user: org.blender.Blender/x86_64/spacenav from bundle blender.flatpak
  3. run the test build:

    $ flatpak run org.blender.Blender//spacenav

Do things work?

japrogramer commented 6 years ago

@bochecha sorry for the late respond everything was sent to spam on my email, so i didn't see it until now. I will try this tommorow in the morning when I am near my hardware.

japrogramer commented 6 years ago

@bochecha finally had the chance to install and run, it didn't work .. I ran the program like you suggested and tha I ran it with all the devices passed like in the first comment

here is everything in my set up


▶ xauth -vib generate :0 . trusted
Attempting to break locks on authority file /home/archangel/.Xauthority
Ignoring locks on authority file /home/archangel/.Xauthority
authorization id is 1024
Ignoring locks and writing authority file /home/archangel/.Xauthority

~/Downloads
▶ XAUTHORITY=$HOME/.Xauthority sudo spacenavd -v -d
Spacenav daemon 0.6
failed to open config file /etc/spnavrc: No such file or directory. using defaults.
Device detection, parsing /proc/bus/input/devices
found usb device [46d:c626]: "3Dconnexion SpaceNavigator" (/dev/input/event17)
adding device.
device name: 3Dconnexion SpaceNavigator
  Number of axes: 6
using device: /dev/input/event17
trying to open X11 display ":0"
   XAUTHORITY=/home/archangel/.Xauthority
adding dev event for device: /dev/input/event17

flatpak run --device=all org.blender.Blender//spacenav

bochecha commented 6 years ago

@japrogramer so you tested it… but then does it actually work? :thinking:

japrogramer commented 6 years ago

@bochecha I mentioned that it didn't work, I should also mention that I'm running Wayland.

bochecha commented 6 years ago

Oh sorry, I missed it.

Did you get any output in the terminal when running Blender? Maybe try with --debug-all? (that might make it extremely verbose)

japrogramer commented 6 years ago

@bochecha i finally got to it, still doesn't work. flatpak run --device=all org.blender.Blender//spacenav --debug-all

SRNA Subclassed: 'Context'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'PropertyGroup'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Bone'
SRNA Subclassed: 'EditBone'
SRNA Subclassed: 'PoseBone'
SRNA Subclassed: 'UIList'
SRNA Subclassed: 'Mesh'
SRNA Subclassed: 'Object'
SRNA Subclassed: 'Texture'
SRNA Subclassed: 'Header'
SRNA Subclassed: 'KeyingSetInfo'
SRNA Subclassed: 'Node'
SRNA Subclassed: 'NodeInternal'
SRNA Subclassed: 'ShaderNode'
SRNA Subclassed: 'CompositorNode'
SRNA Subclassed: 'TextureNode'
SRNA Subclassed: 'WindowManager'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'RenderEngine'
SRNA Subclassed: 'Panel'
SRNA Subclassed: 'Menu'
SRNA Subclassed: 'Operator'
SRNA Subclassed: 'PropertyGroup'
SRNA Subclassed: 'AddonPreferences'
I0708 14:15:12.349328     3 blender_python.cpp:186] Debug flags initialized to:
CPU flags:
  AVX2   : True
  AVX    : True
  SSE4.1 : True
  SSE3   : True
  SSE2   : True
  QBVH   : True
  Split  : False
CUDA flags:
 Adaptive Compile: False
OpenCL flags:
  Device type    : ALL
  Kernel type    : DEFAULT
  Debug          : False
  Single program : True
  Memory limit   : 0
Switching to fully guarded memory allocator.
read file /home/archangel/.var/app/org.blender.Blender/config/blender/2.79/config/userpref.blend
  Version 279 sub 0 date unknown hash unknown
Read prefs: /home/archangel/.var/app/org.blender.Blender/config/blender/2.79/config/userpref.blend
read file 
  Version 272 sub 2 date unknown hash unknown

ordered
 OBCube
 OBLamp
 OBCamera
ED_screen_refresh: set screen
FRS_set_context: context 0x0x7f231f314578 scene 0x0x7f231a1c2038
time bl_operators 0.1282
time bl_ui 0.3875
time keyingsets_builtins 0.0078
time nodeitems_builtins 0.0165
    addon_utils.enable io_scene_3ds
    addon_utils.enable io_scene_fbx
    addon_utils.enable io_anim_bvh
    addon_utils.enable io_mesh_ply
    addon_utils.enable io_scene_obj
    addon_utils.enable io_scene_x3d
    addon_utils.enable io_mesh_stl
    addon_utils.enable io_mesh_uv_layout
    addon_utils.enable io_curve_svg
    addon_utils.enable cycles
Python Script Load Time 0.6515
bpy.ops.wm.splash()
WM_operator_last_properties_store: storing properties for 'WM_OT_splash'
ghost_event_proc: window 1 state = maximized
ghost_event_proc: ghost redraw 1
ghost_event_proc: window 1 state = maximized
ghost_event_proc: ghost redraw 1

wm_event_do_handlers: Handling event
wmEvent  type:172 / OSKEY, val:1 / PRESS,
         shift:0, ctrl:0, alt:0, oskey:1, keymodifier:0,
         mouse:(812,683), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f23075fbef8
Thread 0: update object OBCamera
recalcob Camera
Thread 4: update object OBLamp
Thread 1: update object OBCube
recalcob Lamp
recalcob Cube
recalcdata Cube
Thread 0: total 1 objects in 0.000010 sec.
  Camera in 0.000010 sec
Thread 1: total 1 objects in 0.000229 sec.
  Cube in 0.000229 sec
Thread 2: total 0 objects in 0.000000 sec.
Thread 3: total 0 objects in 0.000000 sec.
Thread 4: total 1 objects in 0.000186 sec.
  Lamp in 0.000186 sec
Thread 5: total 0 objects in 0.000000 sec.
Thread 6: total 0 objects in 0.000000 sec.
Thread 7: total 0 objects in 0.000000 sec.
Scene updated 3 objects in 0.000296 sec
ED_screen_refresh: set screen

wm_event_do_handlers: Handling event
wmEvent  type:172 / OSKEY, val:2 / RELEASE,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(812,683), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f23079485f8

wm_event_do_handlers: Handling event
wmEvent  type:272 / TIMER, val:0 / NOTHING,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(719,644), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307949078

wm_event_do_handlers: Handling event
wmEvent  type:1 / LEFTMOUSE, val:1 / PRESS,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307949078

wm_event_do_handlers: Handling event
wmEvent  type:1 / LEFTMOUSE, val:2 / RELEASE,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:215 / RIGHT_CTRL, val:1 / PRESS,
         shift:0, ctrl:1, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:113 / Q, val:1 / PRESS,
         shift:0, ctrl:1, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038
wm_handlers_do_intern:       handled! 'WM_OT_quit_blender'

wm_event_do_handlers: Handling event
wmEvent  type:113 / Q, val:2 / RELEASE,
         shift:0, ctrl:1, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:215 / RIGHT_CTRL, val:2 / RELEASE,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:272 / TIMER, val:0 / NOTHING,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:220 / RET, val:1 / PRESS,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

wm_event_do_handlers: Handling event
wmEvent  type:272 / TIMER, val:0 / NOTHING,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0,
         mouse:(645,642), ascii:'', utf8:'', keymap_idname:(null), pointer:0x7f2307897038

Blender quit
Arxcis commented 4 years ago

@bochecha

spacenavd-clients does not listen to the device directly. The spacenavd-events are sent across the X11 socket (for compability with clients written for the closed source driver) and also a Unix domain socket for features only available in the open spacenavd-driver.

Clients that use libspnav, have the option to use either the legacy X11-mode or the Unix socket mode.

According to the https://github.com/FreeSpacenav/spacenavd#dependencies, Blender is utliizing the Unix socket mode.

The path to the Unix socket is defined in

#define SPNAV_SOCK_PATH "/var/run/spnav.sock"

https://github.com/FreeSpacenav/libspnav/blob/master/spnav.c#L39

Update

The blender source code also confirms this:

#define SPNAV_SOCK_PATH "/var/run/spnav.sock"

GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys)
    : GHOST_NDOFManager(sys), m_available(false)
{
  if (access(SPNAV_SOCK_PATH, F_OK) != 0) {
#ifdef DEBUG
    /* annoying for official builds, just adds noise and most people don't own these */
    puts("ndof: spacenavd not found");
    /* This isn't a hard error, just means the user doesn't have a 3D mouse. */
#endif
  }
  else if (spnav_open() != -1) {
    m_available = true;

https://github.com/blender/blender/blob/master/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp#L24-L34

This also explains why we don't see any errors, because the error "ndof: spacenavd not found" is silenced other than in debug-builds.

Arxcis commented 4 years ago

I tried

$ flatpak run --filesystem=/var/run/spnav.sock --user org.blender.Blender//spacenav 
bwrap: Can't make symlink at /var/run: File exists

Does that mean that the socket is available inside the flatpak?

ghost commented 3 years ago

Did anyone figure out how to make it work with blender flatpak?

adrianinsaval commented 2 years ago

posting in case it's relevant, socket path seems to be configurable now: https://github.com/FreeSpacenav/libspnav/releases/tag/v0.3

ananace commented 2 years ago

I added the support into FreeCAD with https://github.com/flathub/org.freecadweb.FreeCAD/pull/55 - the exact same changes should work for Blender as well.

Of course, if your system follows spec with /var/run being a symlink, then something as simple as flatpak override --user org.blender.Blender --filesystem=/run/spnav.sock:ro should be enough.

tkrill commented 1 year ago

@ananace comment solves this for me.

flatpak override --user org.blender.Blender --filesystem=/run/spnav.sock:ro

Could this permission somehow be integrated in the flatpak build?

adrianinsaval commented 1 year ago

I do not have a 3d mouse so I cannot test, those of you who have it please test this PR: https://github.com/flathub/org.blender.Blender/pull/131#issuecomment-1366221802

tkrill commented 1 year ago

@adrianinsaval i downloaded and tested the version with the PR above. Seems to work for me.

Arxcis commented 1 year ago

Thank you very much @adrianinsaval :clap: for implementation and @tkrill for testing :smile: and @kevinsmia1939 for merging :+1: