开发者

How is joystick axis information formatted from a USB Joystick?

开发者 https://www.devze.com 2022-12-24 01:58 出处:网络
I actually just have a rather small question, but I have had the HARDEST time finding information about it.

I actually just have a rather small question, but I have had the HARDEST time finding information about it.

For the application I am programming for, there will be a 3-axis joystick being connected via USB to a Windows XP computer, and it is being handled by directx. That information will then be sent elsewhere to an embedded controller. I don't need to know too much of the intricacies of how directx handles it, but I want to know, how is the data for the axes formatted?

Nearest I can tell, mo开发者_运维技巧st joysticks nowadays have 12 bits of resolution, so is the data output as a 12-bit 2's compliment number? And after that, is it represented as a signed 16-bit integer when it is captured from directx?

I'd like to know this so I know how I will work with the data at the embedded platform side, such as how to format the packets sending data to the embedded side, as well ashow to use the information once it is on the embedded side.


The big issue with drivers is that it means the device can provide the data to you HOWEVER it likes. There is nothing stopping it sending a string representation of the number along the USB, for example (Though I admit its unlikely). As long as the driver re-interprets the data into a form windows (or whichever OS) can understand there is no problem.

You are best off selecting a subset of devices and just seeing how the data comes through raw and writing your own abstraction between the device and your system. If its an unknown device you can "guess" as to what format the data comes in as and try to get it to work but I doubt you'll manage a catch all system as some bugger somewhere is going to do things in an odd (ie in their own) way.

0

精彩评论

暂无评论...
验证码 换一张
取 消