简体   繁体   English

从PS3控制器获取输入

[英]Taking input from a PS3 controller

I want to connect a PS3 Controller to my computer (using a usb cable) and use it to control something (like a game). 我想将PS3控制器连接到我的电脑(使用USB线)并用它来控制某些东西(比如游戏)。 Using c# (or c/c++) 使用c#(或c / c ++)

Can someone point me into the right direction (perhaps a tutorial)? 有人能指出我正确的方向(也许是一个教程)? Is there a good library that I can use? 我可以使用一个好的图书馆吗?

I don't need any of the fancy things like vibration; 我不需要任何像振动这样的奇特东西; just the buttons will do. 只需按钮即可。

This should be the right starting point for you: 这应该是您的正确起点:

An article on using the USB Human Interface Device api for reading a wired PS3 controller including motion. 有关使用USB人机接口设备api读取有线PS3控制器(包括运动)的文章。

http://www.codeproject.com/Articles/23634/Wired-PS-Six-Axis-Controller-Using-USB-HID-as-Inp http://www.codeproject.com/Articles/23634/Wired-PS-Six-Axis-Controller-Using-USB-HID-as-Inp

If you just want buttons, I personally recommend SFML , which has a solid C# binding. 如果你只是想要按钮,我个人推荐SFML ,它有一个坚实的C#绑定。 This may, however, lock you into using an SFML Window, or at least an OpenGL one which you then pass into SFML. 但是,这可能会阻止您使用SFML窗口,或者至少使用一个OpenGL,然后将其传递给SFML。 SFML is also open source if you want to look into how they do it from C++. 如果你想从C ++中研究它们是如何做的,SFML也是开源的。

If you plan on learning MonoGame/XNA, you should look at how to receive input via the SDL library, as this is what underlies MonoGame for a number of uses including input. 如果你打算学习MonoGame / XNA,你应该看看如何通过SDL库接收输入,因为这是MonoGame的基础,包括输入在内的多种用途。

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

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