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.
This commit is contained in:
parent
52d05bbc37
commit
edf2935ab1
@ -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.
|
//| held down) can be recorded for the next call.
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) {
|
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(gamepad_singleton->pressed);
|
||||||
mp_obj_t gamepad = MP_OBJ_NEW_SMALL_INT(self->pressed);
|
gamepad_singleton->pressed = 0;
|
||||||
self->pressed = 0;
|
|
||||||
return gamepad;
|
return gamepad;
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);
|
MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);
|
||||||
|
Loading…
Reference in New Issue
Block a user