-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
68 lines (61 loc) · 1.68 KB
/
config.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
from threading import Event
"""
State is the program state. Every state changes make the gui and the currently running thread change
"""
READY = 'ready'
RECORDING_MOUSE_SEQ = 'recording_mouse_seq'
PLAYING_MOUSE_SEQ = 'playing_mouse_seq'
RECORDING_KBM_CONNECTIONS = 'recording_kbm_connections'
PLAYING_KBM_CONNECTIONS = 'playing_kbm_connections'
state = READY
"""
State event object
"""
stateEvent = Event()
"""
Mouse sequence constants
"""
mouse_sequence_playingTimes = 0
mouse_sequence_movementSamplingTime = 0
"""
Current preset is the preset currently in memory
"""
currentPreset = {
'mouseSeq': {
'recordedEvents': [],
'recordedTimes': []
},
'kbmMap': {}
}
# reset the current preset
def resetCurrentPreset(widget):
global currentPreset
currentPreset = {
'mouseSeq': {
'recordedEvents': [],
'recordedTimes': []
},
'kbmMap': {}
}
# reset the current preset
def resetCurrentMouseSequencePreset(widget):
global currentPreset
currentPreset['mouseSeq'] = {
'recordedEvents': [],
'recordedTimes': []
}
class InvalidPreset(Exception): pass
# check if data is a valid preset
def isPresetValid(data):
if len(data.keys()) != 2:
raise InvalidPreset()
if len(data['mouseSeq'].keys()) != 2:
raise InvalidPreset()
#from collections.abc import Mapping
if not isinstance(data['kbmMap'], dict):
raise InvalidPreset()
if not isinstance(data['mouseSeq'], dict):
raise InvalidPreset()
if not ( isinstance(data['mouseSeq']['recordedEvents'], list) and
isinstance(data['mouseSeq']['recordedTimes'], list) ):
raise InvalidPreset()