USB foot switch game controller

Status
Not open for further replies.

aharres

New member
Hello. I am trying to create a simple device. It is a foot switch, which windows, linux, and osx should recognize as a joystick/game controller (or maybe just a generic hid device?). The main purpose I am building this for is to have a dedicated push to talk button for mumble. Having the teensy emulate a keyboard shortcut is not an option since there is not a single button on the keyboard which at least one game doesnt use. The other reason is, it could possibly interfere with the key combinations in your game.

Right now, I am using the included library which emulates a keyboard, mouse, joystick, and serial device at the same time. When I push the switch, the teensy 2.0 pushes joystick button 32. And, as far as I can tell, this works flawlessly.

Code:
void setup() {
  pinMode(1, INPUT_PULLUP);
}
void loop() {
  Joystick.button(32, !digitalRead(1));
}

However, I worry about a few things. Would this joystick button 32 interfere with another joystick's button 32? I don't think so because windows recognizes it as a separate device. However, what happens if I have two of these plugged into the computer? Or maybe someone has another teensy joystick which actually has 32 buttons. Is this going to cause some interference?

I think the solution might be to write code for a generic usb hid with a unique vendor and product id and just have a single button. Does anyone have any code samples I can read that would accomplish this? Or am I overlooking something much easier? Is the teensy 2.0 adequate for what I want to do?
 
Last edited:
Status
Not open for further replies.
Back
Top