Removing serial CDC class to make a class-compliant MIDI device

Could someone tell me the "correct" way to remove the CDC class from a 32u4 to make a class-compliant USB MIDI device using the latest version of the IDE and its associated USB core files? I'm using the USBMIDI library.

I've been able to comment out a few lines in USBCore.cpp to seemingly give me the desired affect, but I'm not sure how to tell if I've done it right.

It used to be possible to comment out a single define to get rid of the CDC class, but that isn't the case now. I've seen various suggestions, but most of them seem to refer to older versions of the USB core files.

It seems like this would a common thing to want to do, but I haven't been able to find any up-to-date information.

Thanks for your help!

I've used this solution, and is working fine (at least in my project, where I need just keyboard support). One side effect is that you need to hit the reset button when you upload your sketch, since auto reset not works anymore.

Ciao, Ale.

Thanks, that's actually exactly what I ended up doing, which seems to work fine for me as well, but I wasn't sure if there was a more proper way, as the poster of that technique seemed to have some reservations.

Hi soryy for posting in an old topic but i have a similar issue.

i want a plain compliant keyboard to use with a kvm switch. My arduino isn't recognized as keyboard at all.

I already tried the suggestion in the link but nothing happens, additional com port is still there. And another question, i've read so many times that you need an additional ISP to program the arduino again if CDC is disabled. Is it true? Or does a manual reset do the same?

Which IDE version did you use to make it work?

Thx

My arduino isn't recognized as keyboard at all.

Which is the OS ? I ended up with this solution 'cause the OS was Windows 2000, which keep treating the board as com port, but this shouldn't be a problem with more modern OS.

Or does a manual reset do the same?

I my case, manual reset was fine to upload a sketch.

Ciao, Ale.

It works fine with Linux and windows but a kvm switch is a hardware device to switch keyboard mouse and video between different pcs.

Did you do something additional or just edit usbcore.cpp and comment out the 3 lines?

Just commented out the lines, recompiled and uploaded, I don't remembar that I did something else.

Ciao, Ale.

This might work.

https://forum.arduino.cc/index.php?topic=685009.0

Hi, thx for suggestions i was already using Bootkeyboard from HID-Project but it didn't work.
As far as i could see the library is not fully compliant with usb Standards. For example [boot] keyboards usually use 8 bytes for data, but the micro defaults to 64.

I was able to disable CDC but still no success.

There are some other possible issues. Googling around only ends up in unanswered forum threads.

Here’s how I have been removing the CDC, which works fine for my MIDI device. I’m not sure about keyboards. I put this version of USBCore.cpp in my sketch folder, which causes the IDE to use this one instead of the “normal” one. You can uncomment the first line if you want CDC back, which is very useful if you want to use serial for debugging.

https://github.com/amowry/warbl/blob/master/WARBL_1.8/USBCore.cpp

To answer the question about programming, my 32u4 programs just fine from the IDE after removing the CDC, but you do have to double-click the reset button to put it in bootloader mode when the IDE starts trying to upload.