ToniLou
Posts: 2
Joined: Thu Feb 13, 2020 8:32 pm

GPIO joystick to USB

Thu Feb 13, 2020 8:44 pm

Hi

I?m using a RPI 3 as an emulator box with RetroPie. Two joysticks (and a few buttons) are wired to a 40-pin GPIO header that connects directly to the RPI. When the joysticks are actioned, the information arrives to the RPI and everything works.

I want to use the GPIO wiring to connect the same joystick to a Mac/PC through USB. So I need something that (1) allows the connection of a GPIO header and (2) process the inputs and converts them to USB data that can be understood by a Mac/PC.

I have seen (and ordered) an RTk.GPIO (https://uk.pi-supply.com/products/ryant ... ce?lang=es) with that goal.

Do you think that the board will be able to understand and forward to its USB port the joystick information? Do you know if I'll need to do something on the PC/Mac in order to process the (hopefully) received USB data?

If not, do you have some idea how I could get closer to the GPIO2USB goal, so a GPIO input can be forwarded and received via USB on a PC/Mac?

Thanks!


Toni

User avatar
topguy
Posts: 6269
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: GPIO joystick to USB

Fri Feb 14, 2020 1:39 pm

Do you think that the board will be able to understand and forward to its USB port the joystick information?
I will say "no". The board will not be recognized by Windows or MacOS as a joystick.
Do you know if I'll need to do something on the PC/Mac in order to process the (hopefully) received USB data?
So while you can create a program to read the buttonpresses you would then also need to create a "virtual" joystick driver.

I think this answer on reddit explains it better than I could.
https://www.reddit.com/r/RetroPie/comme ... ck_to_usb/

User avatar
thagrol
Posts: 2372
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: GPIO joystick to USB

Fri Feb 14, 2020 3:08 pm

ToniLou wrote:
Thu Feb 13, 2020 8:44 pm
I have seen (and ordered) an RTk.GPIO (https://uk.pi-supply.com/products/ryant ... ce?lang=es) with that goal.

Do you think that the board will be able to understand and forward to its USB port the joystick information? Do you know if I'll need to do something on the PC/Mac in order to process the (hopefully) received USB data?
Looks like that board will just pass raw GPIO state to/from the USB host. It won't have any knowledge of what is conncted to the GPIO and what functions any given GPIO is supposed to perform. You'd have to write your own driver that takes the raw GPIO data and converts that to what the Mac/PC application is expecting.
If not, do you have some idea how I could get closer to the GPIO2USB goal, so a GPIO input can be forwarded and received via USB on a PC/Mac?
Several.

Easiest: buy one or more USB josticks.
Medium: use an encoder board as suggested by topguy
Hard:
  • Plug your joystick button combo into a Pi zero
  • Set the zero up as a USB HID gadget
  • Translate GPIO events to HID joystick or key events and pass them to the USB host.
In essence this is building your own encoder board.
Harder: Use the board you linked and do the gpio to keypress/jokstick input on the Mac/PC.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

deepo
Posts: 432
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: GPIO joystick to USB

Fri Feb 14, 2020 4:37 pm

I have an adafruit Trinket M0, a very small device with just enough GPIO to read a joystick, and the ability to implement a standard game controller in the USB world. And it's programmed in CircuitPython.
There are other boarsd that can do the same and can be programmed in Arduino C code.

/Mogens

ToniLou
Posts: 2
Joined: Thu Feb 13, 2020 8:32 pm

Re: GPIO joystick to USB

Fri Feb 14, 2020 4:45 pm

Thanks guys

I did some quick research based on your tips and I found a USB encoders that seem right for the job: https://www.ultimarc.com/control-interf ... -en/u-hid/.

The Ultimarc board seem designed to be seen as an HID device from a PC/Mac and have a 40-pin to connect my already wired GPIO header (that I don't want to rewire at all since I want to be able to use it on the RPI and on the PC/Mac as it is). Surely I'll need to remap by software (from the PC/Mac) the keystrokes, but it looks like the way to go.

I'll give it a try and let you know how it goes.

Thanks again!


Toni

Return to “Beginners”