Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.
While it is traditional to have buttons on pins that are pulled up, and
have the button connect them to the ground, some CircuitPython boards
(notably the CPX) have the button pins pulled low and the button
connects them to VCC.
This patch makes the gamepad only change the pin's pull if it wasn't
already set when passed to the constructor, and also makes it consider
a button pressed when its value is the opposite of its pull.
If a soft reset happens while the gamepad module is scanning for button
presses, there is a moment when the pins get de-initialized, but the
gamepad module is still trying to read them, which ends in a crash.
We can avoid it by disabling scanning on reset.
(cherry picked from commit 470a23d4c9)
Conflicts:
atmel-samd/main.c