Skip to content

Commit

Permalink
fix: fix windows detection
Browse files Browse the repository at this point in the history
  • Loading branch information
heiso committed May 12, 2024
1 parent 7be1e0f commit b34ce65
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,15 +804,15 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
return tud_control_xfer(rhport, request, &size, request->wLength);
}

return true;
break;
}

case VENDOR_VALUE_GET: {
if (stage == CONTROL_STAGE_SETUP) {
return tud_control_xfer(rhport, request, &user_config, request->wLength);
}

return true;
break;
}

case VENDOR_VALUE_SET: {
Expand All @@ -826,7 +826,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
init_keys();
}

return true;
break;
}

default:
Expand All @@ -845,7 +845,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
return tud_control_status(rhport, request);
}

return true;
break;
}
}

Expand All @@ -857,15 +857,15 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
return tud_control_xfer(rhport, request, &size, request->wLength);
}

return true;
break;
}

case VENDOR_VALUE_GET: {
if (stage == CONTROL_STAGE_SETUP) {
return tud_control_xfer(rhport, request, &keys, request->wLength);
}

return true;
break;
}

default:
Expand All @@ -874,30 +874,54 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
}

case VENDOR_REQUEST_WEBUSB: {
return tud_control_status(rhport, request);
if (stage == CONTROL_STAGE_SETUP) {
return tud_control_status(rhport, request);
}

break;
}

case VENDOR_REQUEST_MICROSOFT: {
if (request->wIndex == 7) {
// Get Microsoft OS 2.0 compatible descriptor
uint16_t total_len;
memcpy(&total_len, desc_ms_os_20 + 8, 2);
if (stage == CONTROL_STAGE_SETUP) {
if (request->wIndex == 7) {
// Get Microsoft OS 2.0 compatible descriptor
uint16_t total_len;
memcpy(&total_len, desc_ms_os_20 + 8, 2);

return tud_control_xfer(rhport, request, (void *)(uintptr_t)desc_ms_os_20, total_len);
}

return tud_control_xfer(rhport, request, (void *)(uintptr_t)desc_ms_os_20, total_len);
} else {
return false;
}

break;
}

default:
break;
}
}

case TUSB_REQ_TYPE_CLASS: {
if (stage == CONTROL_STAGE_SETUP) {
if (request->bRequest == 0x22) {
// response with status OK
return tud_control_status(rhport, request);
}

return false;
}

break;
}

default:
break;
}

if (stage != CONTROL_STAGE_SETUP) {
return true;
}
return false;
}

Expand Down

0 comments on commit b34ce65

Please sign in to comment.