From edf2935ab166d3db765eec600ffccaedee79e5a5 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Wed, 23 May 2018 12:44:22 +0200 Subject: [PATCH] Make gamepad.get_pressed work when gamepad was created from frozen code For some reason, when the GamePad is created from frozen code, the get_pressed method would always return 0. This fixes it, and makes it work properly no matter how the object was created. --- shared-bindings/gamepad/GamePad.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 43efc3b186..2c982c7d55 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -119,9 +119,8 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, //| held down) can be recorded for the next call. //| STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) { - gamepad_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t gamepad = MP_OBJ_NEW_SMALL_INT(self->pressed); - self->pressed = 0; + mp_obj_t gamepad = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed); + gamepad_singleton->pressed = 0; return gamepad; } MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);