-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_handler.py
74 lines (51 loc) · 1.71 KB
/
event_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from abc import ABC, abstractmethod
from types import FunctionType
class Meta(type):
def __call__(cls, *args, **kwargs):
funcs = [x for x, y in cls.__dict__.items() if type(y) == FunctionType and not x.startswith('__')]
instance = super().__call__(*args, **kwargs)
for f in funcs:
key = f.replace('handle_', '')
instance.registered_event[key] = f
return instance
class EventHandler(object, metaclass=Meta):
def __init__(self):
self.registered_event = {}
def register(self, key, fn):
self.registered_event[key] = fn
def handle_stick(self, axies):
raise NotImplementedError
def handle_x(self):
raise NotImplementedError
def handle_circle(self):
raise NotImplementedError
def handle_triangle(self):
raise NotImplementedError
def handle_square(self):
raise NotImplementedError
def handle_l1(self):
raise NotImplementedError
def handle_l2(self):
raise NotImplementedError
def handle_l3(self):
raise NotImplementedError
def handle_r1(self):
raise NotImplementedError
def handle_r2(self):
raise NotImplementedError
def handle_r3(self):
raise NotImplementedError
def handle_up(self):
raise NotImplementedError
def handle_down(self):
raise NotImplementedError
def handle_left(self):
raise NotImplementedError
def handle_right(self):
raise NotImplementedError
def handle_select(self):
raise NotImplementedError
def handle_start(self):
raise NotImplementedError
def handle_ps(self):
raise NotImplementedError