-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.py
57 lines (47 loc) · 1.53 KB
/
buttons.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
class Buttons:
def __init__(self, buttons_dict=None):
if buttons_dict is not None:
self.dict_to_object(buttons_dict)
else:
self.init_buttons()
def init_buttons(self):
self.up = False
self.down = False
self.right = False
self.left = False
self.select = False
self.start = False
self.Y = False
self.B = False
self.X = False
self.A = False
self.L = False
self.R = False
def dict_to_object(self, buttons_dict):
self.up = buttons_dict['Up']
self.down = buttons_dict['Down']
self.right = buttons_dict['Right']
self.left = buttons_dict['Left']
self.select = buttons_dict['Select']
self.start = buttons_dict['Start']
self.Y = buttons_dict['Y']
self.B = buttons_dict['B']
self.X = buttons_dict['X']
self.A = buttons_dict['A']
self.L = buttons_dict['L']
self.R = buttons_dict['R']
def object_to_dict(self):
buttons_dict = {}
buttons_dict['Up'] = self.up
buttons_dict['Down'] = self.down
buttons_dict['Right'] = self.right
buttons_dict['Left'] = self.left
buttons_dict['Select'] = self.select
buttons_dict['Start'] = self.start
buttons_dict['Y'] = self.Y
buttons_dict['B'] = self.B
buttons_dict['X'] = self.X
buttons_dict['A'] = self.A
buttons_dict['L'] = self.L
buttons_dict['R'] = self.R
return buttons_dict