Accessing Keyboard.press from a .cpp file

Status
Not open for further replies.

kevin_sydney

New member
This is more an Arduino IDE question than a Teensy question, but I'm hoping you guys know the answer. I'm trying to split my project up so it's more manageable, so I've set it up similarly to this:

Code:
main/
  src/
    some-class.h
    some-class.cpp
  main.ino

If I call Keyboard.press from main.ino it's fine, but if I call it from some-class.cpp I get:

Code:
error: 'Keyboard' was not declared in this scope
To make a USB Keyboard, use the Tools > USB Type menu
     Keyboard.press(m_keycode);

This is a Teensy 3.6 and the USB Type is set as "Serial + Keyboard + Mouse + Joystick". Is there something I need to #include to get Keyboard to work from a .cpp file, or is there some kind of extern declaration that I need?
 
Status
Not open for further replies.
Back
Top