开发者

simple slider with RS232 and C#

开发者 https://www.devze.com 2023-03-18 22:09 出处:网络
I want to try add a simple slider (something like throtle on joysticks) to my computer. The hardw开发者_运维百科are part shouldn\'t be a problem as I can almost do anything about it. It only comes do

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

The hardw开发者_运维百科are 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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号