magellan-spacemouse icon indicating copy to clipboard operation
magellan-spacemouse copied to clipboard

Request to create firmware for space mouse classic usb

Open Platidors opened this issue 2 years ago • 86 comments

Hello. I assembled hid-remapper for your project on one raspberry pi pico board. Tried connecting my old Space Mouse Classic USB controller. On some computers, the Space Mouse Classic USB is not installed correctly. I tried with the help of your device to solve this problem. Space Mouse certainly didn't work with hid-remapper. I want to ask you to make Space Mouse Compact emulation firmware for Space Mouse Classic USB based on the hid-remapper board. Ready to become a firmware tester.

photo_2023-03-08_22-54-15

photo_2023-03-08_22-56-41

photo_2023-03-08_22-56-51

Platidors avatar Mar 08 '23 19:03 Platidors

Do you have means to dump the HID report descriptor of the device?

On Linux it can be done with usbhid-dump or hid-recorder from the hid-tools package. And on Windows with Wireshark.

Even now you should probably be able to map the device's buttons/axes to mouse or keyboard with HID Remapper, it's just that you have to know the HID usage codes that it sends. Does is show some strange looking hex codes in the input list when it's connected? Like 0x00010033 or something.

jfedor2 avatar Mar 08 '23 19:03 jfedor2

Nice enclosure BTW.

jfedor2 avatar Mar 08 '23 19:03 jfedor2

usb.zip I tried using Wireshark. I don't know if I did it right.

Platidors avatar Mar 08 '23 20:03 Platidors

I can see the device and configuration descriptors (and actual traffic), but not the report descriptor. I think there was some trick to getting it with Wireshark. Did you unplug and re-plug the device while capturing?

jfedor2 avatar Mar 08 '23 20:03 jfedor2

USB2.zip here is the disconnect and connect file

Platidors avatar Mar 08 '23 21:03 Platidors

Yeah, that's it!

So based on this, assuming HID Remapper works with this device on hardware level, when you connect it and just keep the default configuration, the button labelled "1" should work as the left mouse button. If that's working then we can try to make it emulate a modern SpaceMouse so that it works with current software.

jfedor2 avatar Mar 08 '23 21:03 jfedor2

It didn't work for me. Or am I doing something wrong. When a regular mouse is connected, the LED blinks, when a space mouse is connected, the LED does not glow. Button "1" does nothing.

Platidors avatar Mar 09 '23 07:03 Platidors

The single Pico version doesn't work with some devices, even if such cases are rare with the newest version. You could try making the dual Pico variant.

jfedor2 avatar Mar 09 '23 12:03 jfedor2

The dual version HID-remapper will still not work as an emulator. What can be obtained by making a double version?

Platidors avatar Mar 09 '23 12:03 Platidors

We can easily make it into an emulator by changing the output report descriptor (and the USB vendor/product IDs). But it has to be able to receive inputs from your Classic, which the single Pico version seems to have trouble with.

jfedor2 avatar Mar 09 '23 12:03 jfedor2

Okay, I'll try to build a double version tomorrow

Platidors avatar Mar 09 '23 19:03 Platidors

Today I collected a double version. When you connect a space mouse, it starts acting on the cursor. When the puck moves, the cursor moves to the lower right corner, pressing the buttons has the same effect on the cursor. The LED on the remapper starts blinking when the space mouse is actuated.

photo_2023-03-10_16-46-47

photo_2023-03-10_16-46-42

Platidors avatar Mar 10 '23 12:03 Platidors

OK, this is a good sign I think.

Try flashing your HID Remapper with this test firmware:

remapper_dual_a_spacemouse.zip

With this firmware it should pretend to be a SpaceMouse Compact. Because of this you won't be able to use the web configuration tool to change the mappings, but the default passthrough configuration should be good at least to test.

When I tested with a real SpaceMouse Compact connected to it, I noticed some choppiness in the movements so there's probably more to look into, but it worked well enough to fool the 3Dconnexion drivers and Fusion 360.

jfedor2 avatar Mar 10 '23 13:03 jfedor2

After the firmware, the remapper became defined as a compact space mouse. Pressing the buttons and moving the joystick opens the radial menu 3Dconnexion. The object in the programs does not move

Platidors avatar Mar 10 '23 13:03 Platidors

Weird. It's as if we're somehow misinterpreting the data coming from the device, but I didn't notice any strange things in the descriptor or the captured traffic that could be the cause. Let me think of some way to debug this.

jfedor2 avatar Mar 10 '23 14:03 jfedor2

Do you have a USB-TTL adapter by any chance? To read serial output from the Pico?

jfedor2 avatar Mar 10 '23 14:03 jfedor2

Unfortunately, no such device is available.

Platidors avatar Mar 10 '23 15:03 Platidors

It was necessary to flash only part A? When idle, the reassigner constantly sends a report request 2023-03-10 193945

Platidors avatar Mar 10 '23 15:03 Platidors

What's inside these reports (responses in particular)? It might be that there's some noise in the sensors and your device keeps sending reports as well and the remapper passes them on to the PC.

And let me make sure I understood correctly, does the 3Dconnexion radial menu open even when not pressing any buttons on the device (just moving the controller)?

jfedor2 avatar Mar 10 '23 16:03 jfedor2

Yes, any movement of the space mouse classic works out pressing 2 buttons of the space mouse compact

Platidors avatar Mar 10 '23 16:03 Platidors

The report request is constantly even if you disconnect the space mouse from the remapper USB3.zip

Platidors avatar Mar 10 '23 16:03 Platidors

This in itself is not a problem I think. It happens because in the SpaceMouse Classic report descriptor, all the X/Y/Z/RX/RY/RZ inputs are defined as absolute. In the SpaceMouse Compact report descriptor, which we're using for the PC side, they are defined as relative (which is a mistake in my opinion, but it doesn't matter normally). HID Remapper just repeats the last seen state, even if the device that originally generated that state was disconnected.

Maybe I will try and program another HID Remapper to emulate a SpaceMouse Classic, connect it to the first one and see if there's something in the behavior that I missed.

jfedor2 avatar Mar 10 '23 16:03 jfedor2

OK, I've found one issue that was preventing the axes from working properly.

This doesn't explain the button behavior, but at least maybe the rotations/translation will work now.

Try this firmware.

remapper_dual_a_spacemouse2.zip

jfedor2 avatar Mar 10 '23 18:03 jfedor2

The behavior of the joystick on this firmware has not changed. The command to launch the two buttons of the space mouse compact

Platidors avatar Mar 10 '23 18:03 Platidors

Hmm then I'm out of ideas for now.

jfedor2 avatar Mar 11 '23 00:03 jfedor2

I have an arduino nano. I can make a ttl usb converter out of it.

Platidors avatar Mar 11 '23 07:03 Platidors

Sounds like a plan. The default TX pin on the dual HID Remapper is GPIO 0 and the baud rate is 921600 (connect it to the A side Pico). By default it just prints the number of received and sent reports every second. Let me know if you can see that and I'll make a build with some diagnostics.

jfedor2 avatar Mar 11 '23 10:03 jfedor2

Conected image

Platidors avatar Mar 11 '23 12:03 Platidors

It should currently be outputting something like this (in readable ASCII), assuming no inputs are sent:

0 0
0 0
0 0

Not sure what the setup is, but you probably need to set the parameters in the Arduino sketch, not on PC side (baud rate etc.).

jfedor2 avatar Mar 11 '23 12:03 jfedor2

Data bits should be 8 (again, on both sides).

jfedor2 avatar Mar 11 '23 12:03 jfedor2