Skip to content

Commit c37b69e

Browse files
committed
Make the gamepad singleton long-lived
So that it is not later moved.
1 parent 1897ce4 commit c37b69e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

shared-bindings/gamepad/GamePad.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "py/obj.h"
2727
#include "py/runtime.h"
2828
#include "py/mphal.h"
29+
#include "py/gc.h"
2930
#include "shared-module/gamepad/GamePad.h"
3031
#include "shared-bindings/digitalio/DigitalInOut.h"
3132
#include "shared-bindings/util.h"
@@ -108,6 +109,7 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
108109
if (!gamepad_singleton) {
109110
gamepad_singleton = m_new_obj(gamepad_obj_t);
110111
gamepad_singleton->base.type = &gamepad_type;
112+
gamepad_singleton = gc_make_long_lived(gamepad_singleton);
111113
}
112114
gamepad_init(n_args, args);
113115
return MP_OBJ_FROM_PTR(gamepad_singleton);

0 commit comments

Comments
 (0)