USB操纵杆与C ++和DirectInput [英] USB Joystick with C++ and DirectInput

查看:733
本文介绍了USB操纵杆与C ++和DirectInput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从usb操纵杆读取数据(x / y轴,按下的按钮等),我听说过DirectInput。搜索了很长时间,找到一个体面的例子或演练,没有什么成功。如果任何人可以分享一个简单的教程,或指导我到正确的地方,我会在你的债务。谢谢

I've been trying to read data (x/y axis, pressed buttons, etc) from a usb joystick, and I've heard of DirectInput. Been searching for some long hours to find a decent example or walkthrough with little success. If anyone can share a simple tutorial, or guide me to the correct place, I'll be in your debt. Thank you

编辑:尝试在Windows平台上实现此目标

edit: Trying to achieve this goal on Windows platform

推荐答案

p> DirectX SDK中有一些DirectInput示例,源代码和编译的二进制文件。包括 Joystick 示例。旧版本的SDK(查找DirectX 9.0 SDK,2004-2005年左右)有更多的样本,多达十多个!

There are a few DirectInput samples in DirectX SDK, source code and compiled binaries. Included is Joystick sample. Older versions of SDK (look for "DirectX 9.0 SDK", years around 2004-2005) had even more samples, up to a dozen!


操纵杆示例

Joystick Sample

描述操纵杆示例程序获取并显示操纵杆
数据。

Description The Joystick sample program obtains and displays joystick data.

路径源:(SDK根)\Samples\C ++ \DirectInput\Joystick

Path Source: (SDK root )\Samples\C++\DirectInput\Joystick

可执行文件: \\ Samples \C ++ \DirectInput\Bin\Joystick.exe

Executable: (SDK root )\Samples\C++\DirectInput\Bin\Joystick.exe

用户指南观察显示的数据在移动时是如何变化的,
旋转杆,旋转油门轮,然后按
中的按钮进行各种组合。

User's Guide Observe how the displayed data changes when you move and twist the stick, rotate the throttle wheel, and press buttons in various combinations.

编程注意事项应用程序轮询操纵杆获取立即
数据定时器设置在对话过程中。

Programming Notes The application polls the joystick for immediate data in response to a timer set inside the dialog procedure.

这篇关于USB操纵杆与C ++和DirectInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆