Sensor Analog Potentiometer Joystick For PS4
This joystick is an analog similar to the ‘analog’ joysticks on the PlayStation 2 controllers. It's made of two potentiometers of a 10k value each, one for x-axis and the other for y-axis and a tactile button for select which is activated when the joystick is pressed down.
The two potentiometers are connected with a gimbal mechanism separating the horizontal and vertical movements. When in idle position, the stick is centered which means each potentiometer is in its center position or value. Back to axes notion, you can choose which potentiometer for which axis x or y randomly. In the picture above, you can see the way i chose my axes (for this example, the axes won't matter. You can choose any of the potentiometer to try the sketch).
As for the hardware connection, the middle pin of the potentiometer is for the analog data and the two others for power. It won't matter which pin would be connected to 5V or GND, it will simply affect the default data value a little bit but no change are necessary in the codes.