added documentation to input_handler.py

This commit is contained in:
Nicholas Dyer 2023-05-11 15:31:36 -04:00
parent eff7f2c893
commit a8674f073e

View File

@ -4,8 +4,15 @@ from pocket_friends.game_files.io_helpers.gpio_handler import Constants, GPIOHan
class InputHandler:
"""
Class that is implemented into surfaces in order to control the
pressing of buttons on both the real hardware and on a keyboard.
"""
def __init__(self, pygame_clock):
self.clock = pygame_clock
# If not on actual hardware, fake the GPIO in order to get it working correctly.
try:
importlib.util.find_spec('RPi.GPIO')
import RPi.GPIO as GPIO
@ -13,6 +20,7 @@ class InputHandler:
except ImportError:
import pocket_friends.game_files.io_helpers.fake_gpio as GPIO
self.on_hardware = False
self.last_input_tick = 0
def create_event(self, pressed_button):
@ -65,6 +73,9 @@ class InputHandler:
running = False
def update(self):
"""
Run the input handler and check for inputs.
"""
if self.on_hardware:
self.handle_gpio()
else: