aiie/teensy/teensy-usb.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

2020-07-07 10:25:04 +00:00
#include <Arduino.h>
#include <USBHost_t36.h>
#include "teensy-usb.h"
2021-01-20 03:27:57 +00:00
// There are multiple hubs here because without them, USB ports won't work
// if it's a chained hub device. From what I've read, most hubs are 4-port
// devices -- but there are 7-port hubs, which use 2 chained hub chips, so
// for all the USB ports to work on those hubs we have to have 2 hub objects
// managing them. I've decided to limit this to 2 hub objects.
2020-07-07 10:25:04 +00:00
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
2021-01-20 03:27:57 +00:00
// One could have multiple keyboards? I think I'm not going to support that
// just yet, until I understand all of this better.
2020-07-07 10:25:04 +00:00
KeyboardController keyboard1(myusb);
2021-01-20 03:27:57 +00:00
//KeyboardController keyboard2(myusb);
2020-07-07 10:25:04 +00:00
TeensyUSB::TeensyUSB()
{
}
TeensyUSB::~TeensyUSB()
{
}
void TeensyUSB::init()
{
myusb.begin();
}
void TeensyUSB::attachKeypress(keyboardCallback cb)
{
keyboard1.attachRawPress(cb);
2021-01-20 03:27:57 +00:00
// keyboard2.attachRawPress(cb);
2020-07-07 10:25:04 +00:00
}
void TeensyUSB::attachKeyrelease(keyboardCallback cb)
{
keyboard1.attachRawRelease(cb);
2021-01-20 03:27:57 +00:00
// keyboard2.attachRawRelease(cb);
2020-07-07 10:25:04 +00:00
}
void TeensyUSB::maintain()
{
myusb.Task();
}
uint8_t TeensyUSB::getModifiers()
{
// FIXME: specifically keyboard1? guess the callbacks need a kb #
return keyboard1.getModifiers();
}
uint8_t TeensyUSB::getOemKey()
{
// same FIXME as getModifiers
return keyboard1.getOemKey();
}