Hak5.org has a cool item called the USB Rubber Ducky. It uses a small microcontroller to inject keystrokes while acting as a standard USB HID Device. This means a lot of different things are possible. It works just like a teensy(google for more info).
The interesting thing about this is that they created a scripting 'language'(if you can call it that) that is encoded(or interpreted) using a Java program to translate 'ducky script' into a runnable base16-representation of a binary for the 32-bit Atmel chip that's inside. I wanted to see what was going on in the encoder script so I downloaded jd-gui.exe.
I found out after a quick skim over the code that it was encoding the duck script into a very specific(yet somewhat predictable) format. This is when I looked into what this format is and what it's called: Intel HEX.
The encoder converts ducky 'syntax' into a pre-compiled 32-bit avr assembly program; this binary is referred to as a .HEX file. This is a text representation of the binary, much like opening up notepad.exe in a hex editor except that the format of this hex follows a specific format that correlates with the spec of the AT32UC3B1256 chip that is executing the code.
This binary code consists of functions for generating valid keyboard characters with arguments based on parameters provided by the user in the 'ducky script' and then pushing those values through a software-defined HID interface in affect to reach their destination at the driver/kernel level interface of the host operating system. This means you have to implement the USB-HID protocol from scratch and be sure that it works across all platforms.
Interesting stuff. I attached the duckencoder.jar in case anybody cares to take a look.