4
  • Is it possible to create virtual device "on the fly" ? (The guy click on a button "new virtual device", write the device name and the windows popup appear as if he a just plugged a new device).
  • Do i have to create a custom device driver or can i use a generic one ?
  • Where should i start (documentation link) ?

My goal is to emulate one or more virtual gamepads, visible in games (with their custom names), and mapped to one or multiple physical devices, like keyboard and mouse.

Thank you !

Caribou
  • 2,070
  • 13
  • 29
yohannc
  • 140
  • 2
  • 9
  • Not sure this should be tagged C++... and if it should, have you tried to do it - any code to post? – Caribou Dec 10 '12 at 10:36
  • Why not C++ ? do you think for ASM ? And no, i didn't made any code. I'm currently looking for the feasability, and where to start. – yohannc Dec 10 '12 at 10:49
  • I retagged - lets see if you get any hits now – Caribou Dec 10 '12 at 11:35
  • @yohannc: Microsoft doesn't condemn C++ for device drivers, but strongly advises you to use it as a better, more typesafe C. Features like virtual functions and exceptions don't work reliably at the IRQ levels of drivers. – MSalters Dec 10 '12 at 11:42
  • @MSalters exceptions aren't supported but virtual functions are - but need to follow several rules – SomeWittyUsername Dec 10 '12 at 11:52
  • @icepack: How do you ensure the vtable is non-pageable? IIRC that's what made them illegal. Even if the vptr and the virtual function were non-pageable, you'd still crash if the vtable was paged out. – MSalters Dec 10 '12 at 11:55

1 Answers1

3

Yes, it's possible. The Windows driver architecture needs such support to allow USB drivers to load on the fly. You will need a custom device driver. There are existing "virtual" device drivers, e.g. for NUL, but those aren't what you want.

However, device driver writing isn't for the faint of heart. You really can't expect to read a single article and start hacking.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • late to the party but: there is nothing wrong with expecting at least one person on the entire population of the planet to have written a tutorial on how to do this, start to finish. The subject is niche enough to never surface in web searching, which is why this is exactly the thing SO users might know, as google and duckduckgo will fail to yield that "single article". – Mike 'Pomax' Kamermans Nov 02 '17 at 16:08
  • @Mike'Pomax'Kamermans: That person is not me, and also, resource requests happen to be off-topic on StackOverflow – MSalters Nov 02 '17 at 16:34
  • Only when SO is not the very last option. Outright asking for tutorial and resource links is definitely off topic, but showing you searched and researched, and you still couldn't find anything, is following the "how to ask a good question" site policy, and not a rubber stamp reason to close. – Mike 'Pomax' Kamermans Nov 03 '17 at 01:08