So the Wii Joystick uses a Blue Tooth interface which is a little different than the N64 controller. As a result this answer deals more with the latter than the former.
The N64 controller uses a single transmission wire on which it encodes bits to send signals back to the N64 console. To accomplish this bits are encoded on that wire as follows:

This encoding can then be used to multiplex the connection and allow 32 bit communication. In the case of the N64 controller these bits are encoded thus:
0 A
1 B
2 Z
3 Start
4 Directional Up
5 Directional Down
6 Directional Left
7 Directional Right
8 unknown (always 0)
9 unknown (always 0)
10 L
11 R
12 C Up
13 C Down
14 C Left
15 C Right
With the remaining 16 bits being used for the Analog Joystick (providing 8 degrees of control).
More over, certain codes are transmitted for specialized function:
To Init: send 03 80 01 followed by 34 80's
To Start Rumble: 03 c0 1b followed by 32 01's
To Stop Rumble: 03 c0 1b followed by 32 00's
You can find more information in this vein here