Spacemouse how to determine available buttons

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
cebugdev
Posts: 6
Joined: Tue Nov 02, 2021 1:23 am

Spacemouse how to determine available buttons

Post by cebugdev »

Hi,

How do I get which buttons are available for which device model for SpaceMouse programaticaly?
if its not possible, I will do it manualy but
How do I know what model the device is connected and how or where can i find information on which buttons are available for what model?

I used the tutorial from this one by the way: https://www.codegardening.com/2011/02/u ... 9771483385 since im using QT.

is there a device Id and model i can check?
what are your suggestions to approach this?
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Spacemouse how to determine available buttons

Post by ngomes »

cebugdev wrote: Mon Nov 15, 2021 4:27 am what are your suggestions to approach this?
The latest SDK (version 4) uses a paradigm to abstract the device. This means the information on the actual connected device (or devices) isn't provided over that SDK.

If your solution requires enumerating individual devices, then you can use version 3 of the SDK (now deprecated) or a system interface such as Raw Input. Have a word with our API Support team. The contact details can be found in the Developer web pages (registration is required).
Nuno Gomes
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Spacemouse how to determine available buttons

Post by jwick »

You are using Raw Input?

We would prefer that you use one of our SDKs as they hide most of the hardware details from you.
We are not trying to be sneaky. We want to isolate your code from changes in our hardware, in particular, the release of new devices. We don't want to require you to make code changes to support a new hardware device someone might buy in the future.

To that end, the driver will send generic button events, not tied to a specific hardware device. Each hardware device will produce some subset of the total set of events. Your code should not care. E.g., if a user has a device with a View Save key, then you may get that event. If not then you won't. You respond to the event, not the device.
We can provide samples if you wish to go that direction.

If you want to use one of the other APIs, I've provided all the hardware details in the Base.xml file we ship with our software. For every Device, it lists the details about the device-level event (the event you would receive over Raw Input). Look at the Device/ButtonInfo/Button entries for a list of Buttons on each hardware device. It's a bit of work...

This is not a public file. I haven't changed the format in a while, but I'm thinking about it.
cebugdev
Posts: 6
Joined: Tue Nov 02, 2021 1:23 am

Re: Spacemouse how to determine available buttons

Post by cebugdev »

Hi thanks for replying,

the reason I want to know what are the buttons available on what device is because in our application we give the user option to Mapp said buttons to specific application specific option, for UX purposes I want to know which buttons are available for the device connected so we can present the correct UI and only present the options for the buttons available.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Spacemouse how to determine available buttons

Post by ngomes »

cebugdev wrote: Thu Nov 18, 2021 2:29 am I want to know which buttons are available for the device connected so we can present the correct UI and only present the options for the buttons available.
This will never end. We have move away from that approach precisely because it is far too much work to try to keep up with changes to our hardware product line.

What's the interface that you are using? One of 3Dconnexion's driver APIs or a system API like "Raw Input"?
cebugdev
Posts: 6
Joined: Tue Nov 02, 2021 1:23 am

Re: Spacemouse how to determine available buttons

Post by cebugdev »

we went with the Win32 SDK way because we found the provided SDK is not intuitive enough, we try to follow the examples and it amazes us that developers need to override like 20 methods to get it working (unless we are doing it wrong), we were using VTK and we just need the motion data rotation and translation, and button events, the samples provided in windows is pretty discouraging compare to say if we do that in Win32 or use VTK.

when using VTK, we can just subscribe to motion event and we are provided with 6 motion data when the spacemouse is rotated or button press events when a button is clicked, same design we can achieve if we use the WIN32 RAWInput sample here https://www.codegardening.com/2011/02/u ... 9771483385
the QT sample triggers signals just as we need it.
The same level of intuitiveness is not found in SDK, instead a developer needs to inherit from a class and override like 20+ methods.
unless we are misunderstanding the samples, using the SDK is not an option.
cebugdev
Posts: 6
Joined: Tue Nov 02, 2021 1:23 am

Re: Spacemouse how to determine available buttons

Post by cebugdev »

we are using RawInput, unfortunately... we have no choice but to use this approach instead of the SDK as we found the SDK and its samples very hard to follow. The samples are spaghetti code that you cant determine which ones are from SDK and which ones are custom implementation.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Spacemouse how to determine available buttons

Post by ngomes »

cebugdev wrote: Thu Nov 18, 2021 3:49 am we are using RawInput, unfortunately... we have no choice but to use this approach instead of the SDK as we found the SDK and its samples very hard to follow.
Well, we have to pick our poison, isn't it? That's what engineering is all about, finding a balance to make something work.

The SDK version 4 -- the one you found to be unintuitive -- has a completely different paradigm from Raw Input, it's camera control as opposed to device data delivery. That paradigm abstracts all our devices. It also provides a method to export application commands, allowing the user to map them to any device button, whatever the device model they may have.

That last feature (application command export) is also available in SDK version 3 which has a data transport implementation that is close to what you're used to in Raw Input but you still be stuck reimplementing all the 3D mouse navigation modes and what not.

If you're interested, you can try reaching our API Support team (see link in a comment above) since they will have an old Raw Input sample around. Perhaps you can find your way in there and see how the different device types can be handled but, again, your program will be outdated as soon as 3Dconnexion comes out with a new device model.
Post Reply