I am writing test software that runs keyboard firmware on a PC (because developing on a PC is faster without uploading to Teensy).
This code emulates Arduino's Keyboard.print() on a PC and uses it to test class KE:
But g++ gives this compile error:
The test Keyboard object needs to be made accessible from inside other classes. How is that done?
How does Arduino make it's Keyboard object accessible from inside other classes?
Arduino defines and instantiates Keyboard in arduino-1.0.5\hardware\teensy\cores\usb_hid\usb_api.cpp
Thank you for reading this long post.
This code emulates Arduino's Keyboard.print() on a PC and uses it to test class KE:
Code:
#include <iostream>
using namespace std;
class usb_keyboard_class // this emulates Arduino class of same name, but in runs on a PC
{
public:
void print(char const * const str) { cout << str; }
};
usb_keyboard_class Keyboard;
class KE // this is the class being tested, it calls the emulated Keyboard.print()
{
public:
void print(char const * const str)
{
Keyboard.print(char); //compile error: 'Keyboard' was not declared in this scope
}
};
KE ke;
int main()
{
ke.print("print_cpp");
}
But g++ gives this compile error:
'Keyboard' was not declared in this scope
The test Keyboard object needs to be made accessible from inside other classes. How is that done?
How does Arduino make it's Keyboard object accessible from inside other classes?
Arduino defines and instantiates Keyboard in arduino-1.0.5\hardware\teensy\cores\usb_hid\usb_api.cpp
Code:
// Preinstantiate Objects //////////////////////////////////////////////////////
usb_keyboard_class Keyboard = usb_keyboard_class();
Last edited: