summaryrefslogtreecommitdiff
path: root/shared-bindings/gamepad/GamePad.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-05-15 10:31:05 -0700
committerGitHub <noreply@github.com>2020-05-15 10:31:05 -0700
commit0d8bca92e208e705150097d26db6a5390dc9eb9b (patch)
tree122acb729c3e0e629642bc39f7f2ee9db3fc084a /shared-bindings/gamepad/GamePad.c
parentbd78ab3c2812f7772021be7863f89a9650589d80 (diff)
parent8ac3e7977f87219454dbab50264a723e797b877a (diff)
Merge pull request #2810 from dherrada/master
Pyi integration
Diffstat (limited to 'shared-bindings/gamepad/GamePad.c')
-rw-r--r--shared-bindings/gamepad/GamePad.c109
1 files changed, 53 insertions, 56 deletions
diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c
index d6f91c1c0..9a23344b3 100644
--- a/shared-bindings/gamepad/GamePad.c
+++ b/shared-bindings/gamepad/GamePad.c
@@ -35,65 +35,62 @@
#include "supervisor/shared/translate.h"
#include "supervisor/shared/tick.h"
-
-//| .. currentmodule:: gamepad
-//|
-//| :class:`GamePad` -- Scan buttons for presses
-//| ============================================
+//| class GamePad:
+//| """Scan buttons for presses
//|
-//| Usage::
+//| Usage::
//|
-//| import board
-//| import digitalio
-//| import gamepad
-//| import time
+//| import board
+//| import digitalio
+//| import gamepad
+//| import time
//|
-//| B_UP = 1 << 0
-//| B_DOWN = 1 << 1
+//| B_UP = 1 << 0
+//| B_DOWN = 1 << 1
//|
//|
-//| pad = gamepad.GamePad(
-//| digitalio.DigitalInOut(board.D10),
-//| digitalio.DigitalInOut(board.D11),
-//| )
+//| pad = gamepad.GamePad(
+//| digitalio.DigitalInOut(board.D10),
+//| digitalio.DigitalInOut(board.D11),
+//| )
//|
-//| y = 0
-//| while True:
-//| buttons = pad.get_pressed()
-//| if buttons & B_UP:
-//| y -= 1
-//| print(y)
-//| elif buttons & B_DOWN:
-//| y += 1
-//| print(y)
-//| time.sleep(0.1)
-//| while buttons:
-//| # Wait for all buttons to be released.
+//| y = 0
+//| while True:
//| buttons = pad.get_pressed()
+//| if buttons & B_UP:
+//| y -= 1
+//| print(y)
+//| elif buttons & B_DOWN:
+//| y += 1
+//| print(y)
//| time.sleep(0.1)
+//| while buttons:
+//| # Wait for all buttons to be released.
+//| buttons = pad.get_pressed()
+//| time.sleep(0.1)"""
//|
-//| .. class:: GamePad([b1[, b2[, b3[, b4[, b5[, b6[, b7[, b8]]]]]]]])
-//|
-//| Initializes button scanning routines.
-//|
-//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which
-//| immediately get switched to input with a pull-up, (unless they already
-//| were set to pull-down, in which case they remain so), and then scanned
-//| regularly for button presses. The order is the same as the order of
-//| bits returned by the ``get_pressed`` function. You can re-initialize
-//| it with different keys, then the new object will replace the previous
-//| one.
-//|
-//| The basic feature required here is the ability to poll the keys at
-//| regular intervals (so that de-bouncing is consistent) and fast enough
-//| (so that we don't miss short button presses) while at the same time
-//| letting the user code run normally, call blocking functions and wait
-//| on delays.
-//|
-//| They button presses are accumulated, until the ``get_pressed`` method
-//| is called, at which point the button state is cleared, and the new
-//| button presses start to be recorded.
+//| def __init__(self, b1: Any, b2: Any, b3: Any, b4: Any, b5: Any, b6: Any, b7: Any, b8: Any):
+//| """Initializes button scanning routines.
+//|
+//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which
+//| immediately get switched to input with a pull-up, (unless they already
+//| were set to pull-down, in which case they remain so), and then scanned
+//| regularly for button presses. The order is the same as the order of
+//| bits returned by the ``get_pressed`` function. You can re-initialize
+//| it with different keys, then the new object will replace the previous
+//| one.
+//|
+//| The basic feature required here is the ability to poll the keys at
+//| regular intervals (so that de-bouncing is consistent) and fast enough
+//| (so that we don't miss short button presses) while at the same time
+//| letting the user code run normally, call blocking functions and wait
+//| on delays.
+//|
+//| They button presses are accumulated, until the ``get_pressed`` method
+//| is called, at which point the button state is cleared, and the new
+//| button presses start to be recorded."""
+//| ...
//|
STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
const mp_obj_t *args, mp_map_t *kw_args) {
@@ -117,15 +114,15 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(gamepad_singleton);
}
-//| .. method:: get_pressed()
-//|
-//| Get the status of buttons pressed since the last call and clear it.
+//| def get_pressed(self, ) -> Any:
+//| """Get the status of buttons pressed since the last call and clear it.
//|
//| Returns an 8-bit number, with bits that correspond to buttons,
//| which have been pressed (or held down) since the last call to this
//| function set to 1, and the remaining bits set to 0. Then it clears
//| the button state, so that new button presses (or buttons that are
-//| 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) {
gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton);
@@ -136,9 +133,9 @@ STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);
-//| .. method:: deinit()
-//|
-//| Disable button scanning.
+//| def deinit(self, ) -> Any:
+//| """Disable button scanning."""
+//| ...
//|
STATIC mp_obj_t gamepad_deinit(mp_obj_t self_in) {
common_hal_gamepad_gamepad_deinit(self_in);