Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add simulated directional buttons for PyGamer #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions adafruit_pybadger.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,24 @@ def button(self):
print("Button select")

"""
#pylint: disable=no-else-return
button_values = self._buttons.get_pressed()
return Buttons(*[button_values & button for button in
(PyBadger.BUTTON_B, PyBadger.BUTTON_A, PyBadger.BUTTON_START,
PyBadger.BUTTON_SELECT, PyBadger.BUTTON_RIGHT,
PyBadger.BUTTON_DOWN, PyBadger.BUTTON_UP, PyBadger.BUTTON_LEFT)])
if hasattr(board, "JOYSTICK_X"):
x, y = self.joystick
return Buttons(button_values & PyBadger.BUTTON_B,
button_values & PyBadger.BUTTON_A,
button_values & PyBadger.BUTTON_START,
button_values & PyBadger.BUTTON_SELECT,
x > 50000, # RIGHT
y > 50000, # DOWN
y < 15000, # UP
x < 15000 # LEFT
)
else:
return Buttons(*[button_values & button for button in
(PyBadger.BUTTON_B, PyBadger.BUTTON_A, PyBadger.BUTTON_START,
PyBadger.BUTTON_SELECT, PyBadger.BUTTON_RIGHT,
PyBadger.BUTTON_DOWN, PyBadger.BUTTON_UP, PyBadger.BUTTON_LEFT)])

@property
def light(self):
Expand Down