X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=converter%2Fusb_usb%2Fusb_usb.cpp;h=be690ffc55118681f5d1436c26ea1bdbaa381f71;hb=f8276ddb57c8b13931c3889a0b50711ea20c5d3d;hp=969e89f357673feb4c9b7d12a7625426bc179234;hpb=148c6a517549973a622f7df91f95e525550cd520;p=max%2Ftmk_keyboard.git diff --git a/converter/usb_usb/usb_usb.cpp b/converter/usb_usb/usb_usb.cpp index 969e89f3..be690ffc 100644 --- a/converter/usb_usb/usb_usb.cpp +++ b/converter/usb_usb/usb_usb.cpp @@ -32,6 +32,8 @@ along with this program. If not, see . #include "timer.h" #include "matrix.h" #include "led.h" +#include "host.h" +#include "keyboard.h" /* KEY CODE to Matrix @@ -151,6 +153,17 @@ uint8_t matrix_scan(void) { dprintf("host.Task: %d\n", timer); } + static uint8_t usb_state = 0; + if (usb_state != usb_host.getUsbTaskState()) { + usb_state = usb_host.getUsbTaskState(); + dprintf("usb_state: %02X\n", usb_state); + + // restore LED state when keyboard comes up + if (usb_state == USB_STATE_RUNNING) { + dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low"); + keyboard_set_leds(host_keyboard_leds()); + } + } return 1; }