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

Thread: Two Joystick HIDs at the Same Time (Teensy ++ 2.0)

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    3

    Two Joystick HIDs at the Same Time (Teensy ++ 2.0)

    Hello everyone!

    I originally posted this in the project guidance section, but I think this question might be better suited here.

    For the past couple of days I have been trying to write code to allow me to display two Joystick HID interfaces at once. (Having two separate HIDs in device manager and game controllers)

    My objective is to connect two retro controllers to the Teensy and have them appear as their own gamepad interface in windows/mac/linux. I have found this repository that has managed to do what I intend https://github.com/jjstreet/teensyarcade but it uses the old version of Teensyduino, because of that, i'm limited to 8 buttons and 2 axis, and most of the new Joystick commands from version 1.45 are unavailable. I would like to ultimately make N64 and Gamecube controllers work as well, so I'd need 4 axis and 10 buttons + 4 for DPad.

    I approached this problem in two ways: First I tried adding buttons and axis to the code I provided in the above link, but after hours of trying, even if I did manage to modify the USB.C file and other core files, I couldn't get the controller to work correctly or at all.

    My second approach was to take the code as an inspiration and try to implement dual Joystick HIDs using the new version of Teensyduino and Arduino IDE, which supports 32 buttons 6 axis and one multi directional HAT switch. I managed to fix some of the compiler errors on my attempt to try and replicate the multiple HID joystick code on the newest version of the Teensy IDE. The Joysticks still don't appear in the device manager, it may be that I have the wrong usb hid device descriptors, or that my USB_API.cpp is wrong.

    Here's the code if anyone would like to take a look.

    Do you guys have any suggestions? or know of any other project that has done this same thing? I'm willing to start from scratch.

    Thanks in advance!

  2. #2
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Hi,

    did you have any success regarding this topic meanwhile?

    I am also urgently looking for a solution to drive two HID joystick with Teensy 2.0 ++ :-/

    Thank you,

    Fifsy

  3. #3
    Junior Member
    Join Date
    Jan 2020
    Posts
    3
    Quote Originally Posted by Fifsy View Post
    Hi,

    did you have any success regarding this topic meanwhile?

    I am also urgently looking for a solution to drive two HID joystick with Teensy 2.0 ++ :-/

    Thank you,

    Fifsy
    I am in the same boat here. I have my own (what someone else called) frankenstein controller which registers itself as keyboard and mouse and two analog sticks, and I want to multiplex the inputs into two custom gamepads.
    My idea for the time being, as this issue seems to be unresolved and that I am totally new to all this is, especially micro programmer electronics, so I am trying to gather all needed pieces and might be wrong here.

    a) use a raspberry frontend as usb host to pick up the signals via evdev and then use uart to push the data to teensy where it then is sent as appropriate commands.

    Now my idea is probably to use additional ftdi usb breakouts to open additional serial lines and to use two teensies to achieve that. Both basically run the same code with different conversion tables. But using two teensies seems hackish to me, if there was another way I would prefer it.
    Anyway I am a newby here, and if my idea on this is not correct, feel free to correct me, I would be happy.

  4. #4
    Junior Member
    Join Date
    Jan 2020
    Posts
    3
    I guess this is a problem which needs to be solved at the Teensy side.
    There are some libraries on the Arduino side, with MT32 controllers which can pull the trick off but of course they do not work with teensy, neither do many standard arduino libraries in this area. From an API standpoint I was able to see that with some extensions it could work, but thing is, it is not supported yet, maybe sometime in the future it will be.
    For my problem I worked around that with 2 Teensies which is hardware overkill given that i just want to simulate 4 usb devices, one being j1+mouse+keyboard and the other one j2.
    But I probably will move my code over to a single board solution in the long run (maybe an MT32 based one)
    The issue seems to crawl up every bunch of years and a solution would be heavens sent for people who build their own arcade controller sets!
    So maybe someone with the knowledge of pulling this off can spend some time on it.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,977
    Hypothetically... if I were to add this for Teensy LC - 4.1, which PC-side software should I use for testing?

    A big question I have, which can probably only be answered by experimenting, is whether the PC software can recognize a single HID report as multiple joysticks. If a separate endpoint is needed, we may only be able to support this on Teensy LC to 3.6.

    Also, is there a need for more than 2 joysticks? If this is going to be done, would be best to do it only once with enough to accommodate the largest application.

  6. #6
    Junior Member
    Join Date
    Jan 2020
    Posts
    3
    Well there are two ways for testing it on the pc side. Windows has a joystick/gampad tool which shows you the joysticks it can detect and then you you can test for the sticks buttons etc...

    On the linux side every controller is mapped into the /dev/input<xxx> and you can use jstest for instance or a graphical tool.
    The problem is does it have to be a single hid? The idea is more that it provides two hids, like it can do for keyboard, mouse, joystick within the same board. The problem then is more on the api side, the high level api atm does not allow to deal with a XInput(0) and XInput(1) for instance

Posting Permissions

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