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.
3Dconnexion Space Mouse Support in Godot
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.
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.
Got Windows compiled and it's perfect. Amazingly, I didn't have to modify the code at all. Standards for the win!
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.
#JustOneOFThoseAppleThings™
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.
@Kojack 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.
- Edited
cybereality
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.
Thanks, @Kojack . 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.
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.
- Edited
cybereality
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.
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.
- Edited
Well, it kinda works. Most things being inverse and wayyyyy too sensitive.
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.)?
Also, check Github again. I updated the Readme with some OS specific instructions.
Megalomaniak 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?
@Megalomaniak 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.
- Edited
cybereality 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.