Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: USB foot switch game controller

  1. #1
    Junior Member
    Join Date
    Dec 2014
    Posts
    1

    USB foot switch game controller

    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 by aharres; 12-04-2014 at 12:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •