使用 RS232 和 C# 的简单滑块

发布于 2024-11-18 18:02:09 字数 284 浏览 3 评论 0原文

我想尝试在我的计算机上添加一个简单的滑块(类似于操纵杆上的油门)。

硬件部分应该不是问题,因为我几乎可以做任何事情。这只是归结为有某种驱动程序。

我现在有一个微控制器和一个电位器,通过转动电位器我可以将0到254之间的值传输到PC的RS232。从硬件的角度来看这足够了吗?

如果您能给我一些关于在哪里寻找信息、做什么以及在最好的情况下一些代码片段的提示,那就太好了。

所以我正在寻找的是能够将我的硬件作为 GAMEPAD 或 JOYSTICK 呈现给 Windows。

谢谢

I want to try add a simple slider (something like throtle on joysticks) to my computer.

The hardware part shouldn't be a problem as I can almost do anything about it. It only comes down to having some kind of driver for it.

What I have at the moment is a microcontroller and a potentiometer, which by turning the potentiometer I can transfer values between 0 and 254 to the RS232 of PC. Is this enough from hardware point of view?

Would be nice if you can give me some tips about where to look for info, what to do, and in the best case some code snippets.

So what I am looking for is to be able to present my hardware to windows as a GAMEPAD or JOYSTICK.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁许谁一生繁华 2024-11-25 18:02:09

您提到的游戏手柄和操纵杆可能是 HID 设备(如果它们本身被识别为此类设备) - 游戏控制器

以下是有关游戏控制器 HID 类的一些信息
http://msdn.microsoft.com/en-us/windows/hardware/gg487464

您将需要开发一个 HID 仿真器驱动程序,该驱动程序

  • 可以识别(通过某种独特的
    查询序列号得到的id
    端口硬件)
  • 或配置为
    您提到的设备类型之一
    (游戏控制器)。

然后,您需要将通过串行端口传入的值转换为您正在模拟的 HID 类的适当值。

这是 HID 模拟驱动程序的 Python 示例
http://code.google.com/p/hidemulator/

这是一个 C++ 示例
http://examples.oreilly.de/english_examples//9780735618039/cd_contents/Samples/Chap13/hidfake/hidfake.htm

The gamepad and joystick you mention are likely HID devices (if they are natively being recognized as such) - gamecontroller

Here's some information on the gamecontroller HID class
http://msdn.microsoft.com/en-us/windows/hardware/gg487464

You will need to develop a HID emulator driver which either

  • identifies (via some sort of unique
    id obtained from querying the serial
    port hardware)
  • or is configured as
    one of the device types you mention
    (gamecontroller).

You then need to translate the values coming in over the serial port to the appropriate values for the HID class you are emulating.

Here's an example in python of a HID emulation driver
http://code.google.com/p/hidemulator/

Here's a c++ example
http://examples.oreilly.de/english_examples//9780735618039/cd_contents/Samples/Chap13/hidfake/hidfake.htm

转身泪倾城 2024-11-25 18:02:09

您可以尝试查看 SerialPort 类。
最有用的事件是 DataReceived

抱歉,我没有得到您提出的确切问题。我刚刚在我的项目中使用了这个类,并对此感到有点兴奋。我希望其他人能给你更好的答案。

You can try to look at SerialPort class.
The most useful event is DataReceived.

Sorry that I didn't get the exact question you asked. I just used this class in my project and felt a little excited about it. I hope someone else can give you a better answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文