added documentation to input_handler.py
This commit is contained in:
parent
eff7f2c893
commit
a8674f073e
@ -4,8 +4,15 @@ from pocket_friends.game_files.io_helpers.gpio_handler import Constants, GPIOHan
|
|||||||
|
|
||||||
|
|
||||||
class InputHandler:
|
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):
|
def __init__(self, pygame_clock):
|
||||||
self.clock = pygame_clock
|
self.clock = pygame_clock
|
||||||
|
|
||||||
|
# If not on actual hardware, fake the GPIO in order to get it working correctly.
|
||||||
try:
|
try:
|
||||||
importlib.util.find_spec('RPi.GPIO')
|
importlib.util.find_spec('RPi.GPIO')
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
@ -13,6 +20,7 @@ class InputHandler:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import pocket_friends.game_files.io_helpers.fake_gpio as GPIO
|
import pocket_friends.game_files.io_helpers.fake_gpio as GPIO
|
||||||
self.on_hardware = False
|
self.on_hardware = False
|
||||||
|
|
||||||
self.last_input_tick = 0
|
self.last_input_tick = 0
|
||||||
|
|
||||||
def create_event(self, pressed_button):
|
def create_event(self, pressed_button):
|
||||||
@ -65,6 +73,9 @@ class InputHandler:
|
|||||||
running = False
|
running = False
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
"""
|
||||||
|
Run the input handler and check for inputs.
|
||||||
|
"""
|
||||||
if self.on_hardware:
|
if self.on_hardware:
|
||||||
self.handle_gpio()
|
self.handle_gpio()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user