Skip to content

CursorManager: Add support for Start and Select buttons for PyGamer. #33

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 4 commits into from
Feb 27, 2022

Conversation

flom84
Copy link
Contributor

@flom84 flom84 commented Feb 26, 2022

Hi

I have been using CursorControl with PyGamer for a personal projects and being quite fond of this library. Unfortunately, there is no support for PyGamer's Select and Start buttons . This change makes it possible to check if either Select or Start button have been pressed. Implementation is similar to how buttons A or B states are handled.

I hope that this pull request would be useful for others as well.

@ladyada ladyada requested a review from FoamyGuy February 27, 2022 02:18
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @flom84. I tested start and select buttons successfully on PyGamer and the functionality of it looks good to me.

I think we should add the values in the dictionary for pybadge devices as well here:

self._pad_btns = {
"btn_left": PYBADGE_BUTTON_LEFT,
"btn_right": PYBADGE_BUTTON_RIGHT,
"btn_up": PYBADGE_BUTTON_UP,
"btn_down": PYBADGE_BUTTON_DOWN,
"btn_a": PYBADGE_BUTTON_A,
"btn_b": PYBADGE_BUTTON_B,
}

self._pad_btns = {
    "btn_left": PYBADGE_BUTTON_LEFT,
    "btn_right": PYBADGE_BUTTON_RIGHT,
    "btn_up": PYBADGE_BUTTON_UP,
    "btn_down": PYBADGE_BUTTON_DOWN,
    "btn_a": PYBADGE_BUTTON_A,
    "btn_b": PYBADGE_BUTTON_B,
+  "btn_select": PYBADGE_BUTTON_SELECT,
+  "btn_start": PYBADGE_BUTTON_START,
}

Without these the update() function ends up raising this error:

Traceback (most recent call last):
  File "code.py", line 23, in <module>
  File "/lib/adafruit_cursorcontrol/cursorcontrol_cursormanager.py", line 166, in update
KeyError: btn_select

@flom84
Copy link
Contributor Author

flom84 commented Feb 27, 2022

@FoamyGuy thank you for reviewing my code. I would add another commit with the changes requested.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Thank you!

These changes look good to me. Tested successfully on pygamer and pybadge

@FoamyGuy FoamyGuy merged commit 5730d0c into adafruit:main Feb 27, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 28, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_CursorControl to 2.6.0 from 2.5.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_CursorControl#33 from flom84/pygamer-start-select-buttons-support
  > Fixed readthedocs build
  > Consolidate Documentation sections of README
@flom84 flom84 deleted the pygamer-start-select-buttons-support branch March 4, 2022 18:08
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