Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

c# - How do you parse information from a Human Interface Device / HID?

I may not even know enough about interacting with HIDs to ask a good question, but here's my best shot so far. I am using C# and am on Windows currently.

I have been researching how to interact with a game controller like a PlayStation 4 or PlayStation 5 controller. I would like to be able to determine when a button is pressed, how far a trigger is pushed down, and any other input a user could perform. The other part I would like to find out how to do is provide input to the controller. This could be something like telling the controller to rumble, or it could tell the PlayStation 5 controller to adjust the tension in its triggers, which is a new feature to that controller.

I have gotten far enough to where I think I can find the device, connect to it, and then start receiving reports with data from the controller. I also see ways to write data to the controller, but I have not tried that yet.

The main barrier I am running into is that I do not know how to parse that data that I am getting back. I am getting 63 bytes of data, but don't know what any of it is supposed to mean. Likewise, I don't know what format to use when sending data to the controller.

I know I can monitor that 63 bytes to see what changes when in press buttons on the controller, but I'm wondering if there is a good way for me to get this information without trial and error. I also don't know of a similar thing that I can do to figure out how to provide data to the controller myself.

Is there a way to get this information from the device itself, or would this information need to be provided by the controller manufacturer?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...