0

I'm new to Teensy, and I'm trying to write a program that allows it to act as a keyboard. To make my program more useful, I'd like to make it not try to act on any input until its drivers install. I saw on GitHub that a way to do this (assuming the user doesn't hit it themselves) is to instruct the program to hit caps lock until the LED turns on. The function I wrote looks like this:

void waitForInstall(){
    boolean currCaps = keyboard_leds;
    while ((currCaps & 2) == (keyboard_leds & 2)){
        delay(200);
        Keyboard.set_key1(KEY_CAPS_LOCK);
        Keyboard.send_now();
    }
}

When I try to compile this, Arduino IDE informs me that 'keyboard_leds' was not declared in this scope. I'm sure I made a very basic mistake, but would anyone mind humoring me and giving me a push in the right direction? Thanks!

J. Doe
  • 1
  • 1

3 Answers3

0

keyboard_leds is a variable delcared in usb_private.h. This doesn't get included by default, and explicitly including it caused duplicate method errors. I wound up adding this

#include "usb_private.h"

to hardware/teensy/avr/cores/usb_hid/usb_hid.h

And that did the trick.

0

Add #include "usb_private.h" to hardware/teensy/avr/cores/usb_serial_hid/usb_api.h

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
weigu
  • 1
-1

You have to select which USB profile you want in the Tools => USB Type

It has to include "Keyboard" to define the keyboard_leds as available.

You probably want the "Serial + Keyboard + Mouse + Joystick" USB Type.

Bruce Barnett
  • 904
  • 5
  • 11