strange cube mx usb hid should work out of the box !
at least it did for me on f4discovery and cusomized nucleof401
make sure to select the “righ”t usb ie FS (for f4) o but it could be HS if both present on that board ( even use only an low speed)
make sure to setup RCC to have 48Mhz clock on USB source “48MHz clock” on cubemx
using internal osc (HSI) may not give stable/precise enought USB clock
for HID it seam ok (it wan’t for CDC) best is to use HSE and have external 8Mhz crystal