Because it's analog, you'll need two analog reading pins on your own microcontroller to ascertain X and Y. Getting an additional digital input will Enable you to examine the switch. Be aware that this example assumes you might be working with an Arduino-compatible board that supports the Joystick library, including https://analog-stick04680.dbblog.net/11330866/details-fiction-and-joystick-controller