|
-
-
- #include <Arduino.h>
- #include "USBHost.h"
-
-
- KeyboardController::KeyboardController()
- {
-
- driver_ready_for_device(this);
- }
-
- bool KeyboardController::claim(Device_t *dev, int type, const uint8_t *descriptors, uint32_t len)
- {
- println("KeyboardController claim this=", (uint32_t)this, HEX);
-
-
- if (type != 1) return false;
- if (len < 9+9+7) return false;
-
- uint32_t numendpoint = descriptors[4];
- if (numendpoint < 1) return false;
- if (descriptors[5] != 3) return false;
- if (descriptors[6] != 1) return false;
- if (descriptors[7] != 1) return false;
- if (descriptors[9] != 9) return false;
- if (descriptors[10] != 33) return false;
- if (descriptors[18] != 7) return false;
- if (descriptors[19] != 5) return false;
- uint32_t endpoint = descriptors[20];
- println("ep = ", endpoint, HEX);
- if ((endpoint & 0xF0) != 0x80) return false;
- endpoint &= 0x0F;
- if (endpoint == 0) return false;
- if (descriptors[21] != 3) return false;
- uint32_t size = descriptors[22] | (descriptors[23] << 8);
- println("packet size = ", size);
- if (size != 8) return false;
- uint32_t interval = descriptors[24];
- println("polling interval = ", interval);
- datapipe = new_Pipe(dev, 3, endpoint, 1, 8, 64);
- datapipe->callback_function = callback;
- queue_Data_Transfer(datapipe, report, 8, this);
- return true;
- }
-
- void KeyboardController::callback(const Transfer_t *transfer)
- {
- println("KeyboardController Callback (static)");
- if (transfer->driver) {
- ((KeyboardController *)(transfer->driver))->new_data(transfer);
- }
- }
-
- void KeyboardController::new_data(const Transfer_t *transfer)
- {
- println("KeyboardController Callback (member)");
- print(" KB Data: ");
- print_hexbytes(transfer->buffer, 8);
-
- queue_Data_Transfer(datapipe, report, 8, this);
- }
-
- void KeyboardController::disconnect()
- {
-
- }
-
-
|