Simulating a USB hardware device

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    Simulating a USB hardware device

    First I need to know if this is possible in C#. Basically what I want to do is simulate a game controller using C# and be able to output the same commands the controller would output, through a USB port.

    To do this, I need to find out what the controller sends in the first place. The controller is a USB device, so I can plug it into my computer and it'll work. Is there a way to capture that device in C# and see the information that it's sending to the computer?

    Once I've done that, I'll need to be able to write a program that can reproduce those commands using buttons and output them through a USB port.

    I plan to get a USB male-to-male cable and plug one end into my computer and the other end into my Xbox 360, and have the ability to control my Xbox using this program.

    I'm sure this is possible in one way or another. Maybe not with C#, but if DVD Drives can be simulated, I'm sure USB game console controllers can, too.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You would need to simulate the full USB driver stack, which I do not believe is an easy task.
    Your software would have to respond to the XBOX's queries of what type of USB device was just plugged in, with the correct responses saying it is an xbox controller as well as all the regular commands.

    You might be better off trying to simulate a keyboard to start, since the xbox recognizes those as well.

    Comment

    • HaLo2FrEeEk
      Contributor
      • Feb 2007
      • 404

      #3
      The Xbox does recognize keyboards, but you can't control a game with a keyboard. What I'm looking for is a way to automate certain tasks in a game. I make spherical panoramas in Halo 3, they require that I set my point of view up in a single spot, then rotate the camera around in specific intervals taking pictures of the full 360° x 360° axis. Doing this on a real controller is not impossible, it's just a pain. If I could automate the task of rotating the camera (by knowing how fast the camera rotates, and thus how far it would rotate in a specific amount of time) I could greatly simplify the task.

      I didn't know it was that complicated though. I'd still like to know if there is a way that I can "see" what the Xbox controller is sending through USB (to my computer) using C#. Is that possible?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        You would probably be able to do it by spamming reads to the memory address associated with the usb device.
        How that is done is out of my realm of knowledge would def have to be done with unmanaged code (win api maybe? unmanaged pointers to address space?)

        I have never gotten my xbox(360) controllers to work on my computer. They show up and register themselves as microsoft xbox controllers, but the driver only allows the indentify, not use. (It was a convient way to charge the batteries that way)

        Comment

        Working...