Skip to content

Multiple fixes in gamepad#864

Merged
dhalbert merged 5 commits into
adafruit:masterfrom
pypewpew:master
May 23, 2018
Merged

Multiple fixes in gamepad#864
dhalbert merged 5 commits into
adafruit:masterfrom
pypewpew:master

Conversation

@deshipu
Copy link
Copy Markdown

@deshipu deshipu commented May 23, 2018

Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.

deshipu added 2 commits May 23, 2018 11:26
Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.
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.
@tannewt tannewt requested a review from dhalbert May 23, 2018 18:00
Copy link
Copy Markdown
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice you made gamepad_singleton volatile, but I'm not sure why you did that.

There's an issue in gamepad_make_new. It's in code that hasn't changed so I can't add a line comment. The issue is that you set gamepad_singleton early. But there are two possible exceptions that occur after that: if one of the args is not a DIgitalInOut, or later, gamepad_init() can also throw an exception if one of the pins is deinited. So in either case you'll be left with a broken singleton. So don't set the singleton until it's completely successfully init'ed.

I'm not sure if this has to do with the problem you mentioned in discord.

@dhalbert
Copy link
Copy Markdown
Collaborator

Also, use mp_raise... in preference to nlr_raise....

deshipu added 2 commits May 23, 2018 21:39
Raise exceptions before the gamepad_singleton is created.
Also, use mp_raise for creating the exceptions.
@deshipu
Copy link
Copy Markdown
Author

deshipu commented May 23, 2018

Thanks. I also added an error when more than 8 buttons are passed — before it would be a memory overflow.

@deshipu deshipu changed the title Cache pullup state in gamepad Multiple fixes in gamepad May 23, 2018
Copy link
Copy Markdown
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, great!

@dhalbert dhalbert merged commit ff592ac into adafruit:master May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants