Search code examples
c#serial-portdriverjoystick

simple slider with RS232 and C#


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


Solution

  • 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