diff --git a/docs/porting.rst b/docs/porting.rst index 8d0262455be40..07a2b1e9c4045 100644 --- a/docs/porting.rst +++ b/docs/porting.rst @@ -79,8 +79,6 @@ as a natural "TODO" list. An example minimal build list is shown below: # any port once their prerequisites in common-hal are complete. # Requires DigitalIO: CIRCUITPY_BITBANGIO = 0 - # Requires DigitalIO - CIRCUITPY_GAMEPAD = 0 # Requires neopixel_write or SPI (dotstar) CIRCUITPY_PIXELBUF = 0 # Requires OS diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index 200eea0630e3f..cac4b8e0bbb90 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/openbook_m4/mpconfigboard.mk b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk index 85b2dd42053f6..949cb6795c1d1 100644 --- a/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ - -CIRCUITPY_GAMEPADSHIFT = 1 diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index 54f00b7448276..0024546f90bb8 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -10,8 +10,6 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_GAMEPAD = 1 -CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 5cef7b44cf94e..c34009f93b67a 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -10,8 +10,6 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ -CIRCUITPY_GAMEPAD = 1 -CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pygamer diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index 2f1062e4198a4..3a164a7a9c567 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_KEYPAD = 1 CIRCUITPY_PULSEIO = 0 CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index cb8fae6f079cf..d0ef189f41acb 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -50,7 +50,6 @@ CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 -CIRCUITPY_KEYPAD ?= 0 CIRCUITPY_MSGPACK ?= 0 CIRCUITPY_RE ?= 0 CIRCUITPY_SDCARDIO ?= 0 diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 0ba6019e071c8..c1fa870a5501e 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -85,12 +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 #if CIRCUITPY_PEW #include "common-hal/_pew/PewPew.h" #endif @@ -358,12 +352,6 @@ void reset_port(void) { reset_gclks(); - #if CIRCUITPY_GAMEPAD - gamepad_reset(); - #endif - #if CIRCUITPY_GAMEPADSHIFT - gamepadshift_reset(); - #endif #if CIRCUITPY_PEW pew_reset(); #endif diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index edc8e6ddf5c1c..580292c984348 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -17,7 +17,6 @@ CIRCUITPY_CAMERA = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 CIRCUITPY_GNSS = 1 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 2493252d78e9b..ea49dd651f60a 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -47,12 +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 #if CIRCUITPY_PEW #include "shared-module/_pew/PewPew.h" #endif @@ -300,12 +294,6 @@ void reset_port(void) { rtc_reset(); #endif - #if CIRCUITPY_GAMEPAD - gamepad_reset(); - #endif - #if CIRCUITPY_GAMEPADSHIFT - gamepadshift_reset(); - #endif #if CIRCUITPY_PEW pew_reset(); #endif diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index e984c3f3262ea..66b4bc91810ef 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 5b6cd66f9a132..deb6d42d876ee 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -184,12 +184,6 @@ 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 ifeq ($(CIRCUITPY_GNSS),1) SRC_PATTERNS += gnss/% endif diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index e63186a325e6e..78a1a2ef117aa 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -468,28 +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 }, -#else -#define GAMEPADSHIFT_MODULE -#endif - -#if CIRCUITPY_GAMEPAD || CIRCUITPY_GAMEPADSHIFT -// Scan gamepad every 32ms -#define CIRCUITPY_GAMEPAD_TICKS 0x1f -#define GAMEPAD_ROOT_POINTERS mp_obj_t gamepad_singleton; -#else -#define GAMEPAD_ROOT_POINTERS -#endif - #if CIRCUITPY_GNSS extern const struct _mp_obj_module_t gnss_module; #define GNSS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_gnss), (mp_obj_t)&gnss_module }, @@ -539,14 +517,6 @@ extern const struct _mp_obj_module_t keypad_module; #define KEYPAD_ROOT_POINTERS #endif -#if CIRCUITPY_GAMEPAD || CIRCUITPY_GAMEPADSHIFT -// Scan gamepad every 32ms -#define CIRCUITPY_GAMEPAD_TICKS 0x1f -#define GAMEPAD_ROOT_POINTERS mp_obj_t gamepad_singleton; -#else -#define GAMEPAD_ROOT_POINTERS -#endif - #if CIRCUITPY_MATH extern const struct _mp_obj_module_t math_module; #define MATH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, @@ -904,8 +874,6 @@ extern const struct _mp_obj_module_t msgpack_module; _EVE_MODULE \ FRAMEBUFFERIO_MODULE \ FREQUENCYIO_MODULE \ - GAMEPAD_MODULE \ - GAMEPADSHIFT_MODULE \ GNSS_MODULE \ I2CPERIPHERAL_MODULE \ IPADDRESS_MODULE \ @@ -979,7 +947,6 @@ struct _supervisor_allocation_node; const char *readline_hist[8]; \ vstr_t *repl_line; \ mp_obj_t rtc_time_source; \ - GAMEPAD_ROOT_POINTERS \ KEYPAD_ROOT_POINTERS \ mp_obj_t pew_singleton; \ BOARD_UART_ROOT_POINTER \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c1526438e8f90..4efd13e7030ac 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -181,12 +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) - CIRCUITPY_GNSS ?= 0 CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c deleted file mode 100644 index 07768399390d9..0000000000000 --- 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 3bbad4c97b325..0000000000000 --- 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 273f109bf5081..0000000000000 --- 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 2ae5efb3a0352..0000000000000 --- 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 deleted file mode 100644 index aba699b23fb43..0000000000000 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ /dev/null @@ -1,124 +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 "py/gc.h" -#include "py/mpstate.h" -#include "shared-bindings/gamepadshift/GamePadShift.h" -#include "shared-bindings/gamepadshift/__init__.h" -#include "supervisor/shared/translate.h" -#include "supervisor/shared/tick.h" - -//| class GamePadShift: -//| """Scan buttons for presses through a shift register""" -//| -//| def __init__(self, clock: digitalio.DigitalInOut, data: digitalio.DigitalInOut, latch: digitalio.DigitalInOut) -> None: -//| """Initializes button scanning routines. -//| -//| The ``clock``, ``data`` and ``latch`` parameters are ``DigitalInOut`` -//| objects connected to the shift register controlling the buttons. -//| -//| The 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. -//| -//| Only one gamepad (`gamepad.GamePad` or `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, - const mp_obj_t *pos_args, mp_map_t *kw_args) { - - enum { ARG_clock, ARG_data, ARG_latch }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ}, - { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_latch, MP_ARG_REQUIRED | MP_ARG_OBJ}, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), - allowed_args, args); - - digitalio_digitalinout_obj_t *clock_pin = assert_digitalinout(args[ARG_clock].u_obj); - digitalio_digitalinout_obj_t *data_pin = assert_digitalinout(args[ARG_data].u_obj); - digitalio_digitalinout_obj_t *latch_pin = assert_digitalinout(args[ARG_latch].u_obj); - - gamepadshift_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); - if (!gamepad_singleton || - !mp_obj_is_type(MP_OBJ_FROM_PTR(gamepad_singleton), - &gamepadshift_type)) { - gamepad_singleton = m_new_ll_obj(gamepadshift_obj_t); - gamepad_singleton->base.type = &gamepadshift_type; - if (!MP_STATE_VM(gamepad_singleton)) { - supervisor_enable_tick(); - } - MP_STATE_VM(gamepad_singleton) = gamepad_singleton; - } - common_hal_gamepadshift_gamepadshift_init(gamepad_singleton, clock_pin, data_pin, latch_pin); - 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 gamepadshift_get_pressed(mp_obj_t self_in) { - gamepadshift_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(gamepadshift_get_pressed_obj, gamepadshift_get_pressed); - -//| def deinit(self) -> None: -//| """Disable button scanning.""" -//| ... -//| -STATIC mp_obj_t gamepadshift_deinit(mp_obj_t self_in) { - common_hal_gamepadshift_gamepadshift_deinit(self_in); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(gamepadshift_deinit_obj, gamepadshift_deinit); - - -STATIC const mp_rom_map_elem_t gamepadshift_locals_dict_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR_get_pressed), MP_ROM_PTR(&gamepadshift_get_pressed_obj)}, - { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gamepadshift_deinit_obj)}, -}; -STATIC MP_DEFINE_CONST_DICT(gamepadshift_locals_dict, gamepadshift_locals_dict_table); -const mp_obj_type_t gamepadshift_type = { - { &mp_type_type }, - .name = MP_QSTR_GamePadShift, - .make_new = gamepadshift_make_new, - .locals_dict = (mp_obj_dict_t *)&gamepadshift_locals_dict, -}; diff --git a/shared-bindings/gamepadshift/GamePadShift.h b/shared-bindings/gamepadshift/GamePadShift.h deleted file mode 100644 index 8856e133acd41..0000000000000 --- a/shared-bindings/gamepadshift/GamePadShift.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_SHARED_BINDINGS_GAMEPADSHIFT_GAMEPADSHIFT_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPADSHIFT_GAMEPADSHIFT_H - -#include "shared-module/gamepadshift/GamePadShift.h" - -extern const mp_obj_type_t gamepadshift_type; - -void common_hal_gamepadshift_gamepadshift_init(gamepadshift_obj_t *gamepadshift, - digitalio_digitalinout_obj_t *clock_pin, - digitalio_digitalinout_obj_t *data_pin, - digitalio_digitalinout_obj_t *latch_pin); - -void common_hal_gamepadshift_gamepadshift_deinit(gamepadshift_obj_t *gamepadshift); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPADSHIFT_GAMEPADSHIFT_H diff --git a/shared-bindings/gamepadshift/__init__.c b/shared-bindings/gamepadshift/__init__.c deleted file mode 100644 index 1b25d342a7fbe..0000000000000 --- a/shared-bindings/gamepadshift/__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/gamepadshift/GamePadShift.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/util.h" - -//| """Tracks button presses read through a shift register""" -//| -STATIC const mp_rom_map_elem_t gamepadshift_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gamepadshift) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_GamePadShift), MP_ROM_PTR(&gamepadshift_type)}, -}; -STATIC MP_DEFINE_CONST_DICT(gamepadshift_module_globals, gamepadshift_module_globals_table); - -const mp_obj_module_t gamepadshift_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&gamepadshift_module_globals, -}; diff --git a/shared-bindings/gamepadshift/__init__.h b/shared-bindings/gamepadshift/__init__.h deleted file mode 100644 index 4b4be756a6533..0000000000000 --- a/shared-bindings/gamepadshift/__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_GAMEPADSHIFT___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPADSHIFT___INIT___H - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_GAMEPADSHIFT___INIT___H diff --git a/shared-module/gamepad/GamePad.c b/shared-module/gamepad/GamePad.c deleted file mode 100644 index 55b447f1eb9c2..0000000000000 --- 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 7c28e2285b6a7..0000000000000 --- 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 50e3edd9cf855..0000000000000 --- 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 1fae570f98e1e..0000000000000 --- 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/shared-module/gamepadshift/GamePadShift.c b/shared-module/gamepadshift/GamePadShift.c deleted file mode 100644 index 6efa0ea5cf097..0000000000000 --- a/shared-module/gamepadshift/GamePadShift.c +++ /dev/null @@ -1,51 +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-module/gamepadshift/GamePadShift.h" -#include "supervisor/shared/tick.h" - -void common_hal_gamepadshift_gamepadshift_init(gamepadshift_obj_t *gamepadshift, - digitalio_digitalinout_obj_t *clock_pin, - digitalio_digitalinout_obj_t *data_pin, - digitalio_digitalinout_obj_t *latch_pin) { - common_hal_digitalio_digitalinout_switch_to_input(data_pin, PULL_NONE); - gamepadshift->data_pin = data_pin; - common_hal_digitalio_digitalinout_switch_to_output(clock_pin, 0, - DRIVE_MODE_PUSH_PULL); - gamepadshift->clock_pin = clock_pin; - common_hal_digitalio_digitalinout_switch_to_output(latch_pin, 1, - DRIVE_MODE_PUSH_PULL); - gamepadshift->latch_pin = latch_pin; - - gamepadshift->last = 0; -} - -void common_hal_gamepadshift_gamepadshift_deinit(gamepadshift_obj_t *gamepadshift) { - MP_STATE_VM(gamepad_singleton) = NULL; - supervisor_disable_tick(); -} diff --git a/shared-module/gamepadshift/GamePadShift.h b/shared-module/gamepadshift/GamePadShift.h deleted file mode 100644 index 53aef50986b6e..0000000000000 --- a/shared-module/gamepadshift/GamePadShift.h +++ /dev/null @@ -1,43 +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_GAMEPADSHIFT_GAMEPADSHIFT_H -#define MICROPY_INCLUDED_GAMEPADSHIFT_GAMEPADSHIFT_H - -#include - -#include "shared-bindings/digitalio/DigitalInOut.h" - -typedef struct { - mp_obj_base_t base; - digitalio_digitalinout_obj_t *data_pin; - digitalio_digitalinout_obj_t *clock_pin; - digitalio_digitalinout_obj_t *latch_pin; - volatile uint8_t pressed; - volatile uint8_t last; -} gamepadshift_obj_t; - -#endif // MICROPY_INCLUDED_GAMEPADSHIFT_GAMEPADSHIFT_H diff --git a/shared-module/gamepadshift/__init__.c b/shared-module/gamepadshift/__init__.c deleted file mode 100644 index eadd3034f6e70..0000000000000 --- a/shared-module/gamepadshift/__init__.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Scott Shawcroft - * - * 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-module/gamepadshift/__init__.h" - -#include "py/mpstate.h" -#include "shared-bindings/gamepadshift/GamePadShift.h" - -void gamepadshift_tick(void) { - void *singleton = MP_STATE_VM(gamepad_singleton); - if (singleton == NULL || !mp_obj_is_type(MP_OBJ_FROM_PTR(singleton), &gamepadshift_type)) { - return; - } - - gamepadshift_obj_t *self = MP_OBJ_TO_PTR(singleton); - uint8_t current = 0; - uint8_t bit = 1; - common_hal_digitalio_digitalinout_set_value(self->latch_pin, 1); - for (int i = 0; i < 8; ++i) { - common_hal_digitalio_digitalinout_set_value(self->clock_pin, 0); - if (common_hal_digitalio_digitalinout_get_value(self->data_pin)) { - current |= bit; - } - common_hal_digitalio_digitalinout_set_value(self->clock_pin, 1); - bit <<= 1; - } - common_hal_digitalio_digitalinout_set_value(self->latch_pin, 0); - self->pressed |= self->last & current; - self->last = current; -} - -void gamepadshift_reset(void) { - MP_STATE_VM(gamepad_singleton) = NULL; -} diff --git a/shared-module/gamepadshift/__init__.h b/shared-module/gamepadshift/__init__.h deleted file mode 100644 index 225db73361a2b..0000000000000 --- a/shared-module/gamepadshift/__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_GAMEPADSHIFT___INIT___H -#define MICROPY_INCLUDED_GAMEPADSHIFT___INIT___H - -void gamepadshift_tick(void); -void gamepadshift_reset(void); - -#endif // MICROPY_INCLUDED_GAMEPADSHIFT___INIT___H diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 05b728826ecaf..8b370187d8e42 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -40,14 +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 - #if CIRCUITPY_KEYPAD #include "shared-module/keypad/__init__.h" #endif @@ -107,17 +99,6 @@ void supervisor_tick(void) { autoreload_tick(); #endif - #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 - } - #endif - #if CIRCUITPY_KEYPAD keypad_tick(); #endif