2017-08-24 16:41:39 -04:00
|
|
|
// Simple test of USB Host Mouse/Keyboard
|
|
|
|
//
|
|
|
|
// This example is in the public domain
|
|
|
|
|
|
|
|
#include "USBHost_t36.h"
|
|
|
|
|
|
|
|
USBHost myusb;
|
|
|
|
USBHub hub1(myusb);
|
|
|
|
USBHub hub2(myusb);
|
|
|
|
USBHub hub3(myusb);
|
|
|
|
KeyboardController keyboard1(myusb);
|
|
|
|
KeyboardController keyboard2(myusb);
|
2017-09-10 06:48:10 -04:00
|
|
|
USBHIDParser hid1(myusb);
|
|
|
|
USBHIDParser hid2(myusb);
|
|
|
|
USBHIDParser hid3(myusb);
|
|
|
|
USBHIDParser hid4(myusb);
|
|
|
|
USBHIDParser hid5(myusb);
|
2017-08-24 16:41:39 -04:00
|
|
|
MouseController mouse1(myusb);
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
2017-09-10 06:48:10 -04:00
|
|
|
while (!Serial) ; // wait for Arduino Serial Monitor
|
|
|
|
Serial.println("USB Host Testing");
|
|
|
|
myusb.begin();
|
|
|
|
keyboard1.attachPress(OnPress);
|
|
|
|
keyboard2.attachPress(OnPress);
|
2017-08-24 16:41:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
2017-09-10 06:48:10 -04:00
|
|
|
myusb.Task();
|
2017-08-24 16:41:39 -04:00
|
|
|
if(mouse1.available()) {
|
|
|
|
Serial.print("buttons = ");
|
2017-09-10 06:48:10 -04:00
|
|
|
Serial.print(mouse1.getButtons());
|
2017-08-24 16:41:39 -04:00
|
|
|
Serial.print(", mouseX = ");
|
2017-09-10 06:48:10 -04:00
|
|
|
Serial.print(mouse1.getMouseX());
|
2017-08-24 16:41:39 -04:00
|
|
|
Serial.print(", mouseY = ");
|
2017-09-10 06:48:10 -04:00
|
|
|
Serial.print(mouse1.getMouseY());
|
|
|
|
Serial.print(", wheel = ");
|
|
|
|
Serial.print(mouse1.getWheel());
|
|
|
|
Serial.print(", wheelH = ");
|
|
|
|
Serial.print(mouse1.getWheelH());
|
|
|
|
Serial.println();
|
2017-08-24 16:41:39 -04:00
|
|
|
mouse1.mouseDataClear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnPress(int key)
|
|
|
|
{
|
|
|
|
Serial.print("key '");
|
|
|
|
Serial.print((char)key);
|
|
|
|
Serial.print("' ");
|
|
|
|
Serial.println(key);
|
|
|
|
//Serial.print("key ");
|
|
|
|
//Serial.print((char)keyboard1.getKey());
|
|
|
|
//Serial.print(" ");
|
|
|
|
//Serial.print((char)keyboard2.getKey());
|
|
|
|
//Serial.println();
|
|
|
|
}
|
|
|
|
|