Clipboard -> Set up -> Joystick -> Flight -> You'll see a column of actions on the left and a column showing buttons on the right. Along the top is a chart of joystick buttons. As you press a button, the corresponding square on the chart will darken. Simply use your mouse to select an action, then press the joystick button you want to use for that action, then click "Apply".
I have 1 button for Primary guns, 1 button for secondary guns, 1 button for firing both. I use a CH Fighterstick, so I also have view zoom, trim, and flaps mapped to buttons on my stick.
This only works if you're a Rook. If you're a Knight or a Bishop, then you don't need your guns, flaps, trim, or divebrakes. You just need to map your throttle to "Full" and have 1 button to release your bombs just before you slam into the airfield hangar or carrier deck.