kozec / sc-controller

User-mode driver and GTK3 based GUI for Steam Controller
GNU General Public License v2.0
1.53k stars 129 forks source link

[FEATURE REQUEST] Implement 3D Mouse Output for SC gyroscope #381

Closed Patola closed 6 years ago

Patola commented 6 years ago

Ok... This will be somewhat convoluted to explain, but here is the thing: sc-controller is so powerful and complete that I use it with the steam controller to make 3D modelling in FreeCAD and (sometimes) in Blender.

However, there is a device called a "space navigator" from 3dconnexion that is a "3D Mouse". It generates its own protocol of output, with 3 translation axes and 3 rotation axes. Both FreeCAD and Blender support it. When you use this device, it moves the 3D viewport accordingly, you don't even have to have it in focus.

It would be great if this functionality could be added to sc-controller, so that we could map the gyroscope from the steam controller to the rotation outputs of space navigator.

The driver for the device is free and open-source, implemented through "spacenavd". And both FreeCAD and Blender have python+C++ code to interact with it. I don't think it would be too difficult to use this code to find a way to output the same information as the 3D mouse.

I understand that this is a long shot and it is a feature that is not very useful to many people, since the device is somewhat expensive. However it has been making inroads and even 3D slicing software like Cura have open bug reports to implement 3D viewing using its API.

I would of course be a volunteer for testing any code, or even help coding if I can get into the protocol.

kozec commented 6 years ago

So, just by looking at source of spacenavd, this should be possible even now.

You can configure SCC to emulate 6-axis device in ~/.config/scc/config.json, key output. You can change device name and USB ids there as well, so spacenavd should pick it up not knowing it's virtual device.

But that's just theory, I'll check if it works first.

kozec commented 6 years ago

I'm playing with it a little and I'm wondering...

How do you imagine those translation axes? Steam Controller has just gyros and doesn't know anything about its own position in space, so it can do some kind of touchpad-to-2D space emulation at best.

Patola commented 6 years ago

"You can configure SCC to emulate 6-axis device in ~/.config/scc/config.json, key output. You can change device name and USB ids there as well, so spacenavd should pick it up not knowing it's virtual device."

I will try to see if it works.

"How do you imagine those translation axes? Steam Controller has just gyros and doesn't know anything about its own position in space, so it can do some kind of touchpad-to-2D space emulation at best."

I would just map the rotational axes. The translation axes are very comfortable mapped to the stick axes (XZ) and the emulated mouse wheel (zoom in/out - Y axis).

Patola commented 6 years ago

These are the space navigator device entries in dmesg:

[   11.828447] usb 3-2.3: Product: SpaceNavigator
[   11.828448] usb 3-2.3: Manufacturer: 3Dconnexion
[   11.849100] input: 3Dconnexion SpaceNavigator as /devices/pci0000:00/0000:00:1c.0/0000:02:00.0/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C626.0004/input/input19
[   11.849183] logitech 0003:046D:C626.0004: input,hidraw3: USB HID v1.11 Multi-Axis Controller [3Dconnexion SpaceNavigator] on usb-0000:02:00.0-2.3/input0

Just as reference for the tests.

kozec commented 6 years ago

Well, if that's the case, all you need is to configure spacenavd so it recognizes virtual device generated by scc.

This /etc/spnavrc should work for mapping horizontal left and both right stick axes as rotation

device-id=045e:028e
axismap3=3
axismap4=4
axismap0=5

... and then you can just set gyro(Axes.ABS_RX, Axes.ABS_RY, Axes.ABS_X) in GUI for gyro.