Low level C library to use SpaceMouse devices
Moderator: Moderators
Low level C library to use SpaceMouse devices
Hello,
I've written an open source low level C library to communicate with SpaceMice. It supports all USB devices and should support all serial devices. It works on Windows and Linux (not well tested yet). It should be trivial to port to macOS - I intend to do that - and should be fairly easy to port to bare metal embedded systems that have a USB host controller.
The library is here: https://github.com/ruevs/libspnavdev
On the page you can see which devices I have already tested on Windows. I would appreciate it if people test the library with other (newer) SpaceMice and report the results here or on the "Issues" tab on GitHub. If you do not want to (or can not) compile the test program you can download the latest automatically built .exe for Windows here https://nightly.link/ruevs/libspnavdev/ ... indows.zip
I would appreciate any feedback and comments.
P.S. If you are curious how the library came about see the "History" at the bottom of the GitHub page.
I've written an open source low level C library to communicate with SpaceMice. It supports all USB devices and should support all serial devices. It works on Windows and Linux (not well tested yet). It should be trivial to port to macOS - I intend to do that - and should be fairly easy to port to bare metal embedded systems that have a USB host controller.
The library is here: https://github.com/ruevs/libspnavdev
On the page you can see which devices I have already tested on Windows. I would appreciate it if people test the library with other (newer) SpaceMice and report the results here or on the "Issues" tab on GitHub. If you do not want to (or can not) compile the test program you can download the latest automatically built .exe for Windows here https://nightly.link/ruevs/libspnavdev/ ... indows.zip
I would appreciate any feedback and comments.
P.S. If you are curious how the library came about see the "History" at the bottom of the GitHub page.
Re: Low level C library to use SpaceMouse devices
Isn't this a fork of John Tsiombikas' spacenav libraries?
Nuno Gomes
Re: Low level C library to use SpaceMouse devices
Not quite. John Tsiombikas did start it here with the intention to abstract the low level device interaction layer from spacenavd. He only set up the API but no functionality (a "hollow shell") and never worked on it again. This year he finally decided to drop/abandon it.
In the meantime I wanted to write one from scratch, found his "empty shell", liked it and "filled it in". The code for serial devices is mostly copy-pate from spacenavd. The USB/HID code I wrote from scratch using HIDAPI as a HAL on Windows/Linux.
See here for details: https://github.com/ruevs/libspnavdev?ta ... le#history
Re: Low level C library to use SpaceMouse devices
The higher layers of spacenavd - those that emulate the 3Dconnexion driver API - are entirely missing from libspnavdev.
Re: Low level C library to use SpaceMouse devices
Got it. Thanks for the clarification, ruevs.
Re: Low level C library to use SpaceMouse devices
Hello, I have a question about implementing it in the Spacepilot device. If we create a virtual USB hardware and assign the spacemouse pro vid/pid values to this hardware, the original 3dconnexion software sees the virtual device as if there really was a device, and when we run a service application that we will create with your library, the program communicates with the device and receives the data and sends it to the virtual USB device, can't we use Spacepilot in the new version of the 3dconnexion software? Is it worth trying?
Re: Low level C library to use SpaceMouse devices
Are you trying to make the SpaceMouse work "remotely"? In other words through a network? If so there are ready made solutions for USB devices.muratxx5 wrote: ↑Tue Jan 07, 2025 5:48 am Hello, I have a question about implementing it in the Spacepilot device. If we create a virtual USB hardware and assign the spacemouse pro vid/pid values to this hardware, the original 3dconnexion software sees the virtual device as if there really was a device, and when we run a service application that we will create with your library, the program communicates with the device and receives the data and sends it to the virtual USB device, can't we use Spacepilot in the new version of the 3dconnexion software? Is it worth trying?
Re: Low level C library to use SpaceMouse devices
No, the current 3Dconnexion software does not recognize the SpacePilot device. However, with your code, we can operate the SpacePilot device with all its features on Windows 11. What I want to do is this: By running the device with your code, I want to send the bit values to a virtual USB device and define the manufacturer information of that device as a current SpaceMouse model. This way, when the current 3Dconnexion software detects the virtual device, it will perceive it as if a real device is connected. We will then send the virtual device's data using software we develop ourselves. It's a kind of intermediary emulator.
Re: Low level C library to use SpaceMouse devices
No, the current 3Dconnexion software does not recognize the SpacePilot device. However, with your code, we can operate the SpacePilot device with all its features on Windows 11. What I want to do is this: By running the device with your code, I want to send the bit values to a virtual USB device and define the manufacturer information of that device as a current SpaceMouse model. This way, when the current 3Dconnexion software detects the virtual device, it will perceive it as if a real device is connected. We will then send the virtual device's data using software we develop ourselves. It's a kind of intermediary emulator.Are you trying to make the SpaceMouse work "remotely"? In other words through a network? If so there are ready made solutions for USB devices.
Re: Low level C library to use SpaceMouse devices
Thank you very much for the library, ruevs. I did what I mentioned—I can now use my old SpacePilot device with the latest 3DxWare software. This means I can use both my SpaceMouse and SpacePilot devices simultaneously. For this, just an empty Arduino Pro Micro connected to the computer was enough. With my own software, I send the SpacePilot's data to the Arduino device, which then forwards it back to the computer. The Arduino essentially acts as an emulator dongle.
The only issue is that I couldn’t adjust the LCD text in the library you created—it shows garbled characters. Is it the same for you? Because of this, I can’t use the LCD at all. I’ll share the code once I’ve made some adjustments.
Let me know if you'd like any refinements!
The only issue is that I couldn’t adjust the LCD text in the library you created—it shows garbled characters. Is it the same for you? Because of this, I can’t use the LCD at all. I’ll share the code once I’ve made some adjustments.
Let me know if you'd like any refinements!
Re: Low level C library to use SpaceMouse devices
Well, never mind. I figured it out myself.**
Funny how this forum works—you ask a question, then end up playing both sides: the confused noob *and* the wise guru who solves it. Is this some kind of self-help therapy?
Anyway, crisis averted. *Mic drop.*"
Funny how this forum works—you ask a question, then end up playing both sides: the confused noob *and* the wise guru who solves it. Is this some kind of self-help therapy?
Anyway, crisis averted. *Mic drop.*"