Teensy keyboard forwarder doesn't work on other computers

Hello, I used the example project "KeyboardForeward" from the usbhost_t36 library you can see the code here:

This works just fine when used on the same computer that has arduino ide and the Teensy4.1 board installed. It does NOT work on any other computer. For example I tried on my laptop which runs the same Windows version, it didn't work, then I installed the Teensy4.1 board in arduino IDE and it started working.

I want the Teensy to work as a keyboard when plugged into any device without having to have software installed. SURELY this must be possible, or the teensy
would be quite worthless as an IoT board....

can someone help me with what I am missing here? I really appreciate the help
 
okay ten seconds later I figured it out you have to comment out the line that says
#define SHOW_KEYBOARD_DATA

then it magically works on the other devices cool.
 
@Jeremy Smith:

In that example sketch, at the beginning of the setup() function, there's the following code:

Code:
#ifdef SHOW_KEYBOARD_DATA
    while (!Serial) ; // wait for Arduino Serial Monitor
    Serial.println("\n\nUSB Host Keyboard forward and Testing");
    Serial.println(sizeof(USBHub), DEC);
#endif

Here's the detailed explanation of what you are seeing (in case you're not already familiar with using #ifdef to activate/deactivate portions of your code):

The line while (!Serial) ; will wait forever if the Serial Monitor is not active/connected (as is the case on your second computer). By commenting out the #define SHOW_KEYBOARD_DATA line (which means that the constant SHOW_KEYBOARD_DATA is no longer defined / no longer exists), you have effectively removed the entire section of code inside of the #ifdef SHOW_KEYBOARD_DATA and #endif pair (which literally means "if SHOW_KEYBOARD_DATA is defined/exists, then include any code until the next #endif).

Hope that helps in understanding what you are seeing . . .

Mark J Culross
KD5RXT
 
Yes I knew it was something in that block (I am familiar with using #ifdef) but I wasn't sure if was using serial commands or if it was that first line waiting for the serial monitor. Makes sense. Thank you!
 
Back
Top