As it's analog, you'll need two analog reading through pins in your microcontroller to determine X and Y. Obtaining an extra electronic input will Allow you to go through the switch. Observe that this example assumes that you are working with an Arduino-compatible board that supports the Joystick library, like https://georgeg227urm8.robhasawiki.com/user