diff --git a/docs/porting.rst b/docs/porting.rst index 8d0262455b..013c367291 100644 --- a/docs/porting.rst +++ b/docs/porting.rst @@ -80,7 +80,7 @@ as a natural "TODO" list. An example minimal build list is shown below: # Requires DigitalIO: CIRCUITPY_BITBANGIO = 0 # Requires DigitalIO - CIRCUITPY_GAMEPAD = 0 + CIRCUITPY_GAMEPADSHIFT = 0 # Requires neopixel_write or SPI (dotstar) CIRCUITPY_PIXELBUF = 0 # Requires OS diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index 68b7e580fe..e0fecb6c73 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit 68b7e580fe7d162d686f92301ab3937907dcaafe +Subproject commit e0fecb6c73f11c31cfc2a9c0e9ce9805b8fb1cf1 diff --git a/frozen/Adafruit_CircuitPython_Requests b/frozen/Adafruit_CircuitPython_Requests index c55425e178..03f54421a0 160000 --- a/frozen/Adafruit_CircuitPython_Requests +++ b/frozen/Adafruit_CircuitPython_Requests @@ -1 +1 @@ -Subproject commit c55425e17842cce3ec0b34489133436c3e1a3898 +Subproject commit 03f54421a050bbfda71e1c98986ddecc3862431a diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index 200eea0630..cac4b8e0bb 100644 --- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk +++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk @@ -12,8 +12,8 @@ EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_GAMEPAD = 1 CIRCUITPY_BUSDEVICE = 1 +CIRCUITPY_KEYPAD = 1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index d7230df4bb..6017b551f1 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -12,6 +12,7 @@ LONGINT_IMPL = NONE # To keep the build small CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_KEYPAD = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 7990f91ccc..2a4d58f134 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -10,37 +10,36 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUIPTY_USB_CDC = 0 CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_AUDIOMP3 = 0 +CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BITBANG_APA102 = 0 CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPADSHIFT = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PS2IO = 0 CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_SAMD = 0 CIRCUITPY_TOUCHIO = 0 -CIRCUIPTY_USB_CDC = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_VECTORIO = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_PWMIO = 0 CIRCUITPY_ANALOGIO = 1 -CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_SYNTHIO = 1 +CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_DISPLAYIO = 1 +CIRCUITPY_KEYPAD = 1 CIRCUITPY_MATH = 1 CIRCUITPY_STAGE = 1 -CIRCUITPY_KEYPAD = 1 +CIRCUITPY_SYNTHIO = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pewpew_m4 CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index 54f00b7448..3043adc2ad 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -10,7 +10,6 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk index bbed46dbed..3eda028754 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -16,8 +16,8 @@ CIRCUITPY_DRIVE_LABEL = "PYCUBED" CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_KEYPAD = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_KEYPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 5cef7b44cf..df504f2e98 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -10,7 +10,6 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ -CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index 2f1062e419..225b37fb20 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -14,8 +14,8 @@ CIRCUITPY_STAGE = 1 CIRCUITPY_MATH = 1 CIRCUITPY_AUDIOIO = 1 CIRCUITPY_ANALOGIO = 1 -CIRCUITPY_GAMEPAD = 1 CIRCUITPY_DISPLAYIO = 1 +CIRCUITPY_KEYPPAD = 1 CIRCUITPY_PULSEIO = 0 CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk index 7364de0cfe..5bf70a9668 100644 --- a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk @@ -22,6 +22,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_BLEIO = 0 CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_KEYPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_RGBMATRIX = 0 diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk index bc4fff5018..653d2e6ed5 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk +++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk @@ -21,6 +21,7 @@ CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_KEYPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_RGBMATRIX = 0 diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 0ba6019e07..c03b79ce4f 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -85,9 +85,6 @@ #include "tusb.h" -#if CIRCUITPY_GAMEPAD -#include "shared-module/gamepad/__init__.h" -#endif #if CIRCUITPY_GAMEPADSHIFT #include "shared-module/gamepadshift/__init__.h" #endif @@ -358,9 +355,6 @@ void reset_port(void) { reset_gclks(); - #if CIRCUITPY_GAMEPAD - gamepad_reset(); - #endif #if CIRCUITPY_GAMEPADSHIFT gamepadshift_reset(); #endif diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index edc8e6ddf5..865c170aaa 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -17,9 +17,9 @@ CIRCUITPY_CAMERA = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 CIRCUITPY_GNSS = 1 CIRCUITPY_I2CPERIPHERAL = 0 +CIRCUITPY_KEYPAD = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_ROTARYIO = 0 diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 2493252d78..cb79974359 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -47,9 +47,6 @@ #include "tusb.h" -#if CIRCUITPY_GAMEPAD -#include "shared-module/gamepad/__init__.h" -#endif #if CIRCUITPY_GAMEPADSHIFT #include "shared-module/gamepadshift/__init__.h" #endif @@ -300,9 +297,6 @@ void reset_port(void) { rtc_reset(); #endif - #if CIRCUITPY_GAMEPAD - gamepad_reset(); - #endif #if CIRCUITPY_GAMEPADSHIFT gamepadshift_reset(); #endif diff --git a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk index 30946057c9..2b46f4397a 100644 --- a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk +++ b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk @@ -8,5 +8,4 @@ MCU_CHIP = nrf52840 INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_DISPLAYIO = 1 -CIRCUITPY_GAMEPAD = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/nrf/boards/pca10056/examples/buttons.py b/ports/nrf/boards/pca10056/examples/buttons.py deleted file mode 100644 index 4db3576970..0000000000 --- a/ports/nrf/boards/pca10056/examples/buttons.py +++ /dev/null @@ -1,26 +0,0 @@ -import board -import digitalio -import gamepad -import time - -pad = gamepad.GamePad( - digitalio.DigitalInOut(board.P0_11), - digitalio.DigitalInOut(board.P0_12), - digitalio.DigitalInOut(board.P0_24), - digitalio.DigitalInOut(board.P0_25), -) - -prev_buttons = 0 - -while True: - buttons = pad.get_pressed() - - if buttons != prev_buttons: - for i in range(0, 4): - bit = 1 << i - if (buttons & bit) != (prev_buttons & bit): - print("Button %d %s" % (i + 1, "pressed" if buttons & bit else "released")) - - prev_buttons = buttons - - time.sleep(0.1) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index e984c3f326..66b4bc9181 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -39,7 +39,6 @@ #include "nrf/power.h" #include "nrf/timers.h" -#include "shared-module/gamepad/__init__.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/_bleio/__init__.h" #include "common-hal/analogio/AnalogIn.h" @@ -207,10 +206,6 @@ safe_mode_t port_init(void) { } void reset_port(void) { - #ifdef CIRCUITPY_GAMEPAD_TICKS - gamepad_reset(); - #endif - #if CIRCUITPY_BUSIO i2c_reset(); spi_reset(); diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 495f5fd10a..5bf46039a7 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -184,9 +184,7 @@ endif ifeq ($(CIRCUITPY_FREQUENCYIO),1) SRC_PATTERNS += frequencyio/% endif -ifeq ($(CIRCUITPY_GAMEPAD),1) -SRC_PATTERNS += gamepad/% -endif + ifeq ($(CIRCUITPY_GAMEPADSHIFT),1) SRC_PATTERNS += gamepadshift/% endif @@ -523,8 +521,6 @@ SRC_SHARED_MODULE_ALL = \ keypad/Keys.c \ sdcardio/SDCard.c \ sdcardio/__init__.c \ - gamepad/GamePad.c \ - gamepad/__init__.c \ gamepadshift/GamePadShift.c \ gamepadshift/__init__.c \ memorymonitor/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index fa55185d75..8e31f0411b 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -468,13 +468,6 @@ extern const struct _mp_obj_module_t frequencyio_module; #define FREQUENCYIO_MODULE #endif -#if CIRCUITPY_GAMEPAD -extern const struct _mp_obj_module_t gamepad_module; -#define GAMEPAD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module }, -#else -#define GAMEPAD_MODULE -#endif - #if CIRCUITPY_GAMEPADSHIFT extern const struct _mp_obj_module_t gamepadshift_module; #define GAMEPADSHIFT_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_gamepadshift),(mp_obj_t)&gamepadshift_module }, @@ -482,7 +475,7 @@ extern const struct _mp_obj_module_t gamepadshift_module; #define GAMEPADSHIFT_MODULE #endif -#if CIRCUITPY_GAMEPAD || CIRCUITPY_GAMEPADSHIFT +#if CIRCUITPY_GAMEPADSHIFT // Scan gamepad every 32ms #define CIRCUITPY_GAMEPAD_TICKS 0x1f #define GAMEPAD_ROOT_POINTERS mp_obj_t gamepad_singleton; @@ -539,8 +532,8 @@ extern const struct _mp_obj_module_t keypad_module; #define KEYPAD_ROOT_POINTERS #endif -#if CIRCUITPY_GAMEPAD || CIRCUITPY_GAMEPADSHIFT -// Scan gamepad every 32ms +#if CIRCUITPY_GAMEPADSHIFT +// Scan gamepadshift every 32ms #define CIRCUITPY_GAMEPAD_TICKS 0x1f #define GAMEPAD_ROOT_POINTERS mp_obj_t gamepad_singleton; #else @@ -888,7 +881,6 @@ extern const struct _mp_obj_module_t msgpack_module; _EVE_MODULE \ FRAMEBUFFERIO_MODULE \ FREQUENCYIO_MODULE \ - GAMEPAD_MODULE \ GAMEPADSHIFT_MODULE \ GNSS_MODULE \ I2CPERIPHERAL_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 42ff9e391b..3d72be7491 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -181,9 +181,6 @@ CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE) CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO) -CIRCUITPY_GAMEPAD ?= 0 -CFLAGS += -DCIRCUITPY_GAMEPAD=$(CIRCUITPY_GAMEPAD) - CIRCUITPY_GAMEPADSHIFT ?= 0 CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c deleted file mode 100644 index 0776839939..0000000000 --- a/shared-bindings/gamepad/GamePad.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include "shared-bindings/gamepad/GamePad.h" - -#include "py/obj.h" -#include "py/runtime.h" -#include "py/mphal.h" -#include "py/gc.h" -#include "py/mpstate.h" -#include "shared-bindings/gamepad/__init__.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" -#include "supervisor/shared/tick.h" - -//| class GamePad: -//| """Scan buttons for presses -//| -//| Usage:: -//| -//| import board -//| import digitalio -//| import gamepad -//| import time -//| -//| B_UP = 1 << 0 -//| B_DOWN = 1 << 1 -//| -//| -//| 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. -//| buttons = pad.get_pressed() -//| time.sleep(0.1)""" -//| -//| def __init__( -//| self, -//| b1: digitalio.DigitalInOut, -//| b2: digitalio.DigitalInOut, -//| b3: digitalio.DigitalInOut, -//| b4: digitalio.DigitalInOut, -//| b5: digitalio.DigitalInOut, -//| b6: digitalio.DigitalInOut, -//| b7: digitalio.DigitalInOut, -//| b8: digitalio.DigitalInOut, -//| ) -> None: -//| """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) { - if (n_args > 8 || n_args == 0) { - mp_raise_TypeError(translate("argument num/types mismatch")); - } - for (size_t i = 0; i < n_args; ++i) { - assert_digitalinout(args[i]); - } - gamepad_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); - if (!gamepad_singleton || - !mp_obj_is_type(MP_OBJ_FROM_PTR(gamepad_singleton), &gamepad_type)) { - gamepad_singleton = m_new_ll_obj(gamepad_obj_t); - gamepad_singleton->base.type = &gamepad_type; - if (!MP_STATE_VM(gamepad_singleton)) { - supervisor_enable_tick(); - } - MP_STATE_VM(gamepad_singleton) = gamepad_singleton; - } - common_hal_gamepad_gamepad_init(gamepad_singleton, args, n_args); - return MP_OBJ_FROM_PTR(gamepad_singleton); -} - -//| def get_pressed(self) -> int: -//| """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.""" -//| ... -//| -STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) { - gamepad_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); - mp_obj_t pressed = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed); - gamepad_singleton->pressed = gamepad_singleton->last; - return pressed; -} -MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed); - - -//| def deinit(self) -> None: -//| """Disable button scanning.""" -//| ... -//| -STATIC mp_obj_t gamepad_deinit(mp_obj_t self_in) { - common_hal_gamepad_gamepad_deinit(self_in); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(gamepad_deinit_obj, gamepad_deinit); - - -STATIC const mp_rom_map_elem_t gamepad_locals_dict_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR_get_pressed), MP_ROM_PTR(&gamepad_get_pressed_obj)}, - { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gamepad_deinit_obj)}, -}; -STATIC MP_DEFINE_CONST_DICT(gamepad_locals_dict, gamepad_locals_dict_table); -const mp_obj_type_t gamepad_type = { - { &mp_type_type }, - .name = MP_QSTR_GamePad, - .make_new = gamepad_make_new, - .locals_dict = (mp_obj_dict_t *)&gamepad_locals_dict, -}; diff --git a/shared-bindings/gamepad/GamePad.h b/shared-bindings/gamepad/GamePad.h deleted file mode 100644 index 3bbad4c97b..0000000000 --- a/shared-bindings/gamepad/GamePad.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD_GAMEPAD_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD_GAMEPAD_H - -#include "shared-module/gamepad/GamePad.h" - -extern const mp_obj_type_t gamepad_type; - -void common_hal_gamepad_gamepad_init(gamepad_obj_t *gamepad, const mp_obj_t pins[], size_t n_pins); -void common_hal_gamepad_gamepad_deinit(gamepad_obj_t *gamepad); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD_GAMEPAD_H diff --git a/shared-bindings/gamepad/__init__.c b/shared-bindings/gamepad/__init__.c deleted file mode 100644 index 273f109bf5..0000000000 --- a/shared-bindings/gamepad/__init__.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include "py/obj.h" -#include "py/runtime.h" -#include "py/mphal.h" -#include "shared-bindings/gamepad/GamePad.h" -#include "shared-bindings/util.h" - -//| """Button handling in the background""" -//| -STATIC const mp_rom_map_elem_t gamepad_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepad) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_GamePad), MP_ROM_PTR(&gamepad_type)}, -}; -STATIC MP_DEFINE_CONST_DICT(gamepad_module_globals, - gamepad_module_globals_table); - -const mp_obj_module_t gamepad_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&gamepad_module_globals, -}; diff --git a/shared-bindings/gamepad/__init__.h b/shared-bindings/gamepad/__init__.h deleted file mode 100644 index 2ae5efb3a0..0000000000 --- a/shared-bindings/gamepad/__init__.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD___INIT___H - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPAD___INIT___H diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index aba699b23f..a232683c96 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -46,8 +46,7 @@ //| is called, at which point the button state is cleared, and the new //| button presses start to be recorded. //| -//| Only one gamepad (`gamepad.GamePad` or `gamepadshift.GamePadShift`) -//| may be used at a time.""" +//| Only one `gamepadshift.GamePadShift` may be used at a time.""" //| ... //| STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, diff --git a/shared-bindings/gamepadshift/__init__.c b/shared-bindings/gamepadshift/__init__.c index 1b25d342a7..3c9c4ce8b2 100644 --- a/shared-bindings/gamepadshift/__init__.c +++ b/shared-bindings/gamepadshift/__init__.c @@ -30,7 +30,11 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" -//| """Tracks button presses read through a shift register""" +//| """Tracks button presses read through a shift register. +//| +//| .. note:: `gamepadshift` is deprecated in CircuitPython 7.0.0 and will be removed in 8.0.0. +//| Use `keypad` instead. +//| """ //| STATIC const mp_rom_map_elem_t gamepadshift_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepadshift) }, diff --git a/shared-module/gamepad/GamePad.c b/shared-module/gamepad/GamePad.c deleted file mode 100644 index 55b447f1eb..0000000000 --- a/shared-module/gamepad/GamePad.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "py/mpstate.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/gamepad/GamePad.h" -#include "supervisor/shared/tick.h" - -void common_hal_gamepad_gamepad_init(gamepad_obj_t *gamepad, - const mp_obj_t pins[], size_t n_pins) { - for (size_t i = 0; i < 8; ++i) { - gamepad->pins[i] = NULL; - } - gamepad->pulls = 0; - for (size_t i = 0; i < n_pins; ++i) { - digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(pins[i]); - if (common_hal_digitalio_digitalinout_get_direction(pin) != - DIRECTION_INPUT) { - common_hal_digitalio_digitalinout_switch_to_input(pin, PULL_UP); - } - digitalio_pull_t pull = common_hal_digitalio_digitalinout_get_pull(pin); - if (pull == PULL_NONE) { - common_hal_digitalio_digitalinout_set_pull(pin, PULL_UP); - } - if (pull != PULL_DOWN) { - gamepad->pulls |= 1 << i; - } - gamepad->pins[i] = pin; - } - gamepad->last = 0; -} - -void common_hal_gamepad_gamepad_deinit(gamepad_obj_t *self) { - MP_STATE_VM(gamepad_singleton) = NULL; - supervisor_disable_tick(); -} diff --git a/shared-module/gamepad/GamePad.h b/shared-module/gamepad/GamePad.h deleted file mode 100644 index 7c28e2285b..0000000000 --- a/shared-module/gamepad/GamePad.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_GAMEPAD_GAMEPAD_H -#define MICROPY_INCLUDED_GAMEPAD_GAMEPAD_H - -#include - -#include "shared-bindings/digitalio/DigitalInOut.h" - -typedef struct { - mp_obj_base_t base; - digitalio_digitalinout_obj_t *pins[8]; - volatile uint8_t last; - volatile uint8_t pressed; - uint8_t pulls; -} gamepad_obj_t; - -#endif // MICROPY_INCLUDED_GAMEPAD_GAMEPAD_H diff --git a/shared-module/gamepad/__init__.c b/shared-module/gamepad/__init__.c deleted file mode 100644 index 50e3edd9cf..0000000000 --- a/shared-module/gamepad/__init__.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Radomir Dopieralski for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include "py/mpstate.h" -#include "shared-bindings/gamepad/__init__.h" -#include "shared-bindings/gamepad/GamePad.h" -#include "supervisor/shared/tick.h" - -#include "shared-bindings/digitalio/DigitalInOut.h" - - -void gamepad_tick(void) { - uint8_t current = 0; - uint8_t bit = 1; - - void *singleton = MP_STATE_VM(gamepad_singleton); - if (singleton == NULL || !mp_obj_is_type(MP_OBJ_FROM_PTR(singleton), &gamepad_type)) { - return; - } - - gamepad_obj_t *self = MP_OBJ_TO_PTR(singleton); - for (int i = 0; i < 8; ++i) { - digitalio_digitalinout_obj_t *pin = self->pins[i]; - if (!pin) { - break; - } - if (common_hal_digitalio_digitalinout_get_value(pin)) { - current |= bit; - } - bit <<= 1; - } - current ^= self->pulls; - self->pressed |= self->last & current; - self->last = current; -} - -void gamepad_reset(void) { - if (MP_STATE_VM(gamepad_singleton)) { - supervisor_disable_tick(); - } - MP_STATE_VM(gamepad_singleton) = NULL; -} diff --git a/shared-module/gamepad/__init__.h b/shared-module/gamepad/__init__.h deleted file mode 100644 index 1fae570f98..0000000000 --- a/shared-module/gamepad/__init__.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_GAMEPAD_H -#define MICROPY_INCLUDED_GAMEPAD_H - -void gamepad_tick(void); -void gamepad_reset(void); - -#endif // MICROPY_INCLUDED_GAMEPAD_H diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index f755df2596..eac98215a1 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -40,10 +40,6 @@ #include "shared-module/displayio/__init__.h" #endif -#if CIRCUITPY_GAMEPAD -#include "shared-module/gamepad/__init__.h" -#endif - #if CIRCUITPY_GAMEPADSHIFT #include "shared-module/gamepadshift/__init__.h" #endif @@ -102,9 +98,6 @@ void supervisor_tick(void) { #ifdef CIRCUITPY_GAMEPAD_TICKS if (!(port_get_raw_ticks(NULL) & CIRCUITPY_GAMEPAD_TICKS)) { - #if CIRCUITPY_GAMEPAD - gamepad_tick(); - #endif #if CIRCUITPY_GAMEPADSHIFT gamepadshift_tick(); #endif