Writing a windows driver for an emulated input dev

2019-03-15 11:20发布

问题:

My application needs to behave as a virtual joystick (imagine dragging a square with the mouse and translating that to the output of an analog joystick) and send some keystrokes over the network to another computer where the driver would receive that input.

I only need to support XP, Vista and Win7.

Maybe it can be done without writing a driver. I tried sending keystrokes with SendKey() which seemed to work but don't know how to emulate an analog joystick.

I've downloaded the VDK and been reading everything I can find on the subject but there are lots of things I still don't understand. Can you please point me in the right direction?

  1. Should I build a kernel-mode or user-mode driver?
  2. Can my driver act as a server for an app on the network?
  3. Do you know good tutorials / books / samples that can help me with this.

Thanks

回答1:

First of all you will have to have some kind of interface between your computer (or the network) and the joystick device that is being controlled.

If it involves making custom hardware to control the analog joystick (like it controls pneumatics or hydraulics or something, not just a pc game joystick type thing), then yes, you will almost certainly need a driver to allow a network app to move (the robot arm, or whatever) will move that joystick.

If you are able to remove the physical joystick from the equation, maybe you can write software that emulates the input of wherever the joystick used to plug into (a joystick/serial port?), or emulates it completely (a reasonably simple driver could do this). You could do it completely without writing a driver if the joystick used a standard communication interface (like RS232) because libraries exist that will handle all that and you can set up virtual COM ports that will be indistinguishable to whatever you are trying to communicate with.

The best book you can buy on driver development at the moment is Developing Drivers with the Windows Driver Foundation

Rootkits: Subverting the Windows Kernel is another great book, but doesn't cover a lot of the newer WDF stuff. It has more of a security focus but has a few awesome chapters on device drivers with fully spoonfed examples, breaking it down in a really accessible way.



回答2:

If it is only over the network, probably simple socket programming should be enough.