如何将操纵杆连接到WAF [英] How to Interface Joystick to WAF

查看:61
本文介绍了如何将操纵杆连接到WAF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在操纵杆和我的项目之间建立一个接口,该接口是带有C#编码的Windows应用程序窗体,以便操纵杆的移动与鼠标执行的相同.

I need to have a interface between joystick and my project which is windows application form with C# coding, So that the movements of joystick are same as performed by the mouse

推荐答案

我已经在此处为您提供了创建操纵杆事件的基本说明:如何进行界面游戏杆 [ ^ ].如果您首先获得并正式接受,那就太好了.

现在,关于鼠标-我真的不认为用操纵杆替换鼠标是有意义的,但是有解决方案.

简短的答案是:编写设备驱动程序.但这一点都不容易.幸运的是,您可以在应用程序级别执行此操作.并且您的鼠标操作可以在整个系统范围内运行(这很容易),也可以只为您的应用程序运行(需要一些额外的工作).

方法如下:P/调用Windows API SendInput.由于事件来自硬件,因此您可以轻松地在低级别上模拟鼠标.请参阅 http://msdn.microsoft.com/en-us/library/ms646310(v = vs.85).aspx [
I already gave you the basic directions on creation of joystick events here: How to Interface Joystick[^]. It would be good if you got it and accepted formally first.

Now, about the mouse— I don''t really think replacing a mouse with joystick makes sense, but there is a solution.

Short answer is: write a device driver. But this is not easy at all. Fortunately, you can do it on application level; and your mouse action can work system-wide (which is easier) or just for your application (will need some extra work).

Here is how: P/Invoke Windows API SendInput. It will allow you to easily simulate mouse on low level as the events were coming from the hardware. See http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[^].

You will need to create joystick events the way I explained in my past solution and capture them; in the event handler read joystick status and simulate mouse input using SendInput. It really works.

Please understand that joystick is way more powerful device than mouse. I would recommend to use all its power, not just as mouse. For example, you can use the joystick angle to control speed, rotation to control direction, etc.

—SA


这篇关于如何将操纵杆连接到WAF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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