As it's analog, you'll need two analog looking through pins with your microcontroller to find out X and Y. Obtaining an additional digital enter will let you examine the swap. Note that this example assumes you're using an Arduino-appropriate board that supports the Joystick library, such as the Arduino Leonardo https://martinolfar.p2blogs.com/36727862/considerations-to-know-about-joystick-controller