3Dconnexion Space Mouse Support in Godot
Asked Answered
C

80

0

I've been looking into this project for @Kojack , to support the 3Dconnexion 3D mice, like the SpaceMouse and SpaceNavigator in Godot. For those that don't know, this is a mouse that supports 6DOF (rotation and translation) and makes it very easy to move the camera and position objects in 3D space.

I think I figured it out, but it's a little harder than I initially thought. It might take me about a week to get working. The basic idea is that you make an EditorPlugin. See here:

https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/making_main_screen_plugins.html

You'll also need a GDNative plugin to access the native shared libraries for the mouse:

https://docs.godotengine.org/en/stable/tutorials/scripting/gdnative/index.html

Then you can get access to the editor interface windows with EditorInterface:

https://docs.godotengine.org/en/stable/classes/class_editorinterface.html

From there you would use get_editor_viewport() to get the viewport, and then search through that to find the camera.

I still need at least a couple days to get a prototype together, but I have some of the pieces working on their own with command line apps. So maybe like a week to get it working. Will be fun to try this with my stereo 3D plug-in.

Cindy answered 30/1, 2022 at 20:8 Comment(0)
C
0

Here is the code that finds the camera given a viewport:

func find_camera(node) :
	var children = node.get_children()
	for child in children:
		if child is Camera:
			return child
	for child in children:
		return find_camera(child)
Cindy answered 30/1, 2022 at 20:51 Comment(0)
B
0

Nice.

I just went to find the camera code I was testing, and the gd script file is missing from my project. I think it was that damn fast boot thing that screwed things up recently after I reinstalled windows. Of course it didn't help that I was testing the camera stuff in Godot 4, before the alpha came out (I got the repo and built it myself). The docs were a bit out of date. :) The camera code I was using was from here: https://github.com/me2beats/godot-tips-and-tricks/issues/15 Your one is a lot simpler. :)

I really need to buy a new Connexion. Not just because the buttons are a bit jammed on my Space Pilot Pro, but also because their newer devices have a different protocol. I use HID to access the devices, but I can't test my reverse engineering without one of the newer ones. Maybe a Space Mouse Enterprise, although I never used the LCD screen of my Space Pilot Pro.

Bulletproof answered 30/1, 2022 at 21:48 Comment(0)
C
0

This is the one I use. I like it cause it is wireless and doesn't take up my whole desk.

https://www.amazon.com/3Dconnexion-SpaceMouse-Wireless-universal-receiver/dp/B079V367MM/

Cindy answered 30/1, 2022 at 23:18 Comment(0)
B
0

I've got the Space Navigator (wired) and Space Pilot Pro. Started with the Navigator, now I keep it at work and use the bigger one at home.

After using one with the palm rest, I don't like going back to the smaller one. Not because I actually need a palm rest, but because that holds it down so hard upwards movement doesn't lift the thing off the desk.

Bulletproof answered 31/1, 2022 at 1:28 Comment(0)
C
0

Yeah, that makes sense. I have to touch it lightly because it moves too much. But usually it's not too bad.

Cindy answered 31/1, 2022 at 1:30 Comment(0)
C
0

So I resumed this project. It's sort of working now, @Kojack . I used the libspnav, so it only works on Linux, but I kind of don't feel like supporting the proprietary SDK. There may be a way to compile for Windows/OSX but I'll have to look into that later. I'm getting all the values for position and rotation in Godot. Right now I am just moving a cube, but I will hook it up to the camera tomorrow. The results are kind of wonky since I'm using Euler, I think I have to convert to quaternion, but that shouldn't be hard.

Cindy answered 11/6, 2022 at 12:31 Comment(0)
C
0

Hey Grampus not sure if the new forum has notifications, let me know if you see this.

Cindy answered 12/6, 2022 at 2:45 Comment(0)
B
0

Cindy Hey, yep notifications work. I was asleep until 30min ago. πŸ™‚

Nice.
Yeah, I don't use their proprietary sdk either. I use direct HID access using HIDAPI from http://github.com/signal11/hidapi
It's windows, linux, bsd and osx. The connexion protocol is really simple. The great thing about HID level is it doesn't need drivers installed, so I can plug my space navigator or pilot pro into any PC and use it (in my own apps) without admin permissions to install the official drivers. That's handy at work where classroom computers don't let me admin.

The annoying thing is they've changed the protocol for newer devices and I can't test they work. I want to buy a new one, but they don't sell to australia directly and resellers add over $100. Plus their educational discount system is "Page not found" for me. Oh well.

Bulletproof answered 12/6, 2022 at 4:41 Comment(0)
K
0

Since you generously gifted me one, should you need someone to help with testing, just let me know.

Konopka answered 12/6, 2022 at 4:48 Comment(0)
C
0

I see right. I'm using this SDK, but now that I look at it, I'm not sure if it can compile for anything but Linux.

https://github.com/FreeSpacenav/libspnav

However, I will finish what I have because it's like 75% there and it if seems good I can look into how to support other platforms. I have the older and newer space nav devices, so figuring out the HID protocol shouldn't be too difficult. I'll look into that later.

Cindy answered 12/6, 2022 at 4:50 Comment(0)
B
0

The old protocol is basically:

#pragma pack(push,1)
struct Packet
{
	unsigned char type;
	union
	{
		struct
		{
			short x;
			short z;
			short y;
		};
		unsigned char bytes[6];
	};
};
#pragma pack(pop)

If type is 1, the shorts are position offsets. If type is 2, they are euler rotations. If type is 3, the x and y are bitfields for buttons (32 bit).

Bulletproof answered 12/6, 2022 at 5:0 Comment(0)
C
0

Thanks Lyall . I should be able to figure it out, I have a bunch of computers for testing, though that will probably be a good idea once I am ready to release something.

Cindy answered 12/6, 2022 at 5:1 Comment(0)
C
0

Oh yeah, that is dirt simple. Okay. I will probably go with that, because I don't think I could release it into the wild only supporting Linux. Though let me work with what I have for now and finish the rest of it and see if it is even worthwhile.

Cindy answered 12/6, 2022 at 5:2 Comment(0)
B
0

Hmm, the Connexion forums say that their wireless devices are harder to use through HID. That's annoying. I have no use for a wireless connexion, I wasn't planning on getting one (the Enterprise model has no wireless option anyway).

I also see that the official Linux sdk hasn't been updated in 17 years, so it may be a little out of date. Probably a good idea to go with libspnav instead. πŸ™‚

Bulletproof answered 12/6, 2022 at 6:58 Comment(0)
C
0

So I made some progress. I can now move the viewport camera around. The axis are all messed up, so I'll need to do some math, but both translation and rotation are getting correct values from the device.

My issue now is that after moving with the spacenav, if you use the mouse/keyboard to move it snaps back to the previous position (before you moved with the spacenav). I guess the editor has it's own copy of the transform it uses, so I may have to hook into that rather than modifying the camera directly. Hopefully that is possible with a plugin and won't need source access.

I also had to rewrite the function to find the camera. That code works for a game, but not in the editor. In the editor you have to find the Viewports and then get the Camera from that. Here is the new function.

func find_camera(node, list) :
	if node is Viewport:
		var camera = node.get_camera()
		list.append(camera)
		return list
	for child in node.get_children():
		find_camera(child, list)
	return list

And you can call it like this:

var editor = get_editor_interface()
var viewport = editor.get_editor_viewport()
var results = find_camera(viewport, [])
var camera = results[1]

The number 1 is needed because I have 1 user camera in my scene (results[0], the first editor camera is results[1]). If I had more, that would be a different number. It would also be a higher number if you used the split view for multiple view angles in the editor. I'll have to figure out a way to determine where you are looking rather than hard-coding the index.

Cindy answered 12/6, 2022 at 8:18 Comment(0)
C
0

Bulletproof I also see that the official Linux sdk hasn't been updated in 17 years, so it may be a little out of date. Probably a good idea to go with libspnav instead. πŸ™‚

Yeah, the fact that they haven't updated the Linux SDK in 2 decades doesn't make me eager to support them. Like it's not even a lot of work, the drivers are fairly simple and they basically abandoned Linux.

Cindy answered 12/6, 2022 at 8:20 Comment(0)
C
0

Hmm. Looks like it isn't possible. Not the end of the world but still kind of disappointing.
https://github.com/godotengine/godot-proposals/issues/3287

Cindy answered 12/6, 2022 at 12:12 Comment(0)
C
0

So I kept looking into it, and no, it is not possible without a source code change. The editor camera transform is controlled by a class called Cursor and is updated in the file spatial_editor_plugin.cpp. However, it holds it's own state, it does not read it from the editor viewport camera. Meaning even though I can move the camera, the state is not maintained (as soon as you start altering the camera with the mouse or keyboard it will revert to the previous state). So it's not going to work. Sorry, Grampus

Cindy answered 13/6, 2022 at 11:37 Comment(0)
B
0

Oh well. Thanks for looking into it.

I guess I'll just hack the Godot source. πŸ™‚

Bulletproof answered 13/6, 2022 at 12:12 Comment(0)
B
0

I'm guessing you were in version 3.4? In 4.0 there's no spatial_editor_plugin.cpp file, but there's a node_3d_editor_plugin.cpp which contains mouse and keyboard controls.
I found that back when I first started looking into this, I could probably easily add hard coded support for my own input library, but it won't help anyone else (and especially not non-windows users). But fine for myself.

Well, if I can get scons to let me. Can't say I'm a fan.

Bulletproof answered 14/6, 2022 at 1:46 Comment(0)
C
0

Yes, I'm on 3.4.4. But 4.0 is similar in the file your found (Spatial was renamed to Node3D in Godot 4.0, but works almost the same). I know I could get it working with a recompile, but I don't wish to do that as it will only work for me. Might still be worth trying just to see how it feels, but the idea was to release it as a plugin to help other people.

That said, I still have full control over user created Nodes. Meaning the Space Navigator could be used to position/orient objects, or move user cameras. This is less common, but still could be useful. I already tried it, I can get the selected object like this:

var editor = get_editor_interface()
var selection = editor.get_selection()

And then do whatever I want. However, I really wanted to use it to fly around the scene.

One other option is to spoof input, which would get passed to the editor. I know I can trigger fake mouse/keyboard events, but this will greatly limit the kind of 6DOF controls I want. However, it could be a compromise.

Cindy answered 14/6, 2022 at 2:57 Comment(0)
C
0

Okay, so I decided I have to finish this. I started editing the Godot source code, it's actually not that complicated (I guess those 15 years of learning C++ finally came in handy). I have the position pretty close to working. Right now it is in global space, so I have to convert it into the camera space, but I solved the issue of the mouse/keyboard interference. The rotation should not be difficult either. It's getting late now, but I think I can have it all working tomorrow.

It will take longer to get the space navigator to work cross-platform, though I can submit my commit and hope it gets merged in the meantime. My changes have nothing to do with the space navigator, it just allows altering the camera position/orientation. This could also be useful for AR/VR or for accessibility. For example, people could develop plugins that allow neck or mouth controllers to move the camera. So I think there is a good chance they will take my merge.

Cindy answered 14/6, 2022 at 10:40 Comment(0)
B
0

Cindy
Cool
Another potential use for control of the editor view is adding camera view shortcuts. Like place the camera looking at a part of your scene then bind that transform to a key. There's already the 6 axis view shortcuts, but no free view recording that I can see.

For some reason I can't get release builds of 4.0 to work (comes up with an error about missing .pck), but debug builds work fine (but slower). Probably some setting got messed up when I followed some online instructions to get godot compiling from visual studio (although still routed through scons, annoyingly).

Bulletproof answered 14/6, 2022 at 14:16 Comment(0)
C
0

It's working!!! Grampus Lyall

I gave up the idea of editing the source code. Though I did get it sort of working, that Cursor class is used for too much and it was causing all sorts of crazy bugs. Even if I did finish it, there was the problem of the z axis, so there was always going to be some jump. I decided to just use what was available as a plugin. This means the 6DOF state is not saved, but it doesn't mess up the normal function of the mouse and keyboard. I'll have to add cross-platform support for the extension, but the plugin itself is fully working.

Cindy answered 14/6, 2022 at 23:59 Comment(0)
B
0

Cindy It might be handy to have a 5DOF mode. I find roll can get annoying at times in editors. πŸ™‚
Cool work though!

Bulletproof answered 15/6, 2022 at 0:23 Comment(0)
C
0

I actually find roll helpful since it gives you a difference perspective. This is important in 3D because you are literally missing a dimension. It's sort of like how traditional artists back in the day were told to view their drawings in a mirror, because it shows you things you can't see normally.

Cindy answered 15/6, 2022 at 0:48 Comment(0)
K
0

Still, a turntable mode might have it's uses too. And a fly mode. But for initial support these can probably be considered "fluff".

Konopka answered 15/6, 2022 at 2:15 Comment(0)
B
0

Then again, if you are using the Connexion sdk, the control panel can already disable roll (at least on windows).

Bulletproof answered 15/6, 2022 at 2:39 Comment(0)
C
0

I guess it is sort of a turntable. It rotates around the selected object right now. You can kind of still fly wherever, since you have full control, but it gets difficult if you move more than around 6 units from the center (of the current object). Fly mode I can look into. I have tried it before on other apps and it never worked well. But it's worth investigating.

Cindy answered 15/6, 2022 at 2:53 Comment(0)
C
0

Bulletproof Then again, if you are using the Connexion sdk, the control panel can already disable roll (at least on windows).

Yes, I can put in some options. That shouldn't be an issue. I have to do that anyway to control the speed.

Cindy answered 15/6, 2022 at 2:54 Comment(0)
B
0

Cindy I guess linux may not have the same thing. But in windows there's already a configuration panel in the drivers for apps that use the sdk which gives axis scales, turning axes on/off, etc.

Bulletproof answered 15/6, 2022 at 4:39 Comment(0)
C
0

No Linux never had that. It was just a service with no GUI, but it hasn't worked in a long time. I looked into the official SDK, but it looks overly complicated and I'm not especially fond of the license (particularly because I plan to release the plug-in open source). While I don't have to open source the DLL, it still makes me nervous. I think I did enough for today, but I'll see about either the HIDAPI or porting libspnav to Windows/macOS. Not sure which would be easier, but I feel like contributing to libspnav may be more worthwhile in the long run.

Cindy answered 15/6, 2022 at 4:51 Comment(0)
B
0

Cindy Wait, sorry, I'd already misremembered the earlier part of the thread and thought you were using the linux sdk. Ignore my last post.
πŸ™‚

I like HID because I can also use it to get access to all features of things like PS5 controllers (touch pad, IMU, etc).

Yeah, the official sdk is rather excessive. For my own simple Connexion library (not my full multi-device input library) that I use with things like Unity, the entire interface is just:

struct ConnexionState
{
	float pos_x;
	float pos_y;
	float pos_z;
	float rot_x;
	float rot_y;
	float rot_z;
	unsigned int buttons;
};
int init();
void poll();
unsigned int getDeviceCount();
unsigned int getDeviceType(unsigned int deviceIndex);
ConnexionState getState(unsigned int deviceIndex);
ConnexionState getStatePrevious(unsigned int deviceIndex);
unsigned int buttonPressed(unsigned int deviceIndex, unsigned int button);
unsigned int buttonReleased(unsigned int deviceIndex, unsigned int button);
unsigned int buttonDown(unsigned int deviceIndex, unsigned int button);
void setLED(unsigned int deviceIndex, unsigned int value);
void setRotationPower(unsigned int deviceIndex, float p);
void setTranslationPower(unsigned int deviceIndex, float p);

This is where I still applaud Microsoft for the XInput API. Unlike almost every other API they've made, XInput is so incredibly simple to use. No setup/init. One function call gives you the state of every part of an xbox controller in a simple struct. One function call lets you set haptics. Shame it doesn't support other brand devices like DirectInput does.

Bulletproof answered 15/6, 2022 at 5:38 Comment(0)
C
0

Side note, I don't understand these SDKs that are so over-engineered. I just want a single header file, like 5 functions, and a simple command-line sample. Not sure why they have to make things so obtuse.

Cindy answered 15/6, 2022 at 5:44 Comment(0)
B
0

Cindy Back a long time ago I got a TrackIR (head tracker camera for flight sims).
I wanted to add support to my college game engine.
I had to apply to be a developer (they hand picked them). They wanted me to sign an NDA, because the C++ header of their API contained proprietary secrets or some crap. WTF? All I needed was an init function and something to return 6 floats. There's nothing else the device needs to be used.
They also said not only could I not allow any student to see their header, but also no co-worker at the college could see it. I'd have to make my own binary only API that wrapped their API and keep the source secret.
I never responded after I read that.

Later I found out that they were so paranoid about their software that they made the camera (a USB IR webcam) only turn on if you sent a copyrighted haiku to it, so any third party drivers could be sued for copyright infringement. They also extorted companies like Eagle Dynamics (DCS flight sims) to remove support for competing alternative head tracking devices under threat of their games being blacklisted by the TrackIR driver.

Urgh.

Still not my strangest contract. I bought a Beagleboard (the spiritual ancestor of the Raspberry Pi that started the small ARM SOC board craze). But due to some encryption code in the firmware, the US treated it as a military device for export and to get it shipped to Australia I had to sign a document from the Department of Energy that said I had no dealings with a list of known terrorist collaborator companies. Also I saw the term "weapons of mass destruction" in the doc at least once. It was a tiny arm board equivalent to maybe an iphone 3.
I've still got the Beagleboard on my shelf, never really used it for anything (it was going to be a dev kit for the Pandora handheld, but then my Pandora shipped).

Bulletproof answered 15/6, 2022 at 7:57 Comment(0)
C
0

Yeah. Then these companies wonder why they go out of business.

Cindy answered 15/6, 2022 at 8:9 Comment(0)
C
0

I got HIDAPI working. It only took a few hours, way easier than I thought. Everything is hard-coded for my device though, so it will take some time to configure for all the various models. I found this code, which has the product and vendor ids, which is a great help.

https://github.com/johnhw/pyspacenavigator/blob/master/spacenavigator.py

It also has some of the different mapping formats of the data. However, my device seemed to work differently (even though it is listed there with the correct VID/PID). The axes were not in the right order (meaning not x, y, z) and some were negated. I did get it all working, but I expect that not all devices conform to this format, as you can see in the link above. I have one older wired Space Navigator, so I can try that later. That should give me an idea, but there are like 8 or so devices I would need to support.

Also, HID has WAY better performance than the libspnav. There is no more choppiness and everything is butter smooth at 144Hz. So that is a nice bonus. And the code should compile on Windows and macOS, but I will have to verify that tomorrow. So this was definitely the right plan.

Cindy answered 17/6, 2022 at 23:8 Comment(0)
B
0

Cindy
Yep, I believe the protocol changed when they went from Space to SpaceMouse. The event 3 (buttons and long press buttons) changed to event 28 (buttons) and 29 (long press buttons).

Hehe, I clicked that link, firefox showed me I already had it bookmarked. πŸ™‚

Bulletproof answered 18/6, 2022 at 1:16 Comment(0)
C
0

Well, I'm not planning on supporting buttons, just axis control, so that simplifies things. If there are only two protocols for the axis that should be simple. I just don't want to deal with trying to support a bunch of devices I don't own. But I think there is enough open source examples for me to attempt it with what I have.

Also, I noticed that the movement is not exactly the same. All I did was make a new shared lib, I left the interface the same, so I just dropped it into my plugin and everything basically worked. However it feels very different. I think libspnav was doing some sort of low pass filter or clamping or something. Because it was choppier before, but not noisy. Now it is super smooth, but things seem to move in unintended directions. So I'll have to look into that next, maybe tomorrow. But I have the basic code working, it just a matter of tweaking some numbers.

Cindy answered 18/6, 2022 at 1:25 Comment(0)
B
0

That's why my input library has a rather odd collection of devices it supports, so far only things I directly own. πŸ™‚

I do find the values are jittery when looking at them directly, but I've never noticed it when using them to control things.

A couple of other things to consider if you haven't already done so:
The range of the axes can vary, not just by model but individual device. The general range is considered to be -350 to 350, but for example my space pilot pro vertical axis has a range of around -410 (up) to 532 (down), but I have to push very hard on it to hit those extremes. The X axis is similar, left has a smaller range than right.
What I do is start with -350 to 350 as the min/max for each axis. If I get a larger value, I adjust the range to fit it. The returned values from my lib are then scaled to fit -1.0 to 1.0 to the current range.

Also making the axes nonlinear can be good. Put a power curve on it so small movements from centre have less effect. The official app only lets you change scale, mine has user specified power as well.

Here's my input test app where I reverse engineer these things. πŸ™‚

Bulletproof answered 18/6, 2022 at 2:40 Comment(0)
C
0

Okay, cool. I think I see the issue. I have a command line app just printing values, and I see some odds one when barely moving the puck. Like it will be at 0 and then jump to 94 or some high number when I am only slightly touching it. So maybe my code is not correct, or there is some conversion issues. Because the numbers look fairly plausible most of the time but seem biased in one direction and then also extremely noisy at close to zero. It's getting late, though, I will investigate tomorrow. Thanks for the advice.

Cindy answered 18/6, 2022 at 5:0 Comment(0)
K
0

Pretty sure the windows driver & control software will run a calibration step on first launch, and it's not optional.

Konopka answered 18/6, 2022 at 7:56 Comment(0)
C
0

Yeah, i was considering that. I'll have to look at the code that is available and see if there is a way to calibrate if there are hardware irregularities.

Cindy answered 18/6, 2022 at 16:53 Comment(0)
C
0

Okay, I figured it out. It had nothing to do with the hardware or any of the HID code. It was just some bad matrix math in my GDScript plugin. How it ever worked in the first place is beyond me.

Cindy answered 18/6, 2022 at 23:22 Comment(0)
C
0

So I got the original Space Navigator wired to work, with the old 2 channel format. I also added an array for device/vendor IDs, right now it only has the 2 I own, but it's all dynamic so I just have to plugin the hex codes for the rest of the models and it should all work. Going to test one other thing tonight, but it's pretty much finished (at least on Linux). Tomorrow I will compile for macOS and Windows, which should just work since it's standard C code, but you know how that goes.

Cindy answered 19/6, 2022 at 6:22 Comment(0)
C
0

Got Windows compiled and it's perfect. Amazingly, I didn't have to modify the code at all. Standards for the win!

Cindy answered 19/6, 2022 at 23:48 Comment(0)
C
0

Well, I got Mac to compile, but it's not good. My code works, but the system is doing all weird stuff. If you have the official 3Dconnexion drivers installed, then it takes over control and leaves the device open, meaning I am not able to connect to it. I'm not sure why this is, on Windows it works fine with multiple apps having access (just not at the same time). On Windows you can also disable specific apps or the whole driver itself. But on Mac there are limited options, it is very bare-bones compared to Windows, and people on the forum said the only way was to uninstall completely.

That would be fine, except without the official driver on Mac, the Space Mouse does some sort of mouse cursor emulation by default. So while I can connect to it via HID, and that works, it is also moving the mouse around, rotating the camera, zooming in, etc, wildly. And I'm not sure why that is. But even if I could disable it, most people that have devices like this are using them for 3D modeling work, so it would be too much to ask them to uninstall the driver just for a Godot plug-in.

So I don't know. I spent all day on this, but it's getting late to figure this out. At least Linux and Windows are fully working. I will have to see what I can do about Mac. I don't want to release unless it's cross-platform, especially since I know these devices are popular with designers that are likely on Mac. I saw there was some config XML file the driver uses, so I might be able to blacklist Godot. It's kind of a hack, but at least I have a lead.

Cindy answered 20/6, 2022 at 4:29 Comment(0)
K
0

#JustOneOFThoseAppleThingsβ„’

Konopka answered 20/6, 2022 at 5:46 Comment(0)
C
0

Yes, well, I can't stand Apple or anything about their computers, but I'm not going to release an app unless it works on all platforms. I mean, if I really can't figure it out after a couple days we will see, but I don't like apps that are only on one OS, it seems rude to users.

Cindy answered 20/6, 2022 at 5:58 Comment(0)
C
0

Grampus Do you have any experience with the Space Mouse on macOS? I am wondering if I am missing something or it's really this messed up. See 3 posts above. Thanks.

Cindy answered 20/6, 2022 at 7:31 Comment(0)
B
0

Cindy
Never even tried plugging a space mouse into a mac.

Maybe try calling

hid_darwin_set_open_exclusive(0);

before opening the device. Apparently that was added to hidapi in march, after 3 years of people discussing problems with shared access to hid devices on macs.

But that's just me with google, I avoid mac development. πŸ™‚

Bulletproof answered 20/6, 2022 at 8:30 Comment(0)
C
0

Thanks, Grampus . That seemed promising, but was already in the code. I also tried setting it to 1, but it was the same. Will have to keep looking.

Cindy answered 20/6, 2022 at 16:17 Comment(0)
C
0

I looked all on Github and I see what the issue is. The official driver on macOS (starting with Big Sur) opens the Space Mouse in exclusive mode, so there is nothing I can do to get access via HIDAPI after that point. This is unfortunate, but at least I know it's not a bug in my code. Maybe I will see if I can disable the mouse emulation so it will at least work if you uninstall the driver.

Cindy answered 20/6, 2022 at 16:52 Comment(0)
B
0

Cindy
Is there any kind of per app configuration on the mac connexion software?
On windows, the app has that pic I posted above. The default for all non connexion aware software is the pitch axis is enabled and does mouse wheel emulation, everything else is disabled. You can turn it off manually if you get double input (HID and mousewheel).
The app configurations are stored in xml files, so maybe you can make a godot config file that just turns everything off for godot. I have no idea where a mac would store those though (if they even exist on a mac). For windows, the files are at C:\Users\kojack\AppData\Roaming\3Dconnexion\3DxWare\Cfg\

Edit: wait, no, you are talking about when the drivers aren't installed. Ignore all that.
I guess macs are treating it as a generic HID device themselves and add default support.

Bulletproof answered 20/6, 2022 at 19:59 Comment(0)
C
0

So, yes, I considered that. The Mac app is more limited, it's not like Windows where you can enable/disable axis and stuff. Even if you could, that doesn't help, cause the service starts at boot and attaches with exclusive access. So AFAIK there is no way to get it to work with the driver installed. I saw a few people with the same exact issue and there is no work around.

That said, I was able to get it working without the driver. I just had to connect to it with exclusive access, and then that disables the mouse cursor emulation. I would have liked to get the driver working too, but for that I would need the official SDK and I don't feel like doing that at this point. One cause there are license concerns, and two I don't really feel like supporting their software with the way they treat non-Windows users. Also having to support two code paths in the library. Not worth my time.

So it's all working and tested on Windows, Linux, and macOS, with both the new wireless model Space Mouse and the older Space Navigator. Those are the only formats, so, in theory, most of the other devices should work as well, but I'll have to get feedback as I don't have the hardware. I'm working on a video now, and the Github page, should be up in a few hours.

Cindy answered 20/6, 2022 at 21:45 Comment(0)
C
0

It's been released!

https://github.com/cybereality/godot-space-mouse

Cindy answered 21/6, 2022 at 4:5 Comment(0)
K
0

Well, it kinda works. Most things being inverse and wayyyyy too sensitive. πŸ˜ƒ

Konopka answered 21/6, 2022 at 6:54 Comment(0)
C
0

Strange. I tested the old wired (same one I sent you) and the new wireless model, on Windows, Linux, and macOS. This was designed for Godot 3.4.4 but it should be compatible, I don't think the API changed. Can you list out the relevant specs of your machine (OS and version, Godot version, etc.)?

Cindy answered 21/6, 2022 at 7:44 Comment(0)
C
0

Also, check Github again. I updated the Readme with some OS specific instructions.

Cindy answered 21/6, 2022 at 7:46 Comment(0)
C
0

Konopka Well, it kinda works. Most things being inverse and wayyyyy too sensitive.

I also tested on 60Hz and 144Hz monitors, but since the update happens in Godot (in _process()) there may be some timing issues if you have a weird refresh rate. What kind of monitor do you have?

Cindy answered 21/6, 2022 at 9:38 Comment(0)
C
0

Lyall If you're on Windows, you have to open the 3Dconnexion driver after you open the Godot editor. Then click the settings, it should show a popup for the godot-x86_64.exe. In there, uncheck everything, so that you don't get double control.

Cindy answered 21/6, 2022 at 10:3 Comment(0)
K
0

Cindy Strange. I tested the old wired (same one I sent you) and the new wireless model, on Windows, Linux, and macOS. This was designed for Godot 3.4.4 but it should be compatible, I don't think the API changed. Can you list out the relevant specs of your machine (OS and version, Godot version, etc.)?

I'm pretty sure it's just up to expectations and preferences. I tend to think in terms of moving and manipulating the camera rather than the object/world which causes everything to feel inverse to my brain. In other words: it's psychosomatic.

edit: well, the sensitivity might be to do with my device being new and underused. Hasn't "worn in" yet perhaps so still overly sensitive.

Konopka answered 21/6, 2022 at 10:38 Comment(0)
K
0

Cindy I also tested on 60Hz and 144Hz monitors, but since the update happens in Godot (in _process()) there may be some timing issues if you have a weird refresh rate. What kind of monitor do you have?

75hz Freesync over HDMI and radeon chill is set to 'on', targeting 50 to 75 range in global profile. But godot reports pretty much a constant 75fps update anyways.

Konopka answered 21/6, 2022 at 10:42 Comment(0)
C
0

Konopka I'm pretty sure it's just up to expectations and preferences.

I could see that. I've been using the Space Mouse off and on for like 15 years, so I am very comfortable with it. When I first got it it did seem very fast, but it's just sensitive. Also note that the focus/pivot is on the selected object (or the world origin, if nothing is selected). The movement will slow down as you get closer to the object.

I tried to tweak it to get a balance where you could still control and get up close to something down to like 10cm but it would still feel okay up to like 10m. If you go too far out it will get fast, so if you have a large level you might have to click on an object closer to the camera.

I wanted to add sliders to adjust the speed, but it doesn't look like you can export variables in editor plugins. My only option was to make a new dock, where I could attach settings. I might still want to do that, depending on the feedback I get. In the meantime, you can open the file addons/spacemouse/SpaceMouse.gd and look for these two variables.

const translate_speed = 0.1
const rotate_speed = 0.02

Feel free to change them if you like (you will have to enable/disable the plugin to see the effect). Converting the code to fly the camera is probably a lot more work, but I can look into it. I might have to make that dock anyway, so if that's the case I can put in some other options.

Cindy answered 21/6, 2022 at 10:59 Comment(0)
K
0

Cindy In the meantime, you can open the file addons/spacemouse/SpaceMouse.gd and look for these two variables.
const translate_speed = 0.1
const rotate_speed = 0.02
Feel free to change them if you like (you will have to enable/disable the plugin to see the effect).

I suspect trying to tighten those scalar values down would likely just run into floating point precision issues, but I guess I could try.

Cindy I wanted to add sliders to adjust the speed, but it doesn't look like you can export variables in editor plugins. My only option was to make a new dock, where I could attach settings.

I think in this case, just having a config.ini or just conf(no extension) file in a sort of plain text format would probably be fine.

Konopka answered 21/6, 2022 at 11:4 Comment(0)
C
0

Lyall Grampus
I just pushed version 1.4.1, which adds an editor dock to adjust speed and added a new fly camera mode.
https://github.com/cybereality/godot-space-mouse

Cindy answered 22/6, 2022 at 9:18 Comment(0)
K
0

It might be a good idea to include the version number in the release zip file name.

Edit: yeah this is a huge QoL improvement! the camera mode with some speed adjustments makes a big difference. πŸ™‚

Konopka answered 22/6, 2022 at 12:29 Comment(0)
B
0

Haven't tried it yet, but I will. πŸ™‚

Bulletproof answered 22/6, 2022 at 12:52 Comment(0)
C
0

Konopka It might be a good idea to include the version number in the release zip file name.

Yeah, good call. I updated the zip names.

Cindy answered 22/6, 2022 at 13:23 Comment(0)
C
0

Bulletproof Haven't tried it yet, but I will. πŸ™‚

Yes, please do. There is a very small market for people with Space Navs that are also using Godot.

Cindy answered 22/6, 2022 at 13:24 Comment(0)
B
0

Cindy Market segment of 3? πŸ™‚

Bulletproof answered 22/6, 2022 at 14:14 Comment(0)
K
0

Hey, it's a start!

Konopka answered 22/6, 2022 at 21:31 Comment(0)
B
0

It's working fine for me.
Windows 10, Godot 3.4.4, both Space Navigator and Space Pilot Pro.

One thing that would be nice is saving the settings.

Does Godot support addons that are project independent? Unity pretends to not do addons that are outside of the project (so the tool is available in all projects automatically), but there's an undocumented way to do it (I use it for my Unity Connexion plugin) which Unity provides for its own editor addons.

Bulletproof answered 25/6, 2022 at 2:23 Comment(0)
C
0

Oh yeah, I could save the settings, it wouldn't take long. I wanted more people to test it and give feedback before I submit to the asset library. So far I only got you two here that I know tried it. Some other people mentioned they were going to download, but I never heard back from them.

I believe the plug-ins are project specific. But once it is on the asset library, you can click one button in the editor and it will install itself. So that is good enough for me, but I can double check if there is some global way to do it.

Cindy answered 25/6, 2022 at 3:24 Comment(0)
B
0

Cindy
One of the issues I had with project based addons in Unity was when I wanted to use it with student projects. It got annoying to have to modify many student projects to do something that is unrelated to the project. Plus being careful to not include it when pushing changes I might make to the project.
Unreal, 3DSMax, Maya, Blender, Sketchup, Visual Studio, etc all let you install addons to the editor itself.
Obviously not something you can do if Godot doesn't support that, just something I've run into before. Ideally both would be supported, project payload addons and global editor addons.

You could probably go on the Connexion dev forums and ask if anyone wants to try it out. https://forum.3dconnexion.com/

Bulletproof answered 25/6, 2022 at 4:11 Comment(0)
C
0

Thanks. I'll give it a try later.

Cindy answered 25/6, 2022 at 5:7 Comment(0)
C
0

Configuration is now saved on exit.
https://github.com/cybereality/godot-space-mouse

Global editor plugins are not possible, however.

Cindy answered 26/6, 2022 at 5:26 Comment(0)
C
0

I got the Xbox controller technically working, but it's really bad. I mean, it works, but it felt really bad and not much better than just using the mouse. Not sure it's worth investigating any further, but maybe I will take another look tomorrow.

Cindy answered 28/6, 2022 at 6:33 Comment(0)
C
0

So I'm considering this project done. The 1.4.3 version is on Github and can now be installed directly in the Godot editor via the Asset Library tab.
https://godotengine.org/asset-library/asset/1383

Also, just in case anyone finds this by search and is working on something similar, the vendor and product ids for all Space Mouse devices are listed on the 3Dconnexion FAQ:

Keyboard Pro: USB\VID_256F&PID_C664\…
Numpad Pro: USB\VID_256F&PID_C665\…
CadMouse Pro: USB\VID_256F&PID_C656\…
CadMouse Compact: USB\VID_256F&PID_C655\…
CadMouse Compact Wireless: USB\VID_256F&PID_C658\…
CadMouse Pro Wireless: USB\VID_256F&PID_C654\…
CadMouse Pro Wireless Left:  USB\VID_256F&PID_C657\…
SpaceMouse Enterprise: USB\VID_256F&PID_C633\…
CadMouse: USB\VID_256F&PID_C650\…
CadMouse Wireless: USB\VID_256F&PID_C651\…
Universal Receiver: USB\VID_256F&PID_C652\…
SpaceMouse Compact: USB\VID_256F&PID_C635\…
SpaceMouse Pro Wireless Receiver: USB\VID_256F&PID_C632\…
SpaceMouse Pro Wireless (cabled): USB\VID_256F&PID_C631\…
SpaceMouse Wireless Receiver: USB\VID_256F&PID_C62F\…
SpaceMouse Wireless (cabled): USB\VID_256F&PID_C62E\…
SpaceMouse Pro: USB\VID_046D&PID_C62B\…
SpacePilot Pro: USB\VID_046D&PID_C629\…
SpaceExplorer: USB\VID_046D&PID_C627\…
SpaceNavigator: USB\VID_046D&PID_C626\…
SpaceNavigator for Notebooks: USB\VID_046D&PID_C628\…
SpaceTraveler: USB\VID_046D&PID_C623\…
SpacePilot: USB\VID_046D&PID_C625\…
SpaceBall 5000 USB: USB\VID_046D&PID_C621\…
SpaceMouse Plus USB: USB\VID_046D&PID_C603\…
SpaceMouse Plus XT USB: USB\VID_046D&PID_C603\…
SpaceMouse Classic USB: USB\VID_046D&PID_C606\…
CadMan: USB\VID_046D&PID_C605\…

https://3dconnexion.com/uk/support/faq/how-can-i-check-if-my-usb-3d-mouse-is-recognized-by-windows/

I already have the 7 most popular devices on my plug-in (the standard consumer models) but I may update my product id database in the future. I am just pretty busy and most of those are CadMouse and stuff I don't think Godot users are using. However, I will update at some point.

Cindy answered 7/7, 2022 at 5:49 Comment(0)
C
0

Wait, it looks like they are still testing it. You can download from Github for now.

https://github.com/cybereality/godot-space-mouse

Cindy answered 7/7, 2022 at 5:52 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.