multiple HID gamecontrollers



I am planning to make my own arcade controller and would like to use a single microcontroller that appears to the host as multiple HID game controllers. From looking around it seems like the functionality to implement more than one simultaneous HID might not yet be available. I am wondering how much work would there be involved to achieve this. I've got experience writing embedded software, but haven't really touched USB properly (just used out of the box APIs so far). Nevertheless I am looking forward to dive into it and, if it's cool with the project owners, more than happy to send a pull request after getting everything working and tested.

Also, as a side question. Is there any software I2C bitbang library available as well?
From looking around it seems like the functionality to implement more than one simultaneous HID might not yet be available.

When you set Tools > USB Type in Arduino to "Keyboard+Mouse+Joystick", Teensy will implement 4 HID interfaces! :)

The first three are for the Keyboard, Mouse and Joystick. The 4th is a special "vendor defined" on that's used to emulate a serial connection. That allows you to use Serial.print("stuff") in Arduino and have it display in the Arduino Serial Monitor. Certainly the technology exists to implement multiple HID interfaces!

Maybe you're thinking of using 2 keyboard interfaces, one for each player? If so, as a sanity check you might try just plugging 2 regular USB keyboards into your machine and fire up whatever game you're using. You'll pretty quickly discover all the operating systems merge the streams of keystrokes together. It's not a limitation on the Teensy side, but rather on your computer, where a game can't associate each keyboard with a different player (or at least, can't without installing special drivers). Or maybe it can? Please do this test with your game and let us know the results?

But with a single keyboard interface, you might run into the limitation where only 6 keys can be pressed simultaneously. Here is a thread about working around that issue, so any combination of all 104 keys can be used at any instant.

Someday I plan to integrate this into the default Teensyduino install, but for now you'll need to get it from that thread.

Also, as a side question. Is there any software I2C bitbang library available as well?

Yes, such libraries exist. I'm sure you can find them if you search. Or maybe someone will reply with links for you?
Hi Paul, thanks for your prompt response.

The idea was to have 2 joystick interfaces and perhaps a keyboard interface. To give you a better background, I'm planning to make a small bartop with an android device. Due to the limited space this would have one arcade controller and two wii classic controllers connectors (there lies my need to have two I2C channels). Strictly speaking it would be fine if at any given time it could either be "one keyboard", "one joystick", or "two joysticks", as I was planning to have a switch (most likely two buttons) to select between "one player with arcade controller", "one player with wii classic controller" or "two players both with wii classic controllers".

I am completely new to the world of arcade and emulators, so I'm learning as I go, I'll have to check connecting multiple HID devices into android, etc. In fact when I wrote the first post I was planning to implement the arcade controller as a joystick, but it seems like most people prefer to do it as a keyboard (not 100% sure why, I'll need to look into it). The main reason I was under the impression that more than one-of-the-same HID was not yet available was due to posts like these below, and other "can I use this HID and this HID together" posts where it is suggested to modify the USB code. They might have been older posts.

Anyway, the idea is to implement two independent joystick HIDs at the same time. Will this be possible?
Hi there,

The post that Paul mentioned was mine. I managed to get the NKRO keyboard working.

The aim for my project is to be able to connect 2 SNES pads to the computer as either 2 independent joysticks or as a single keyboard that emits multiple key presses. A switch will most likely control how the presses are interpreted.

I actually stripped out the joystick stuff so that I could focus on the keyboard portion but the plan is to add them back in.

I'm not familiar with how the usb implementation in Android works but as far I've seen while perusing the internet you have a possible 2 options:

1. A single HID game controller that contains all the axes and buttons for all joysticks connected
2. Multiple HID game controllers, one for each joystick

Now, with android, I know for a fact there are lots of existing controllers that are available that work out of the box with emulators that are available. Have you looked into any of those? Also, I'm pretty sure I've seen instances of people using PS3, and Wii controllers through the bluetooth interface. Would any of those things be an option for you?
Hi joshuass,

Yeah, I believe HID support was added in android 3.1, so I am hoping it works “out of the box” once it’s finished. I would like to make this as simple as possible for somebody else to implement, so I’d rather spend the time working on the “API software” in order to simplify the “application code” and remove the need to do anything on the host side. So, I would like to get two or more independent HID joysticks working simultaneously (and maybe an HID keyboard at the same time? I’ll decide on this one once I start playing with the microcontroller). The main reason why I chose the wii classic controllers is because I have 2 of them already, they are popular, and still cheap to buy in the shops (and hopefully still around for as long as the WII U is out). I’m doing this arcade thing mostly as an excuse to do a quick sw/hw project before I get into something a bit more ambitious after the summer, so I am reusing a lot of what I’ve got around (tablet, arcade controller, wii controllers), it’s a lot more fun than just buying the stuff.
How will you interface the Wii Classic controllers to the microcontroller? Will you be drilling and modding the controllers and attaching it directly or are you going to try and speak the controller protocol?

In my SNES project, the controller protocol was actually very simple, so I was able to speak to the controller without any modifications (thus, saving my 1st party controllers from breaking and not being usable on a real SNES!).

If the Wii Classic controller has a protocol that is anything like the N64 or GameCube, it will be a pain in the arse to speak natively to it.
The wii communicates using normal I2C, so that is quite simple to implement. The only issue is that the slave address is static, so I will not be able to talk to two controllers in the same bus, that's why I was originally asking about an software bitbang I2C library to use both at the same time (I'd rather do that than to multiplex between the two controllers).