Giving a Custom Name to the USB Keyboard/Mouse Device Emulated by the ATmega32U4

Hi

When using the ATmega32U4 to emulate a Keyboard/mouse,
If you go to Device Manager, you see a generic name for them.

Is it possible, in code, to give a more meaningful name to the Keyboard and Mouse?

Thank you

Is it possible, in code, to give a more meaningful name to the Keyboard and Mouse?

I have no clue about the Windows side but as you can do the same in Linux by only changing stuff on the Linux machine I guess you should ask on a Windows forum as it’s an OS problem and not an Arduino problem.

Hi pylon

Thank you for your idea.

Please note that what you suggest is different than what I meant.

You suggest that the user renames his USB Device,
while my question is about how the device itself identifies in the first place.

For example,
when you connect a USB Flash Drive to your computer,
you will mostlikely see "Sandisk Extreme 128GB" in the Device Manager,
without you having to do anything.

It's in the firmware of the USB Flash Drive.

So my question is If using Arduino Code I can also choose some custom name for the Keyboard/Mouse that I emulate with the ATmega32U4,
instead of the general name that is given..

That mean you want to provide custom USB manufacturer and product strings. There is no support in the API to do that but you may change the default strings in your IDE by editing the file USBCore.pp (search for USB_MANUFACTURER and USB_PRODUCT). Please not that doing that will change the corresponding string for every sketch you upload to such a device. And note also that the bootloader contains it's own strings so if you want to change them you have to compile your own bootloader.

Shame on you for even asking such a question on an Arduino forum. The very FIRST hit when I Googled "USB programming" explains exactly where you must begin.

Paul

pylon:
That mean you want to provide custom USB manufacturer and product strings.

There is no support in the API to do that but you may change the default strings in your IDE by editing the file USBCore.pp (search for USB_MANUFACTURER and USB_PRODUCT). Please note that doing that will change the corresponding string for every sketch you upload to such a device.

I think it will change the string for every sketch for every Arduino of tht type..
So If I have 5, all of them will get it..
Not exactly what I wished to get.

pylon:
And note also that the bootloader contains it's own strings so if you want to change them you have to compile your own bootloader.

Hmm, that's something I wish not to mess with..

OK seems that the answer is that what I am looking for is not supported.

Maybe it can be a feature suggestion for next versions of the IDE..

I think it will change the string for every sketch for every Arduino of tht type..
So If I have 5, all of them will get it..
Not exactly what I wished to get.

So it might be a good idea to tell us what you want to achieve and not how you think it should be achieved. I get the impression you just want a serial number activated.

Well in this case it’s not really a Serial Number added,
but simply a way to differentiate the regular Keyboards/Mice in the list, for the Emulated one…

They all get the usual standard and identical “HID Device” string.

They all get the usual standard and identical "HID Device" string.

But that string is from your OS and not from the device.

From what I know USB Devices define that string.

Manyh USB Chips have a small EEPROM area, which allows manufacturers to define their Company Name and product's Display Name

Some USB Chips do not have the EEPROM built-in, so they enable adding a small EEPROM chip aside to them, for defining that info..

From what I know USB Devices define that string.

As far as I know this isn't true. You have to provide a vendor- and product-ID. You may provide a manufacturer and product string. My OS doesn't show that string for my mouse or keyboard so I'm almost sure that string is displayed by your OS for every HID type device.

Some USB Chips do not have the EEPROM built-in, so they enable adding a small EEPROM chip aside to them, for defining that info..

And the ATmega32U4 allows to set that in software. But the IDE doesn't set the string to "HID Device". Check it yourself if you don't believe me.

I believe you :slight_smile:
And I thank you for all your help.

It seems that the answer is just simply no, at least for what I was hoping for (customized per item, not per type).

So OK, thank you for all the info.

I'm interesting in this as well, changing device name in device manager and Arduino IDE that is.

This is only assumptions:
As I understand chip Bootloader defines device name.
To change it in bootloader mode I think you have to modify bootloader code, recompile and upload it or it may be possible to target MCU memory directly and change it that way...

For a regular run time, for example HID it's probably defined by USB library.

pylon:
That mean you want to provide custom USB manufacturer and product strings. There is no support in the API to do that but you may change the default strings in your IDE by editing the file USBCore.pp (search for USB_MANUFACTURER and USB_PRODUCT). Please not that doing that will change the corresponding string for every sketch you upload to such a device. And note also that the bootloader contains it's own strings so if you want to change them you have to compile your own bootloader.

I'm guessing USB_MANUFACTURER and USB_PRODUCT privates/constants?

Solution would be to add public function to USB library (USBCore.cpp in this case) whos job is to change USB_MANUFACTURER and USB_PRODUCT on request. Doesn't look very difficult task.

To change it in bootloader mode I think you have to modify bootloader code, recompile and upload it or it may be possible to target MCU memory directly and change it that way...

Correct, you have to modify the bootloader to change the two strings there.

I'm guessing USB_MANUFACTURER and USB_PRODUCT privates/constants?

They are precompiler definitions so you might get them set without modifying the library but in my experience it's almost impossible to set precompiler definitions using the IDE that are set in the correct order to be visible in standard libraries. At least that's subject to be changed in future versions.

Solution would be to add public function to USB library (USBCore.cpp in this case) whos job is to change USB_MANUFACTURER and USB_PRODUCT on request. Doesn't look very difficult task.

You cannot do that at any time. Once the HID type is registered you can change the strings as often as you like but you won't see any difference on the host system.

Thank you 3Dgeo for your really good ideas

pylon:
You cannot do that at any time. Once the HID type is registered you can change the strings as often as you like but you won't see any difference on the host system.

Actually this is OK:
The important thing is how the USB Device registers itself to the computer, the first time it is connected..
After that, the developer usually has no reason to change it..

The whole idea is to be able to choose a custom name, so it will be more easily identifiable on the PC..
After that, there really is no reason to change it anymore..

BTW, what would be the difference (in outcome) between changing the Bootloader and changing USB_MANUFACTURER and USB_PRODUCT?
The Bootloader affects the name shown in a different place than USB_MANUFACTURER and USB_PRODUCT?

The whole idea is to be able to choose a custom name, so it will be more easily identifiable on the PC..
After that, there really is no reason to change it anymore..

Keep in mind that the manufacturer and product strings are already identifiable in your case. "HID Device" is neither the manufacturer nor the product string.

BTW, what would be the difference (in outcome) between changing the Bootloader and changing USB_MANUFACTURER and USB_PRODUCT?

The bootloader is only active if you either press the reset button on the board or start a special process on the PC (set the configuration to 1200 baud).

The Bootloader affects the name shown in a different place than USB_MANUFACTURER and USB_PRODUCT?

No, at another time.

pylon:
Keep in mind that the manufacturer and product strings are already identifiable in your case. "HID Device" is neither the manufacturer nor the product string.

You have a point..

Is the "HID Device" changeable too, by the device, or only defined by the OS?

Is the "HID Device" changeable too, by the device, or only defined by the OS?

That's probably set by your OS for all devices with HID device type.

But if you select "Hardware-IDs" under "Details" you can see the Vendor- (VID) and Product-IDs (PID). Using these values you can easily identify the device, even under Windows.

Wait, just so we are one the same page, we are talking about this name change:

I've tried modifying USB_MANUFACTURER and USB_PRODUCT in USBCore.cpp, but it doesn't seems to have any effect so I'm guessing the only way is to changing bootloader.

Changing bootloader isn't that hard as well, I bet Arduino provides Leonardo bootloader source code, so opening its project in Atmel studio, changing USB_MANUFACTURER and USB_PRODUCT and recompiling it is straight forward process. If someone can find source code of Leonardo bootloader I would test this (sorry, too sick/lazy to Google it :slight_smile: ).

P.S. yes, I'm still using win7, it's the best OS till this day, bite me ;D

3Dgeo:
I've tried modifying USB_MANUFACTURER and USB_PRODUCT in USBCore.cpp, but it doesn't seems to have any effect so I'm guessing the only way is to changing bootloader.

Maybe it's because it is already registered on that computer?
Maybe on another computer, towhich that device has never been connected, the change will be seen?

3Dgeo:
P.S. yes, I'm still using win7, it's the best OS till this day

I am on Windows XP Pro SP3..
And I say the same thing you say: it's the best OS till this day.