Skip to content

Commit 5e265f4

Browse files
deshiputannewt
authored andcommitted
When clearing gamepad buffer, use the last button state, not 0
When reading the accumulated button presses in gamepad and gamepadshift, don't clear the buffer to "no buttons pressed", but instead set it to the current (last checked) state. This clears the accumulated presses, but retains any ongoing ones. This fixes #1935
1 parent 036e7a3 commit 5e265f4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

shared-bindings/gamepad/GamePad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
127127
STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) {
128128
gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton);
129129
mp_obj_t pressed = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed);
130-
gamepad_singleton->pressed = 0;
130+
gamepad_singleton->pressed = gamepad_singleton->last;
131131
return pressed;
132132
}
133133
MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);

shared-bindings/gamepadshift/GamePadShift.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args,
9494
STATIC mp_obj_t gamepadshift_get_pressed(mp_obj_t self_in) {
9595
gamepadshift_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton);
9696
mp_obj_t pressed = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed);
97-
gamepad_singleton->pressed = 0;
97+
gamepad_singleton->pressed = gamepad_singleton->last;
9898
return pressed;
9999
}
100100
MP_DEFINE_CONST_FUN_OBJ_1(gamepadshift_get_pressed_obj, gamepadshift_get_pressed);

0 commit comments

Comments
 (0)