|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeyboardController::new_data(const Transfer_t *transfer) |
|
|
void KeyboardController::new_data(const Transfer_t *transfer) |
|
|
{ |
|
|
{ |
|
|
processing_new_data_ = true; |
|
|
|
|
|
println("KeyboardController Callback (member)"); |
|
|
println("KeyboardController Callback (member)"); |
|
|
print(" KB Data: "); |
|
|
print(" KB Data: "); |
|
|
print_hexbytes(transfer->buffer, 8); |
|
|
print_hexbytes(transfer->buffer, 8); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
memcpy(prev_report, report, 8); |
|
|
memcpy(prev_report, report, 8); |
|
|
queue_Data_Transfer(datapipe, report, 8, this); |
|
|
queue_Data_Transfer(datapipe, report, 8, this); |
|
|
processing_new_data_ = false; |
|
|
|
|
|
|
|
|
|
|
|
// See if we have any outstanding leds to update |
|
|
|
|
|
if (update_leds_) { |
|
|
|
|
|
updateLEDS(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void KeyboardController::updateLEDS() { |
|
|
void KeyboardController::updateLEDS() { |
|
|
println("KBD: Update LEDS", leds_.byte, HEX); |
|
|
|
|
|
if (processing_new_data_) { |
|
|
|
|
|
println(" Update defered"); |
|
|
|
|
|
update_leds_ = true; |
|
|
|
|
|
return; // defer until later |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Now lets tell keyboard new state. |
|
|
// Now lets tell keyboard new state. |
|
|
static uint8_t keyboard_keys_report[1] = {0}; |
|
|
|
|
|
setup_t keys_setup; |
|
|
|
|
|
keyboard_keys_report[0] = leds_.byte; |
|
|
|
|
|
queue_Data_Transfer(datapipe, report, 8, this); |
|
|
|
|
|
mk_setup(keys_setup, 0x21, 9, 0x200, 0, sizeof(keyboard_keys_report)); // hopefully this sets leds |
|
|
|
|
|
queue_Control_Transfer(device, &keys_setup, keyboard_keys_report, this); |
|
|
|
|
|
|
|
|
|
|
|
update_leds_ = false; |
|
|
|
|
|
|
|
|
mk_setup(setup, 0x21, 9, 0x200, 0, sizeof(leds_.byte)); // hopefully this sets leds |
|
|
|
|
|
queue_Control_Transfer(device, &setup, &leds_.byte, this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|