1
0
mirror of https://github.com/gdsports/USBHost_t36 synced 2024-11-21 16:45:04 -05:00

FIX - Keyboard LEDS

The main issue was I used a setup structure on the stack which turned into garbage.  Earlier I thought the data was copied, but it was not...

Found that fixing this resolved the earlier issue where I needed to defer the update.  So removed the defered code, plus use member variable for the one byte output instead of static variable.
This commit is contained in:
Kurt Eckhardt 2017-11-07 07:08:36 -08:00
parent ec4a7ac24c
commit d3e21b04c0
2 changed files with 2 additions and 24 deletions

View File

@ -669,8 +669,6 @@ private:
uint8_t keyOEM; uint8_t keyOEM;
uint8_t prev_report[8]; uint8_t prev_report[8];
KBDLeds_t leds_ = {0}; KBDLeds_t leds_ = {0};
bool update_leds_ = false;
bool processing_new_data_ = false;
Pipe_t mypipes[2] __attribute__ ((aligned(32))); Pipe_t mypipes[2] __attribute__ ((aligned(32)));
Transfer_t mytransfers[4] __attribute__ ((aligned(32))); Transfer_t mytransfers[4] __attribute__ ((aligned(32)));
strbuf_t mystring_bufs[1]; strbuf_t mystring_bufs[1];

View File

@ -179,7 +179,6 @@ static bool contains(uint8_t b, const uint8_t *data)
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);
@ -197,12 +196,6 @@ void KeyboardController::new_data(const Transfer_t *transfer)
} }
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();
}
} }
@ -328,22 +321,9 @@ void KeyboardController::LEDS(uint8_t leds) {
} }
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}; mk_setup(setup, 0x21, 9, 0x200, 0, sizeof(leds_.byte)); // hopefully this sets leds
setup_t keys_setup; queue_Control_Transfer(device, &setup, &leds_.byte, this);
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;
} }