Microcontroller as USB Host for gamepad - Page 1
Forum section: electronics / projects

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 01, 2025, 08:57:54 pm
content: I have no idea where to start with this...I would like to connect a PIC or ATSAM microcontroller (and open to other offers...) to a game controller so I can control my GPIOs as a result of button presses and gamepad movements.Ideally I would use...Logitech F310 or similar...How do-able is that? Is this just a stupid idea and I should try another approach? e.g. Bluetooth?

author: ledtester
author_rank: Super Contributor
timestamp: July 01, 2025, 09:23:17 pm
content: The thing to search for is: USB HID host + your micro controller, eg:USB HID host ArduinoorUSB HID host rpi picoHID stands for "human interface device"

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 01, 2025, 09:25:31 pm
content: OK so this looks quite hard!I think I need a USB Host and my chosen Microchip microcontrollers (PIC and ATSAMC21) don't seem to really do that.MAX3421 adapter looks pretty expensive.ESP32-S3 might be a possibilty...https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/hidbut this is my normal dev environmentHm.Once I have a USB host it seems do-able... not simple... but do-able.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: July 01, 2025, 09:40:34 pm
content: I used the STM32H503CB in this project:https://lemmini.de/STUSB2DB15/STUSB2DB15.htmlWhen I looked for a smallish microcontroller with a hardware USB host interface, it seemed to be the cheapest/most attractive on the market.Getting the USB HID stuff to run was a bit of a struggle, even more so to get devices with XInput support to work.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 01, 2025, 09:54:48 pm
content: Quote from: 0xdeadbeef on July 01, 2025, 09:40:34 pmVery good! This is very similar to my requirement... basically I want to be able to drive connections on a JAMMA adapter for a test rig when I am testing Arcade PCBs.Good job... looks like a reasonable struggle.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: July 01, 2025, 10:04:08 pm
content: I used this with my ownNeo Geo MiniMakwhich is basically a Jamma SuperGun specialized for Neo Geo multi-slots, so adapting it to Jamma should be simple.Nearly all of the pins of the STM32H503xx are 5V tolerant, so the pins I use to pull the joystick control lines low are just configured to open drain and switched to ground if activated.

author: aeg
author_rank: Regular Contributor
timestamp: July 01, 2025, 11:05:48 pm
content: Consider using a Sega Genesis controller. Connect pins 5 and 7 to 5V and pin 8 to ground, and then you get Up, Down, Left, Right, B, C on pins 1, 2, 3, 4, 6, 9 respectively. No microcontroller needed.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 02, 2025, 02:06:55 pm
content: Quote from: aeg on July 01, 2025, 11:05:48 pmI need many more buttons.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 02, 2025, 02:10:27 pm
content: I stumbled across a CH559 project that provides a bridge between USB host side and a microcontroller.https://github.com/atc1441/CH559sdccUSBHostThat might be the path of least resistanceI also note that ATSAMD1 has some USB host support and that isn't far off my current development set-up.Lots of possibilities!

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: July 02, 2025, 03:49:19 pm
content: Quote from: NivagSwerdna on July 02, 2025, 02:06:55 pmAFAIK, the number of buttons of a normal HID gamepad is limited to 32. However, D-Pads are not handled as buttons but either as (two) axes or as hat-switch which returns a value of 0..8 or so.

author: Ian.M
author_rank: Super Contributor
timestamp: July 02, 2025, 04:27:37 pm
content: Nintendo Wii wired controllers use I2C, and there are Arduino libraries to support them, so consider a Wii Classic Controller Pro.

author: fchk
author_rank: Frequent Contributor
timestamp: July 03, 2025, 01:28:16 pm
content: Quote from: NivagSwerdna on July 01, 2025, 08:57:54 pmThere are PIC24 with USB-OTG, which can act as device and Host. Microchip offers USB stack plus Host HID stack as part of MLA and Melody/Harmony software stacks for free.