Before I hop right into the code, I am going to briefly try to explain the major details of the USB protocol so that the code makes a little more sense. The USB protocol is partitioned into several different layers. The root is always a device. Under a device is a configuration. A device may have different configurations, such as powered from the USB port or powered externally. Under each configuration is an interface. The interface describes how the communication will take place between the host (computer) and the device. Lastly, there are the endpoints where all of the data transactions occur. Data transfer falls into the following categories: Control, Interrupt, Bulk, and Isochronous. Each has benefits over others and is more appropriate in different situations.
In order to establish communication with the USB, the host needs to know information about the device. The device sends descriptors for each of the layers listed above that describe how to communicate with a particular device. Lastly, the issue of power; USB specifies that a device is guaranteed a 100mA (5V) block but can request more blocks. The request for more blocks of power is solely up to the host controller to grant or deny.
I know that was a quick and dirty explanation and I skipped many of the tedious and time consuming details, but if you are really interested go read the million page USB white paper and www.usb.org . With that out of the way, let's talk about how I plan to communicate with the actual PC. Most USB items that you have ever purchased required you to install drivers on the computer before you plugged the device in. However, I am going to take advantage of a little secret that Microsoft Windows already has a lot of drivers that we can easily communicate with, namely the Human Interface Driver (HID). This is a generic input driver that will work perfectly for what I am trying to accomplish.
The new version of the source code includes a feature that I call Mouse Mode. Essentially, in Mouse Mode the NES controller can be used as a mouse on the computer. This works great for things like HTPC (Home Theater PC) and starting up the emulators. You press a certain key combination to enter mouse mode (Start, Select, A, and B all at the same time) to enter and exit Mouse Mode.
I used to have a whole section devoted to how the software actually worked and explaining small caveats and tricks, but nobody ever read it so I decided to just comment the hell out of the source code. If you want to look at the software, download the source code and look at it in a text editor. I will only support changing the top 3 #define statements and compiling, change anything else and you are on your own! If you do modify it (and it actually works) it would be nice if you would minimally cite me and send me a copy.
Note:I have not tested all of these configurations; however, I see no reason why any of them shouldn't work. I do know that the 4MHz oscillator setting for both devices with and without Mouse Mode works properly.