Data format

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

Moderator: Moderators

Post Reply
ProgramMax
Posts: 4
Joined: Sat Dec 29, 2007 4:33 pm

Data format

Post by ProgramMax »

The other day I was talking to a programming buddy and said something along the lines of:
"I love the idea of raw input. But every device gets to format its data however it wants? That would mean for me to support every device I need to go research every device's format. Or is there some sort of init packet that describes how the data is formatted?"

His response was "No no, there's a standard. If a device identifies itself as a keyboard then there is a standard format for how to read the raw input of a keyboard. And if it's a mouse then same thing."

That would mean that somewhere I could go find the format of all the page and usage ids, right? Where could I find that?

My SpaceNavigator identifies itself as a multi-axis controller. Does that mean all multi-axis controller packets will first have a byte describing if it's sending translation/rotation/button information, then follow it with the little endian data?

And how often do things deviate? Do all multi-axis controllers have the 3rd "page" (not sure what to really call it) for buttons? Or is that a custom thing to 3DConnexion devices? Are the LEDs and displays not standard?

Thanks. :D
jwick
Moderator
Moderator
Posts: 3342
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi ProgramMax,

You may be mixing APIs here. "RawInput" is usually used to refer to a Win32 API for getting data from devices such as ours. It works quite well. It is Windows only.

You seem to be refering to HID. Yet another API. There is no standad that applies to the LEDs and the display, but the axes and buttons follow the HID usage standard. You can read the descriptors from the device from HID and parse accordingly. Read the HID spec for details. There is also a HID example on our ftp site. It may not parse the data in the most general way, and probably should be modified to parse better.

Jim
3Dx Software Development
ProgramMax
Posts: 4
Joined: Sat Dec 29, 2007 4:33 pm

I think I follow

Post by ProgramMax »

Oops, I got mixed up, you're right. My buddy also had specifically said "If it's a HID device then it follows the standard..."

And I can easily enough find if it is a HID device by if(
RawInputDevice.dwType == RIM_TYPEHID ).
Then I can use the usage page & usage to figure out the standard formatting. I can still read the input through raw input.

You're saying the HID API also lets me get descriptors? I'll go read up on that a bit.

Thanks for the quick response.
ProgramMax
Posts: 4
Joined: Sat Dec 29, 2007 4:33 pm

Post by ProgramMax »

I found a list of HID device standards here http://www.usb.org/developers/devclass_docs/Hut1_12.pdf.
But I am still unsure about several things.

Each usage page / usage id combo gets its own format, right?
Page 0x01 ID 0x04 is a joystick.
Page 0x01 ID 0x08 is a multi-axis controller.
Page 0x07 ID 0x04 is the keyboard key 'a'/'A'??
I understand a joystick might have a standard data format that tells me what the x/y is and which buttons are pressed. Same thing with the multi-axis controller. But does keyboard key 'a'/'A' have its own format? That doesn't make sense to me.
This happens a lot through out the doc. There are things like game pad (which has a d-pad and buttons and the likes) and then there is just d-pad left. D-pad up itself isn't a device, right? It's part of a bigger device?

Can a device have multiple usages?
For example usage page 0x14 usage id 0x02 is bitmapped display. If the SpacePilot is both a multi-axis controller and a bitmapped display can it show up as both? Would that make the system interpret it as two seperate devices and so isn't so desirable?

I only skimmed the doc but I'm not sure I understand how it explains format. I see in Appendix A some examples that make sense. But what would really be great is something like your raw input example that shows me how to interpret the packet, only for interpretting each of the standard devices. I realize that would be a very exhaustive list so maybe "each" isn't what I really want. But the biggies - gamepad, joystick, keyboard, mouse, etc.

I really appreciate all of your help so far. I'll continue reading up on HID and the likes.
jwick
Moderator
Moderator
Posts: 3342
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

That's a lot of questions in there. I don't have all the answers. I haven't dug into a completely generic parser (no need to--I know exactly what I'm dealing with--the firmware guys tell me! :D ).

Yes, each combo of usage page and usage id is unique. But it isn't arbitrary. I'd say that the usage id is unique and each falls on a particular page.

Yes, a device can have multiple usages. Yes that could be a problem--probably why we don't do it.

Play around with the HID examples on our ftp site and you'll know as much as I do.

All this is a good start, but most (all?) devices have capabilities that fall outside the spec. Feature reports (in and out) are used as out-of-band messages for all these special commands. So, say you may be able to get the x & y & z data from a joystick from one manufacturer and a joystick from another manufacturer the same say, some special buttons, or resolution, or vibrations, or what have you, may require special knowledge of that device (such as our SpacePilot LCD). Still, that's a lot better than it used to be! If you could stop the innovation by companies like ours then the standard could catch up--but what fun would that be?

Good luck.
Jim
3Dx Software Development
Post Reply