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

Thread: Configure Teensy HID device from PC?

  1. #1

    Configure Teensy HID device from PC?

    I was planning on using a Teensy 4.1 as part of a DIY simulator setup but apparently none of the software that I as looking at using to control the setup works on the Teensy for various reasons (MMjoy2 & FreeJoy). How do I go about making the Teensy 4.1 configurable via software to change button mappings and keycodes without going into the IDE? I'm willing to code this from scratch if there's not already something I can use with the newer Teensy models otherwise I'm going to have to redo the whole project and change some circuits if I switch MCU's.

    EDIT: To clarify, I want to write a GUI or command line application that allows me to remap the inputs of my controller from PC. the controller uses Joystick + Keyboard HID mode. The keyboard keycodes are primarily what need changed from pc. Similar to what MMJoy2, Freejoy, and the U-HID and Bodnar board software can do. I'm not asking for help coding the mapping software per se, but more specifically how to communicate and configure the software on the Teensy. I know how to go about doing this with standard arduino/atmel chips where the bootloader can be modified but cant figure out how to do this on the teensy where the doesnt appear to be the case.
    Last edited by gregevans209; 01-25-2021 at 01:25 AM.

  2. #2
    Member squeeek's Avatar
    Join Date
    Feb 2015
    Location
    France
    Posts
    52
    Hey @gregevans209 !

    I discovered Freejoy just yesterday but already have a couple of Teensy's around, and planned to use them for just that kind of project, using Teensy LC and Teensy 4.1. I think what would be interesting is to first define the protocol (over USB serial) between the Teensy and the application. I don't know if it might be worth using the same as Freejoy or not, I did not dig deep enough into Freejoy. It would be cool to be able to use a command line to up/download mappings to the Teensy, and to activate loaded profiles through tihs protocol too, so that scripts could automagically activate the correct one for a given game, for example.

    My time is currently too short to code such things, but I'd definitely be willing to help on the specification and testing side if something completely new is being developed. Maybe I could also get my hands on a UX designer, at least for the GUI part.

    One point I have not yet found how to easily change (by software configuration or with a jumper on a digital input for example, with a preference for the first option) is the USB product ID (they do it on Freejoy and I find it useful when several controllers are connected, to know which one is which) as it is just some constants in .c and .h files

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,567
    Quote Originally Posted by gregevans209 View Post

    EDIT: To clarify, I want to write a GUI or command line application that allows me to remap the inputs of my controller from PC. the controller uses Joystick + Keyboard HID mode. The keyboard keycodes are primarily what need changed from pc. Similar to what MMJoy2, Freejoy, and the U-HID and Bodnar board software can do. I'm not asking for help coding the mapping software per se, but more specifically how to communicate and configure the software on the Teensy. I know how to go about doing this with standard arduino/atmel chips where the bootloader can be modified but cant figure out how to do this on the teensy where the doesnt appear to be the case.
    I hope I understood your question right... maybe, not...
    I don't get what this has to do with the bootloader, how a bootloader can help to remap inputs, and what the bootloader should do exactly. Can you clearify that?
    Normally the bootloader does what it name says... nothing more. Seems you want it to do something different?

    [quote]
    how to communicate and configure
    [/code]
    Write a program for the Teensy that accepts your commands via hid or serial, or.. anything you want.

    For the remapping: You can store the remapping in the eeprom and use that. On PC-Side you programm just needs to tell the Teensy what it should do.. Easiest via serial or HID protocol.
    If you don't want the Arduino IDE, there are alternatives (I like Platformio)

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,567
    Quote Originally Posted by squeeek View Post

    One point I have not yet found how to easily change (by software configuration or with a jumper on a digital input for example, with a preference for the first option) is the USB product ID (they do it on Freejoy and I find it useful when several controllers are connected, to know which one is which) as it is just some constants in .c and .h files
    Should be doable, but need some little changes to the core files... maybe Paul Stoffregen reads this and adds some macros...

    Edit: The Teensy loader will not find it anymore but there's the 15 sec reset that erases all and puts it into the orginal state.
    Last edited by Frank B; 03-03-2021 at 09:54 AM.

  5. #5
    Member squeeek's Avatar
    Join Date
    Feb 2015
    Location
    France
    Posts
    52
    Quote Originally Posted by Frank B View Post
    Should be doable, but need some little changes to the core files... maybe Paul Stoffregen reads this and adds some macros...

    Edit: The Teensy loader will not find it anymore but there's the 15 sec reset that erases all and puts it into the orginal state.
    OK let's see if Paul happens to stumble in that thread then. I suppose it would need a reboot of the Teensy, but that should not be an issue here. I did not get what you meant in your edit, sorry...

  6. #6
    Senior Member
    Join Date
    Jun 2013
    Posts
    381
    On Teensy 2.0, 3.2, and 3.6 I'm able to reconfigure my devices, but it involves a bit of hacking. I'm not going to give you all the details, but the reason it's possible is because the EEPROM can be read before the Teensy is enumerated. If you look around for some of my old posts from several years back you'll see some of the details about how to make it work.
    Last edited by yeahtuna; 03-11-2021 at 08:49 AM.

  7. #7
    Member squeeek's Avatar
    Join Date
    Feb 2015
    Location
    France
    Posts
    52
    Neat, thanks for the hint @yeahtuna ! EEPROM would definitely be a good candidate to store the USB product ID if it can be read at startup.

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,504
    This https://forum.pjrc.com/threads/65023...l=1#post262494 shows how to read out the EEProm before USB enumerates. In this case it was necessary to set the Serialnumber but it should work for changing other USB constants as well.

  9. #9
    Member squeeek's Avatar
    Join Date
    Feb 2015
    Location
    France
    Posts
    52
    Thanks @luni !

  10. #10
    Junior Member
    Join Date
    Aug 2019
    Posts
    17
    I have an instrument panel with encoders that send xplane commands to adjust the different instruments. I have one Air Manager panel that has a normal heading indicator and another that has an HSI and puts NAV2 into the NAV1 position (there are other differences). I have a mode switch on my "audo panel" that I use to switch the panel controller from one to the other, and a multi-color LED above it that says which mode it is in. Then, my code decides which XP command it's going to send for which encooder based on the mode it is in.

Posting Permissions

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