Problem understanding HID in Arduino Leonardo

Hi everyone :stuck_out_tongue_closed_eyes:
making an Arduino UNO a HID device requires changing the firmware of the Atmel16u2 the second chip/MCU on the Arduino UNO board which is responsible of the data transfer between the arduino and the USB Port of the PC,
so what do make the Arduino Leonardo capable of sending data to the PC as a HID like Keyboard?, just with including the keyboard library
while the Atmel 16u2 cant until we change the firmware
where in the Atmel 32u4 is those settings and the device name stored?. if its not in the Bootloader where in and not in the source code how can be change for example the nature of the device CDC,HID or the name?
thanks !

hardware/avr/cores/arduino/CDC.cpp
hardware/avr/cores/arduino/USBAPI.h
hardware/avr/cores/arduino/USBCore.h
hardware/avr/cores/arduino/USBCore.cpp
hardware/avr/cores/arduino/PlugableUSB.cpp
hardware/avr/cores/arduino/PlugableUSB.h
hardware/avr/cores/arduino/USBDesc.h
hardware/avr/libraries/HID/src/HID.h
hardware/avr/libraries/HID/src/HID.cpp
libraries/Keyboard/sc/Keyboard.cpp
libraries/Keyboard/sc/Keyboard.h
libraries/Mouse/src/Mouse.cpp
libraries/Mouse/src/Mouse.h