Here is one document I have written that you could store the controller playback as MIDI file or using MIDI input/output, both for emulation and possibly for playback on real NES/Famicom hardware too. They can also record and playback data in memory. It may be usable even for thing other than NES/Famicom, too. This document is not complete here is what it is so far:
Code:
Channel:
0=Player 1 controller/expansion
1=Player 2 controller/expansion
2=Player 3 controller/expansion
3=Player 4 controller/expansion
4=
5=
6=
7=
8=Poke main memory
9=Poke video memory
10=
11=
12=Emulator macro 1
13=Emulator macro 2
14=Emulator macro 3
15=Emulator macro 4
Message (controller/expansion):
Note off=released button
Note on=pushed button (velocity=64 if not pressure-specific, 0=note off)
Key pressure=if pressure changed
Control=various, depends on program/device type
Program=select device type
Channel pressure=unuse
Pitch wheel=various
Message (memory):
Program (controller/expansion):
0=NES/Famicom/GameBoy (note: 0=A, 1=B, 2=SELECT, 3=START, 4=up, 5=down,
6=left, 7=right)
1=GameBoy Advance (note: 8=L, 9=R)
2=SuperNES/SuperFamicom/NintendoDS buttons (note: 10=X, 11=Y)
3=Famicom Mahjong (note: 2=SELECT, 3=START, 8=KAN, 9=PON, 10=CHII,
11=RIICHI, 12=RON, 64...77=tiles in hand)
4=Light gun (note: 60=button, 62=light)
5=Exciting Boxing (note: 0=right hook, 1=right move, 2=left move, 3=left
hook, 4=straight, 5=right jab, 6=body, 7=left jab)
6=Family Trainer (notes 1...12 correspond to buttons numbered 1 to 12 on
side B)
7=VS Unisystem (notes: 0=left coin, 1=right coin, 2=service) (controls:
64...71=switches; value 0=off 127=on)
8=Famicom keyboard
9=Crazy Climber
10=Arkanoid
11=Top Rider
12=OekaKids Tablet
13=TurboFile
14=Hyper Shot
15=SpaceShadow Gun
16=Barcode
17=IBM PC keyboard
18=American NES four player device (same notes as program 0)
19=Mouse
20=Nintendo 64
21=GameCube
22=Wii remote
23=Wii classic
24=GameBoy Printer
25=PlayStation
26=XBOX
27=Piano keyboard
127=Unuse (default setting)
Controls (memory):
0=bits 0x000F of address
1=bits 0x00F0 of address
2=bits 0x0F00 of address
3=bits 0xF000 of address
7=bits 0x7F0000 of address (unuse for NES/Famicom)
16=bits 0x0F of data
17=bits 0xF0 of data
Notes (memory):
127=Write data to memory
0=Player 1 controller/expansion
1=Player 2 controller/expansion
2=Player 3 controller/expansion
3=Player 4 controller/expansion
4=
5=
6=
7=
8=Poke main memory
9=Poke video memory
10=
11=
12=Emulator macro 1
13=Emulator macro 2
14=Emulator macro 3
15=Emulator macro 4
Message (controller/expansion):
Note off=released button
Note on=pushed button (velocity=64 if not pressure-specific, 0=note off)
Key pressure=if pressure changed
Control=various, depends on program/device type
Program=select device type
Channel pressure=unuse
Pitch wheel=various
Message (memory):
Program (controller/expansion):
0=NES/Famicom/GameBoy (note: 0=A, 1=B, 2=SELECT, 3=START, 4=up, 5=down,
6=left, 7=right)
1=GameBoy Advance (note: 8=L, 9=R)
2=SuperNES/SuperFamicom/NintendoDS buttons (note: 10=X, 11=Y)
3=Famicom Mahjong (note: 2=SELECT, 3=START, 8=KAN, 9=PON, 10=CHII,
11=RIICHI, 12=RON, 64...77=tiles in hand)
4=Light gun (note: 60=button, 62=light)
5=Exciting Boxing (note: 0=right hook, 1=right move, 2=left move, 3=left
hook, 4=straight, 5=right jab, 6=body, 7=left jab)
6=Family Trainer (notes 1...12 correspond to buttons numbered 1 to 12 on
side B)
7=VS Unisystem (notes: 0=left coin, 1=right coin, 2=service) (controls:
64...71=switches; value 0=off 127=on)
8=Famicom keyboard
9=Crazy Climber
10=Arkanoid
11=Top Rider
12=OekaKids Tablet
13=TurboFile
14=Hyper Shot
15=SpaceShadow Gun
16=Barcode
17=IBM PC keyboard
18=American NES four player device (same notes as program 0)
19=Mouse
20=Nintendo 64
21=GameCube
22=Wii remote
23=Wii classic
24=GameBoy Printer
25=PlayStation
26=XBOX
27=Piano keyboard
127=Unuse (default setting)
Controls (memory):
0=bits 0x000F of address
1=bits 0x00F0 of address
2=bits 0x0F00 of address
3=bits 0xF000 of address
7=bits 0x7F0000 of address (unuse for NES/Famicom)
16=bits 0x0F of data
17=bits 0xF0 of data
Notes (memory):
127=Write data to memory