First thing to note is that some 'joysticks' come with I2C interfaces (the Nintendo nunchucks being the classic ones) and this bus can be used by using more than one I2C device at once. Using these joysticks can save a lot of hassle BUT you may need eBay to get them.
For analogue joysticks, the simplest way is to look into I2C or SPI analogue to digital converters (ADCs) that handle multiple inputs.
Each pot on the joystick then feeds one input and you poll the ADC to find the value and then position of the joystick. Despite the joystick being able to move in four directions you only need two channels per stick.
In these type of converters you normally have a pay off and have to work out if resolution (i.e. the number of bits) is more vital than conversion speed:
- Do you need to know the player is moving up / left - if so fast conversion speed and low accuracy is what you need
- Do you need to know the player is 10% up and 45% left - if so conversion accuracy is more important than speed
You will find that a trade is required between speed, accuracy and cost :-)
AB Electronics have quick guide to this type of connection here but many other suppliers can be found with a quick Google search.
For digital joysticks (i.e. where each direction is a switch) there are two classic ways you can approach this:
- Multiplex - here the switches are scanned in turn on a row / column matrix. This is how many many keyboards work.
- Input / Output expanders (often connected to I2C). These give many many more ports at the cost of a little coding - you selected the device, the port and then read the value.
Other thoughts are a bit slow today but to get you thinking:
- Put a small micro-controller between the joystick and the Pi - the micro controller then does the hardworking and sits on I2C reporting a bit mapped value (for digital) or a set of values in registers (for analogue)
- Use Bluetooth controllers - be aware Bluetooth programming is a real PAIN in the **** due to lack of documentation unless you find a library
- Use a microcontroller to represent a keyboard key press for each switch and feed this is to your program
To progress this I would:
- Decide if you need accuracy (analogue) or general direction?
- Decide on the number / type of inputs (remembering buttons / tilt etc)
- Try a few solutions (code / hardware) on one joystick and work out if it can scale.
- Repeat from step one till you have a glance between cost / effectiveness for your game