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

Rotation not working for SpaceNavigator Wireless in editor and playmode #31

Open
JiapengChi opened this issue Jul 20, 2021 · 20 comments
Open

Comments

@JiapengChi
Copy link
Contributor

Describe the bug
Hi, I tried the Fly Around sample scene, but I noticed that I cannot rotate the camera or the target sphere. I printed the SpaceNavigatorHID.current.Rotation.ReadValue(), which was always (0.0, 0.0, 0.0). So was in the Input Debugger.

Did I do something wrong?

Desktop:

  • OS: Windows 10
  • SpaceNavigator Driver version 2.0.0-beta.7

Thank you so much.

@PatHightree
Copy link
Owner

Is your device a SpaceNavigator or another variant ?

@JiapengChi
Copy link
Contributor Author

@PatHightree Yes, I am using the 3DConnexion SpaceNavigator.

@PatHightree
Copy link
Owner

Can you rotate the camera in the sceneview ?

@JiapengChi
Copy link
Contributor Author

@PatHightree Sorry, cannot do it. Unity cannot get any rotation vectors from the SpaceNavigator.

@PatHightree
Copy link
Owner

PatHightree commented Jul 20, 2021

Maybe there is a hardware variation.
Can you please install the Input Device Helper from the samples in the package manager.
Run it via the Window/SpaceNavigator/Save all HID descriptors to files pull-down menu.
Then attach the json file for the SpaceNavigator to this issue.
Thanks.

@JiapengChi
Copy link
Contributor Author

@PatHightree Here it is: https://www.dropbox.com/s/us3kru5fch6q50r/SpaceMouse.json?dl=0

Thanks!

BTW: Can this driver work with Spacemouse Enterprise?

@PatHightree
Copy link
Owner

Strange, this json file doesn't look like mine at all, even the vendorId and productId are different.
Can you check whether this is the correct file ?
Mine starts with
"vendorId": 1133,
"productId": 50726,
Yours is
"vendorId": 9583,
"productId": 50739,

The driver might support the Spacemouse Enterprise as is, if it uses the same data layout as the SpaceNavigator.
If it doesn't, please open a new issue and attach the corresponding json file and I will try to add support for it.

@JiapengChi
Copy link
Contributor Author

Hi @PatHightree,

I have tried several different data formats to fetch the rotation, only QuaternionControl can get something with positive infinity and negative infinity. I guess they may change the data format for the rotation operations of SpaceMouse wireless and SpaceMouse Enterprise.

Do I need to start a new issue for that?

@PatHightree
Copy link
Owner

PatHightree commented Jul 25, 2021

AH, you're using a wireless SpaceNavigator, that uses a different data layout than the wired version.
On the other hand, I though I had already included support for the wireless version, so maybe I messed that up.
I'll rename this issue to focus it on the SpaceNavigator Wireless.
Please open another issue for the SpaceMouse Enterprise and include the corresponding json file.
Thank you

P.S.
I updated the issue template to include the device type and connection, thanks for that as well :)

@PatHightree PatHightree changed the title Cannot Rotate in Fly Around Scene Cannot Rotate in Fly Around Scene on SpaceNavigator Wireless Jul 25, 2021
@unsetlay
Copy link

Hi, I am using the SpaceMouse wireless and getting the same issue, too.
I can not rotate the view using spacemouse wireless, should I open a new issue or provide some info to help?

@JiapengChi
Copy link
Contributor Author

Hi @PatHightree ,

Actually, I am using SpaceMouse wireless with wire, but neither of the two scripts in the project can get the rotation data.

I will start a new issue.

Thanks!

@PatHightree
Copy link
Owner

@unsetlay
Thanks, no further actions needed right now. G
ood to know we have another SN Wireless available for testing a fix.

@JiapengChi
The data format is device-specific, shouldn't matter if it's actually connected wired or wireless (afaik).
I want to use one issue per hardware variation, so I'll use this one for the SN Wireless and the new one for the SM Enterprise.

@PatHightree PatHightree changed the title Cannot Rotate in Fly Around Scene on SpaceNavigator Wireless Rotation not working for SpaceNavigator Wireless in editor and playmode Jul 26, 2021
@loopervfx
Copy link

loopervfx commented Aug 8, 2021

@PatHightree I am also able to repro this issue with SpaceMouse Wireless P/N: 3DX-600044 PID: A4318303087 on Windows 10. I am happy to test when a fix is in the works.

As a workaround, if someone needs a live repo (not the old unitypackage) that you can at least have Scene View functionality for SpaceMouse using the 3DConnexion Driver on Windows, I am using this fork: https://github.com/Dinomite-Studios/space-mouse-unity. You must paste https://github.com/Dinomite-Studios/space-mouse-unity.git in the + Add package from git URL.. entry field.

@JiapengChi
Copy link
Contributor Author

Hi @PatHightree ,

May I ask what kind of tool you use for reverse engineering of HID device events?

Thanks.

@PatHightree
Copy link
Owner

Just the Unity Input Debug window, the Unity forums and Google

@jondowen
Copy link

jondowen commented Jan 4, 2023

In case this is useful for anyone, I managed to get rotation working with my SpaceMouse Wireless when connected via USB cable.

  • The product ID 0xC652 refers to the Universal Receiver.
  • SpaceMouse Wireless (Cabled) has Product ID 0xC62E (According to this source)
  • Modifying SpaceNavigatorWirelessHID accordingly correctly identified my device in Play mode (when cabled).
  • I haven't tested editor as I don't use it for that.
// Registering the layout
InputSystem.RegisterLayout<SpaceNavigatorWirelessHID>(
	matches: new InputDeviceMatcher()
		.WithInterface("HID")
		.WithManufacturer("3Dconnexion.*")
		.WithCapability("productId", 0xc62e)); 		// SpaceMouse Wireless (cabled)
		//.WithCapability("productId", 0xC652));    // 3DConnexion Universal Receiver

I then found that yaw and roll were swapped, so swapping the offsets for these in SpaceNavigatorWirelessHIDState.ReportFormat1 (like in SpaceNavigatorHIDState.ReportFormat2) got this working properly too:

// 1st report
[InputControl(name = "translation", format = "VC3S", layout = "Vector3", displayName = "Translation")] 
[InputControl(name = "translation/x", offset = 0, format = "SHRT", parameters = "scale=true, scaleFactor=10")] 
[InputControl(name = "translation/y", offset = 4, format = "SHRT", parameters = "scale=true, scaleFactor=-10")]
[InputControl(name = "translation/z", offset = 2, format = "SHRT", parameters = "scale=true, scaleFactor=-10")]
[InputControl(name = "rotation", format = "VC3S", layout = "Vector3", displayName = "Rotation")] 
[InputControl(name = "rotation/x", offset = 6, format = "SHRT", parameters = "scale=true, scaleFactor=-80")] 
[InputControl(name = "rotation/y", offset = 10, format = "SHRT", parameters = "scale=true, scaleFactor=80")] 
[InputControl(name = "rotation/z", offset = 8, format = "SHRT", parameters = "scale=true, scaleFactor=80")]
public ReportFormat1 report1;

Versions:
Unity 2022.1.24f1
3DConnexion 10.8.11

No joy getting the Universal Receiver working, but I guess that's issue #50.

@FejZa
Copy link

FejZa commented Mar 14, 2023

Thanks a lot @jondowen. This works great in editor and play mode. But in a windows standalone player build rotation does not work, just translation unfortunately. Any chance you solved that as well?

@sagarpatel
Copy link

sagarpatel commented Jan 10, 2024

Thanks @jondowen , this works great on my end too.
I was getting the same problem as @FejZa in a windows standalone build, thankfully this fix mentioned on this page seems to work:
#38

Recap: both translation and rotation working in Play mode as well as Windows Standalone build
using Unity 2023.1.15f1

@jondowen
Copy link

I'm now using Unity 6000.0.2f1 and no longer get the crash when plugging in the Universal Receiver. I've modified the code slightly to register devices for both:

  • SpaceMouse Wireless (Via Cable)
  • SpaceMouse Wireless

Modified code:

static SpaceNavigatorWirelessHID()
{
    // Register a layout with product ID, so this layout will have a higher score than SpaceNavigatorHID
    InputSystem.RegisterLayout<SpaceNavigatorWirelessHID>(
        matches: new InputDeviceMatcher()
            .WithInterface("HID")
            .WithManufacturer("3Dconnexion.*")
            .WithCapability("productId", 0xc652));         // 3DConnexion Universal Receiver
    DebugLog("SpaceNavigatorWirelessHID : Register layout for SpaceNavigator Wireless productId:0xc652");
    
    InputSystem.RegisterLayout<SpaceNavigatorWirelessHID>(
        matches: new InputDeviceMatcher()
            .WithInterface("HID")
            .WithManufacturer("3Dconnexion.*")
            .WithCapability("productId", 0xc62e)); // SpaceMouse Wireless (cabled)
    DebugLog("SpaceNavigatorWirelessHID : Register layout for SpaceNavigator Wireless (cabled) productId:0xc62e");
}

For me, that addresses issue #50, but I don't have any other hardware so can't verify that I haven't broken anything else.

It's very nice to be able to go wireless again!

@PatHightree
Copy link
Owner

Hi Jon, great to hear you're making progress
The project is on the back burner for me at the moment
I may get access to a wireless device some time soon, that might get things going again, we'll see

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

No branches or pull requests

7 participants