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

Support for other 3dconnexion products #1

Open
herbertwest3 opened this issue Jan 12, 2016 · 23 comments
Open

Support for other 3dconnexion products #1

herbertwest3 opened this issue Jan 12, 2016 · 23 comments
Assignees

Comments

@herbertwest3
Copy link

It would seem simple to support other SpaceMouse products by adjusting the vendor and product ids for the HID device. I tried 0x256f,0xc62e and 0x256f,0xc62f for the SpaceMouse Wireless, and was then able to turn on and off the LED with set_led() but never received any data callbacks. Any thoughts? Would love to get this working; pyspacenavigator is exactly what I need.

@johnhw johnhw self-assigned this Jan 12, 2016
@johnhw
Copy link
Owner

johnhw commented Jan 12, 2016

Yes, it should be easy enough. I'll make some changes to support multiple device types. I think the data encoding (or at least the channel IDs used) might be different for your device, but it is easy enough to determine this. I'll add a script that dumps the raw HID stream to terminal so you can see what changes are happening when you move the Wireless, and then I can modify the callback code to work with that output.

@johnhw
Copy link
Owner

johnhw commented Jan 13, 2016

OK, the latest version (0.1.5) can support multiple devices. We just need to work out what the format for the Wireless device is. If you run the raw_data.py script from pywinusb you should be able to see the raw data stream from the device.
The format seems to be
[channel, a1, a2, b1, b2, c1, c2], where a1,a2 etc form a 16 bit values. The buttons on my device are just:
[channel, button_bits, 0, 0, 0, 0, 0]

If you can work out what the values are for the 6 axes and buttons on your device, you can add a new entry to device_specs in spacenavigator.py; send a pull request and I'll add it in. (or post them here and I can add them in)

@herbertwest3
Copy link
Author

(i just noticed the above replies hiding in my inbox). thank you, i will take a look as soon as i can and feed back some information to you.

@PaulMichaelPhillips
Copy link

Hi @johnhw

I am trying to get this to work with a wireless SpaceMouse. It connects successfully (once the id's have been changed) but the data once formatted is always 0. Do you have an idea as to what alteration is required to get the data formatted correctly?

Regards,
Paul

@johnhw
Copy link
Owner

johnhw commented Jan 4, 2018

Can you run the raw_data.py script mentioned above (from the pywinusb package) to dump the HID stream while you adjust the SpaceMouse? If you adjust the mouse on each axis (as best you can) and try each button, you should be able to see which channels are carrying the axis data. I assume a new entry in the device_specs dictionary will be required to support the device.

@PalantirWielder
Copy link

PalantirWielder commented Mar 3, 2018

Hey there @johnhw,
Today I was looking around for ways to access my SpaceMouse Pro Wireless' values and I came across your library. It's pretty cool.

I also tried to use the library with my SpaceMouse but:

  • The VID & PID needed to be changed for my device
  • I too was getting all zeroes in the read values

So following your suggestion for using raw_hid.py I was able to reverse out the protocol alterations for the 6-axes and the 15 buttons. I've since updated my local spacenavigator.py to decode and output the 6-axes values. And I'm in the process of designing how to integrate the multiple buttons into your code with the smallest code disturbance.

  1. Once I've completed the code alteration I'll fork your library so you can see the changes. In addition to that, would you be interested in my creating a Pull Request to submit the fork, after we discuss any alterations that you'd like?

  2. My current plan is to simply alter the code to work only with the SpaceMouse Pro Wireless that I'm working with. Once you've had a chance to look over my code, I'd be interested to hear any suggestions for having the two different devices co-exist in the code. I think the key difference will be in how buttons are specified in the different device configurations.

  3. Do you have a vision for how I could extend your code to handle the 15 buttons that my device has? I'm sure I could come up with something on my own, but perhaps you'd have a more concise design given it's your code.

Just let me know how you'd like to collaborate, if at all.

@johnhw
Copy link
Owner

johnhw commented Mar 3, 2018

@PalantirWielder
Yes, very happy to have this added. Please make a PR.

I have just modified the code (1c815eb) to make the button state be a list of (binary) integers, which will make it easier to support 15 buttons. The old code could support multiple buttons by adding new entries into the button_mapping list, but this will end up packed into a single integer as a bit array which is pretty inconvenient.

With the tweaked code, just add the buttons into button_mapping, specifying the byte+bit of the HID event to look at, and the button state will be written into that element of the button vector.

Note all that you need to is add a new entry to device_specs for the SpaceMouse Pro Wireless. It will then autodetect the right device and use it; you don't need to change or remove the SpaceNavigator.

@PalantirWielder
Copy link

PalantirWielder commented Mar 4, 2018

@johnhw
Excellent. I've downloaded your latest code and ported my changes over to the new format. I'll test the SpaceMouse Pro changes tomorrow.

I have a SpaceNavigator on hand, so I tested that in the meantime. Assuming that I'm correctly understanding the formatting of the ButtonSpec, I believe that there were a few changes that weren't implemented to handle the new format. I updated the SpaceNavigator's device_specs for button_mapping so that it had a ButtonSpec for each of the two buttons. I then propagated that change through the code to restore the testing button_callback functionality.

All these changes will be in the PR I'll file after I can confirm the SpaceMouse Pro code works as desired.

Thanks for the quick response!

@PalantirWielder
Copy link

@johnhw
I've forked the repository, made the changes to the code, and tested it on both the SpaceMouse Pro Wireless, as well as the SpaceNavigator (3DX-700028).

The SpaceMouse Pro appears to work as desired.

One thing that popped up was the value scaling of the aforementioned SpaceNavigator. When moving the puck to it's extremes, I noticed that the values were of a greater magnitude than 1.0.
I then changed the scaling to 1.0 temporarily and looked for the min/max values for each axis:
x [-441.0, 446.0]
y [-471.0, 498.0]
z [-458.0, 445.0]
roll [-454.0, 409.0]
pitch [-439.0, 445.0]
yaw [-420.0, 413.0]

I also jumped to a commit prior to your recent changes, and the scaling phenomenon was still present. Is it a problem if the output values are greater than 1.0?

Since functionality appears to be working properly, beside the odd scaling quirk, I'll go ahead and file a PR. Then in that thread we can discuss any additional changes you'd like made before the merge.

@johnhw
Copy link
Owner

johnhw commented Mar 6, 2018

Thanks for the PR! I will investigate the SpaceNavigator scaling issue on my device -- perhaps the device axis range is different on different versions or can be user modified?

@johnhw
Copy link
Owner

johnhw commented Mar 6, 2018

Hmm, can't see why the SpaceNavigator would report these values -- mine maxes out at [-350.0, 350.0], and so scales to exactly [-1.0, 1.0] with the default scaling. The latest commit prints out the vendor name, device name and version number as reported by the device itself. I get:

 SpaceNavigator connected to 3Dconnexion SpaceNavigator version: 1077 [serial: ]

Do you have a different HW version? It could also be that the range is configurable in firmware.

@PalantirWielder
Copy link

My pleasure! It nice when my work can be contributed back to the community.

  1. When I went to execute the updated code, it failed to run because serial_number is considered unicode, and the value that it contains wasn't a known character, on my system at least.
Devices found:
        SpaceNavigator
SpaceNavigator found
Traceback (most recent call last):
  File "spacenavigator.py", line 347, in <module>
    print(dev.describe_connection())
  File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u0000' in position 78: character maps to <undefined>

FYI, I changed the serial number to all zeroes when I pasted it here

  1. After working around that issue, I received this output:
    SpaceNavigator connected to 3Dconnexion SpaceNavigator version: 1028

So yes, it is a different version. Not sure if that's a firmware version or a hardware version, but it is different.

@PalantirWielder
Copy link

Oh, and one other thing. I don't believe the SpaceMouse Pro has a controllable LED, unlike the SpaceNavigator. Is there a way to verify that there is no interface to one?

@giant99
Copy link

giant99 commented Jun 28, 2018

Hello, I'm trying to modify the code to include the SpaceMouse Enterprise. I have added SpaceMouse Enterprise to the supported devices list and now it recognizes it. But nothing else is happening. I have run the raw_data.py script as suggested and Have the following strings
Raw data: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
When using the device the channel remains 1 for the axis directions
If we set object moving left-right as X axis, zoom in-out as Y axis, and up-down as Z axis then
Raw data: [1, X, X, Y, Y, Z, Z, R, R, P, P, Y, Y]

Please let me know where I need to change the code. I'm not really familiar with working with this level of complicated scripting.

Thanks

@aephchw
Copy link

aephchw commented Nov 23, 2018

Hi,
thank you johnhw for your work!
I am trying to use it with the SpaceMouse Enterprise but can't succeed.
@giant99: could you figure it out?
Thanks in advance

@johnhw
Copy link
Owner

johnhw commented Nov 23, 2018

@aephchw you might want to look at the automatic branch. It will autodetect the device capabilities from the HID usage pages for any detected device. Unfortunately, I can't get buttons to work correctly with this mode on Windows, but it should be enough for you to get the axes specifications to use in the master branch version.

@aephchw
Copy link

aephchw commented Nov 23, 2018

ok, thank you. Until now I already figured out how to connect with it and read its status which already works fine for me (I don't need the buttons, just x,y,z coordinates).
Currently I am not sure, if the axis are correct as I copied them from the SpaceMouse Pro, but at least I do get values.
Next step is implementing it in a GUI..

@giant99
Copy link

giant99 commented Dec 3, 2018 via email

@Mindbulletz
Copy link

My 3dconnexion device (SpaceMouse Wireless) creates six nearly identical devices. vID=0x256f, pID=0xc652, for each one. Only one of them outputs the data.

I've created a profile for the device already, but I can't figure out how to select between the device's instances more granularly than vID and pID. Is there one in pyspacenavigator or am I better off custom-writing something based on the raw_data.py example?

@TheOfficialDarthVader
Copy link

I've noticed the code here on GitHub includes support for the SpaceMouse Compact but this is not the case when installing the library with pip

@levinivel
Copy link

Hi, can you add the product "SpaceMouse Module USB" (https://3dconnexion.com/us/product/spacemouse-module/) as well to the list? This version is not supported by 3DConnexion's libraries, so a solution such as pyspacemouse is perfect for those users.

@Niyati20
Copy link

Niyati20 commented Sep 26, 2023

Anyone figure out how to use Spacemouse Enterprise with Pyspacemouse or add it to this library?

@bksel
Copy link

bksel commented Dec 8, 2023

Hi, would it be hard to implement support for SpaceMouse Enterprise with all its basic keys - the same ones that are with SpaceMouse Pro? Would it be matter of switching parameters defined for SpaceMouse Pro, or it would be harder?

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