2828#include "py/mphal.h"
2929#include "py/gc.h"
3030#include "py/mpstate.h"
31- #include "shared-module/gamepad/__init__.h"
32- #include "shared-module/gamepad/GamePadShift.h"
31+ #include "shared-bindings/gamepad/__init__.h"
32+ #include "shared-bindings/gamepadshift/GamePadShift.h"
33+ #include "shared-bindings/gamepadshift/__init__.h"
34+ #include "shared-module/gamepadshift/GamePadShift.h"
3335#include "supervisor/shared/translate.h"
34- #include "GamePadShift.h"
35- #include "__init__.h"
3636
37- //| .. currentmodule:: gamepad
37+ //| .. currentmodule:: gamepadshift
3838//|
39- //| :class:`GamePadShift` -- Scan buttons for presses
40- //| =================================================
39+ //| :class:`GamePadShift` -- Scan buttons for presses through a shift register
40+ //| ===========================================================================
4141//|
4242//| .. class:: GamePadShift(data, clock, latch)
4343//|
5050//| is called, at which point the button state is cleared, and the new
5151//| button presses start to be recorded.
5252//|
53+ //| Only one gamepad (`gamepad.GamePad` or `gamepadshift.GamePadShift`)
54+ //| may be used at a time.
55+ //|
5356STATIC mp_obj_t gamepadshift_make_new (const mp_obj_type_t * type , size_t n_args ,
5457 const mp_obj_t * pos_args , mp_map_t * kw_args ) {
5558
@@ -63,9 +66,9 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args,
6366 mp_arg_parse_all (n_args , pos_args , kw_args , MP_ARRAY_SIZE (allowed_args ),
6467 allowed_args , args );
6568
66- digitalio_digitalinout_obj_t * data_pin = pin_io (args [ARG_data ].u_obj );
67- digitalio_digitalinout_obj_t * clock_pin = pin_io (args [ARG_clock ].u_obj );
68- digitalio_digitalinout_obj_t * latch_pin = pin_io (args [ARG_latch ].u_obj );
69+ digitalio_digitalinout_obj_t * data_pin = assert_digitalinout (args [ARG_data ].u_obj );
70+ digitalio_digitalinout_obj_t * clock_pin = assert_digitalinout (args [ARG_clock ].u_obj );
71+ digitalio_digitalinout_obj_t * latch_pin = assert_digitalinout (args [ARG_latch ].u_obj );
6972
7073 gamepadshift_obj_t * gamepad_singleton = MP_STATE_VM (gamepad_singleton );
7174 if (!gamepad_singleton ||
@@ -76,7 +79,7 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args,
7679 gamepad_singleton = gc_make_long_lived (gamepad_singleton );
7780 MP_STATE_VM (gamepad_singleton ) = gamepad_singleton ;
7881 }
79- gamepadshift_init (gamepad_singleton , data_pin , clock_pin , latch_pin );
82+ common_hal_gamepadshift_gamepadshift_init (gamepad_singleton , data_pin , clock_pin , latch_pin );
8083 return MP_OBJ_FROM_PTR (gamepad_singleton );
8184}
8285
@@ -103,7 +106,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(gamepadshift_get_pressed_obj, gamepadshift_get_pressed
103106//| Disable button scanning.
104107//|
105108STATIC mp_obj_t gamepadshift_deinit (mp_obj_t self_in ) {
106- gamepad_reset ( );
109+ common_hal_gamepadshift_gamepadshift_deinit ( self_in );
107110 return mp_const_none ;
108111}
109112MP_DEFINE_CONST_FUN_OBJ_1 (gamepadshift_deinit_obj , gamepadshift_deinit );
0 commit comments