You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
970 B

import os
import json
class UserControls:
def __init__(self):
print("UserControls init")
self.configs = self.get_config()
def get_config(self):
configs = {}
for file in os.listdir("conf"):
if file.endswith(".json"):
with open(os.path.join("conf", file)) as f:
configs[file[:-5]] = json.load(f)
return configs
def handle_events(self, mapping, event):
print(self.configs[mapping].get(event))
if method := self.configs[mapping].get(event):
getattr(self, method)()
def scroll_up(self):
if self.graphics.view_offset_y < 0:
self.graphics.view_offset_y += 10
def scroll_down(self):
self.graphics.view_offset_y -= 10
def scroll_left(self):
self.graphics.view_offset_x += 10
def scroll_right(self):
self.graphics.view_offset_x -= 10