简体   繁体   English

轮询USB游戏控制器设备C#

[英]Polling USB Game controller device C#

I learned recently how PS2 game controllers send continuous updates to the PS2, with data identifying which buttons have been pressed, etc. 最近,我了解了PS2游戏控制器如何向PS2发送连续更新,以及如何识别按下了哪些按钮的数据等。

Having an adapter that allows my PS2 game controller to connect to a USB port, I started looking into writing a driver to allow it to control the mouse (similar to Joy2Mouse (http://atzitznet.no-ip.org/Joy2Mouse3/) ), as an exercise in understanding how it works. 有一个允许我的PS2游戏控制器连接到USB端口的适配器,我开始研究编写驱动程序以使其能够控制鼠标(类似于Joy2Mouse(http://atzitznet.no-ip.org/Joy2Mouse3/) ),作为了解其工作原理的练习。

I am having trouble even grasping the basics of how to access and asynchronously poll a USB device for input, and was wondering if anyone had any example code (C#) for accessing the USB device and polling its input, or could explain how it is done? 我什至无法掌握如何访问和异步轮询USB设备以进行输入的基础知识,并且想知道是否有人具有用于访问USB设备并轮询其输入的任何示例代码(C#),或者可以解释它是如何完成的?

From what I can gather, I will need to use some windows drivers for accessing the USB device, but I have no experience of this, and so don't know how to do this. 据我所知,我将需要使用一些Windows驱动程序来访问USB设备,但是我对此没有经验,所以不知道该怎么做。

Thanks for any help you can give. 谢谢你提供的所有帮助。

Those PS2 adapters interface with the controller for you, and provide a joystick interface for you. 这些PS2适配器可为您与控制器接口,并为您提供操纵杆接口。

There are a few ways of accessing a joystick. 有几种访问操纵杆的方法。 An older method (but still works) is by using Managed DirectX. 一种较旧的方法(但仍然可以使用)是使用Managed DirectX。 http://www.codeproject.com/KB/directx/joystick.aspx http://www.codeproject.com/KB/directx/joystick.aspx

Note that Managed DirectX is no longer released. 请注意,不再发布Managed DirectX。 You might try SlimDX ( http://slimdx.org/features.php ) 您可以尝试SlimDX( http://slimdx.org/features.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM