alecgibson
Posts: 1
Joined: Mon May 18, 2015 12:38 pm

Joypad Polling

Mon May 18, 2015 12:47 pm

I'm new to Pi development, but know some Python, so I'm helping a group of kids get started with their Pi using the provided library. I've had a look through the APIs, but there seems to be no mention of interaction with the Joypad / Directional Pad. Is anyone to advise on how the pad is accessed?

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1665
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Joypad Polling

Mon May 18, 2015 7:35 pm

The joystick just looks like a USB keyboard mapped to the cursor keys and Enter.
Try using it to navigate the Linux terminal history! :)

So all you need to do is look for those same keyboard events.
You should have an example file which demonstrates it.

Code: Select all

cd ~/astro-pi-hat/examples
./pygame_joystick.py
Code is also online here.
https://github.com/astro-pi/astro-pi-ha ... oystick.py

Return to “Astro Pi”