Update:
The controller emulator now registers correctly on an Xbox.
Next step: Getting the button press data on to the control over serial.
Would be useful to test a converter that comes with a steering wheel that works with xbox ps2 and pc ? Steering wheel has ps2 port that plugs to the converter . I can even use a ps2 pad on xbox or pc via this converter
Or a Logitech xbox wireless controller
Good job. Keeping an eye on this, in order to maybe eventually mod it into a DIY Steel Battalion controller/cockpit.
As rso said I cant wait to turn this into a diy steel battailon controler.
> two atmega chips communicating over serial
sounds laggy :/
At 115200 baud you can send an entire controller state every 2ms.
On the output end the delay should be negligible since the buffer is emptied every 4ms.
I hope the delay won't be noticeable, if it is I'll look into using some other means of communication.
Bigger cortex m micro with both host and device capability a possibility?
Yes a cortex would work. If anyone is up for it an OrangePI with OTG could work too, albeit I am not sure what it would require to do the xpad emulation using the USB gadget framework in linux.
The ATMega32u4 cannot act as a USB host, so a host shield (or a teensy) is needed.
A couple of metrics:
A cheap PS2 to Xbox adapter sends gamepad state every 8ms.
An original Xbox S controller sends every 4ms.
A frame at 60fps is ~16ms, at 30fps it's 33ms.
This means a total latency of less than 16ms is proably good enough for most people.
From the initial test with a baud rate of 57600 through a linux PC I can get around 25ms latency from the PC receives the HID report till it is sent to the Xbox. I suspect the host shield will reduce this drastically because it offloads the USB processing to a dedicated chip and sends stuff to the atmega over SPI, which will run way faster than 57kbit (running on 16mhz this would be in the "couple of megabits" range).
Next steps:
A USB shield is coming to me from china, so in 2-3 weeks I'll be able to give it a go.
In the meantime:
If you are a programmer, check out the code.
So nice, a Porshe fanatec wheel with Outrun 2 SP from chihiro .... my dream...
I developed the 'MUNIA' (multi use nintendo input adapter) and am planning on doing something similar for PS2 and original xbox controllers. This device can take inputs from snes, n64 and NGC and output to snes, n64, NGC or PC. That means you can use your SNES controller to play on the NGC, use your NGC controller to play on N64 or any other combination you can make. Its main intended purpose though is viewing the inputs on PC to form an overlay on twitch so the controller state is replicated on screen.
I've been meaning to build this for xbox and ps2 and especially the xbox one requires a decent microcontroller. I had begun to make a design with 2 microcontrollers, one as USB host and the other as normal device. The micros were shared an SPi bus to exchange packets but halfway through development I stopped. It was incredibly annoying to update 2 devices and keep them in sync, so I decided I'd rather do it properly instead using a single micro with both host and client capability. I'm sure the 2-mcu approach can work but I found it too cumbersome to work on.
For the 'input viewer' part I always configure the microcontroller to be a spy on the bus. This is more difficult, but guarantees there is absolutely no delay between original controller and console. For xbox and other USB-based protocols this is not going to be possible though.
The only microprocessors with double USB PHY that I know are STM32F4x5 and STM32F466 with the latter being somewhat affordable. There's probably a few more possible choices but these are the ones I know of.