Emulate a NES gamepad with Arduino

I’d like to use my Arduino as a NES gamepad, and I’d like to know if it is possible to assign sent text in Processing as stdin for other programs. My emulator is, on Linux, gfce-ultra, and I just want to emulate a keyboard on my Arduino, but a keyboard with good-placed keys for playing NES games. Here is my code. I really need your help.

Manette_NES.ino (3.05 KB)

The delay(500) is here to prevent keys repetition.
I forgot to say that my english is very bad, that I’m an Arduino newbie, and that I’ve a bug (I think) on the 12th pin (please see my code). That’s all for the moment.