Gracefully reset the gamepad module
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
This commit is contained in:
parent
a1be272b1e
commit
1c97b7f4df
|
@ -193,6 +193,9 @@ void reset_port(void) {
|
|||
//
|
||||
// analogin_reset();
|
||||
//
|
||||
// #ifdef CIRCUITPY_GAMEPAD_TICKS
|
||||
// gamepad_reset();
|
||||
// #endif
|
||||
//
|
||||
// // Wait for the DAC to sync then reset.
|
||||
// while (DAC->STATUS.reg & DAC_STATUS_SYNCBUSY) {}
|
||||
|
|
|
@ -49,3 +49,7 @@ void gamepad_tick(void) {
|
|||
gamepad_singleton->pressed |= gamepad_singleton->last & gamepad_current;
|
||||
gamepad_singleton->last = gamepad_current;
|
||||
}
|
||||
|
||||
void gamepad_reset(void) {
|
||||
gamepad_singleton = NULL;
|
||||
}
|
||||
|
|
|
@ -28,5 +28,6 @@
|
|||
#define MICROPY_INCLUDED_GAMEPAD_H
|
||||
|
||||
void gamepad_tick(void);
|
||||
void gamepad_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_GAMEPAD_H
|
||||
|
|
Loading…
Reference in New Issue