Xbox controller emulator for Atmel AVR microcontrollers

Hello all

A couple of days ago I read a post on ogxbox.com regarding using a 360 controller on an OG xbox.
I decided to give it a shot.

The progress so far is that the chip registers as an OG xbox controller on all PCs but NOT on the Xbox. I've tried it with or without hubs, with different polling speeds and whatnot.

I would love the help of the community to accomplish this.

The code
XPAD emulator: https://github.com/ripdajacker/xpad-avr
HID joystick to SPI redirect application: https://github.com/ripdajacker/hidjoy2spi

What can I do?
For now wait, I will post a tutorial on how to set the converter up as soon as it is viable.

Coming soon:
Very elaborate latency measurements.
would it be worth getting a cheap wireless controller and plugging in the xbox end into a pc to see how it identifies ?

something like https://www.ebay.co.uk/itm/Wireless...151820?hash=item1ed8ca3e8c:g:X4YAAOSwhOdXn0tN
If you have one lying around sure thing :) Most of the chinese ones identify as the same xbox controller with vendor id 0xFFFF.

I have a PS2-XBOX adapter and this one is interesting. It is a basic HID device if you plug it in to a PC, but when you plug it into an Xbox it is an xpad. I verified this with a logic analyzer. This means the method may be somewhat flawed, but it would be nice to have as many unique examples as possible.

During my research I fell over XQEMU which happens to implement an xbox controller in software.
I will look into this the next couple of days.
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.
Have you ever heard of Kade?
http://www.kadevice.net/forum/index.php
The coder there, Bruno/bootsector, has been doing xbox encoders for years and is a big fan of open source projects
He also has his own site http://www.brunofreitas.com/node/41
Try contacting him to see if he can help
note regarding that last link: since gitorious is pretty much down already and might go down for good at any time (not unlike like this forum...), y'all might want to clone the relevant code from where it moved to while you still can.
Kade looks awesome and there's certainly some relevant Xbox-specific code.
The code has been moved to github: https://github.com/bootsector/usb-retropad-adapter/

For this project I still need a USB host which can interface with a 360 controller and translate it into signals the OG Xbox understands. The cheap version of this is just to use two atmega chips communicating over serial.
> 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.
Input lag?
@zzattack The PS2 controller is not USB and you clock it yourself, which means there's basically no lag.
Do you have any code from your initial attempts?
Did you find a micro that has host + client support at the same time?
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.

Original thread: https://assemblergames.com/threads/xbox-controller-emulator-for-atmel-avr-microcontrollers.68658/