USB bootloader for the arduino DUE
You shouldn't have to rewrite the Arduino Due bootloader - you just need to write a program that can act as USB HID using the native USB port, and upload the program to the Arduino Due. You can use the Due's programming USB port to do the upload.

But here's info on the Arduino Due boot process:

The Due has a ROM bootloader that listens to the USB native port and Serial port 0. You can talk to the ROM bootloader via USB directly by resetting the SAM3X8E and using the native port. But I've not found that method to be very reliable. The more frequently used programming port is connected to an Atmel AVR 16U2 microprocessor acting as a USB-serial converter, connected to the SAM3X8E serial port 0. The Arduino 1.5 IDE can talk to the 16U2 using the Bossa command (bossac), reset the SAM3X8E, and upload new programs to it it. This page explains the Arduino Due's bootloader in detail.

If you're interested, here's the source code for the 16U2 AVR USB-serial converter.

And here's Bossa - the Due's command that corresponds to avrdude.

Using bossac (the Bossa commandline tool), you can upload code the SAM3X8E, using the builtin ROM bootloader.



On creating HID devices:

Here's a link to an Atmel application note that has example code for creating a program that can act as a USB HID keyboard: 

http://asf.atmel.com/docs/latest/common.services.usb.class.hid.device.keyboard.example.sam3x_ek/html/index.html

The source code to this example is the in the Atmel ASF packages - unfortunately, a large download. Here's where to get it:

http://asf.atmel.com/docs/latest/download.html

Once you download it, the source code the HID keyboard example is in this folder:

common/services/usb/class/hid/device/kbd/example/sam3x8e_arduino_due_x

Here's a list of the other app notes, with examples of other kinds of USB and HID devices. Look for the ones that are for the Arduino Due:

http://asf.atmel.com/docs/latest/applications.html