workaround for the '4' key/000 problem with numpad affecting using DISP+4 to quick-switch display screens

This commit is contained in:
Tristan Rowley
2020-03-14 18:19:52 +00:00
parent 5896d7ef43
commit 5e82ba3f88

View File

@@ -22,7 +22,13 @@ class NumpadInput(object):
numpad = list(string.ascii_lowercase[0:19])
if event.char is 'h': # DISP button
#self.root.after(60, lambda:self.on_key_press_delay(event.char))
#return
if self.data.is_display_held:
return # ignore spurious message if already held"""
self.data.is_display_held = True
if self.in_0_event:
return
if event.char is '.' or event.char is 'z':
self.actions.quit_the_program()
@@ -39,8 +45,11 @@ class NumpadInput(object):
if event.char in numpad:
self.check_key_release_settings(event.char)
if event.char is 'h':
self.data.is_display_held = False
##print ("--- releasing %s" % event.char)
# lag for 60ms to check that this is not a 'stream of 000' bullshit job from the keypad
if event.char is 'h' and not self.in_0_event:
self.root.after(50, self.on_key_disp_release_delay)
#self.data.is_display_held = False
def on_mouse_move(self, event):
if self.data.settings['user_input'].setdefault(
@@ -78,15 +87,14 @@ class NumpadInput(object):
if self.data.is_display_held and key in numbers:
if numbers.index(key) >= len(self.data.get_display_modes_list()):
self.message_handler.set_message('ERROR', 'No page %s to display!' % numbers.index(key))
return
self.actions.call_method_name("set_display_mode_%s"%self.data.get_display_modes_list()[numbers.index(key)])
return
print('the numpad action being called is {} (mode is {})'.format(this_mapping[mode][is_function], mode))
if value != -1:
self.actions.call_method_name(this_mapping[mode][is_function],value)
else:
self.actions.call_method_name("set_display_mode_%s"%self.data.get_display_modes_list()[numbers.index(key)])
else:
self.actions.call_method_name(this_mapping[mode][is_function])
print('the numpad action being called for \'{}\' is {} (mode is {})'.format(key, this_mapping[mode][is_function], mode))
if value != -1:
self.actions.call_method_name(this_mapping[mode][is_function],value)
else:
self.actions.call_method_name(this_mapping[mode][is_function])
if is_function and self.data.settings['sampler']['FUNC_GATED']['value'] == 'off':
self.data.function_on = False
@@ -108,21 +116,39 @@ class NumpadInput(object):
if 'DEFAULT' in this_mapping:
if this_mapping['DEFAULT'][0] == 'toggle_function':
self.run_action_for_mapped_key(key)
def on_key_disp_release_delay(self):
if not self.in_0_event and self.additional_0_in_event==0:
print("releasing !")
self.data.is_display_held = False
else:
print("ignoring release !")
def on_key_disp_press_delay(self):
if not self.in_0_event and self.additional_0_in_event==0:
print("pressing!")
self.data.is_display_held = True
else:
print("ignoring press!")
def on_0_key_press(self) :
print ("on_0_key_press!")
if(not self.in_0_event ):
print (" first 0 received!")
self.in_0_event = True
self.additional_0_in_event = 0
self.root.after(60, self.check_event_outcome)
else:
print (" additional 0 received making %s!" % str(self.additional_0_in_event + 1))
self.additional_0_in_event = self.additional_0_in_event + 1
def check_event_outcome(self):
if(self.additional_0_in_event == 0 ):
print (" no additional events, sending s")
self.in_0_event = False
self.run_action_for_mapped_key('s')
elif(self.additional_0_in_event > 1):
print (" %s additional events, sending n"%self.additional_0_in_event)
self.in_0_event = False
self.run_action_for_mapped_key('n')
elif(self.additional_0_in_event == 1):
@@ -130,6 +156,7 @@ class NumpadInput(object):
self.root.after(60, self.second_check_event_outcome)
def second_check_event_outcome(self):
print("not supposed to happen?")
if(self.additional_0_in_event == 1 ):
self.in_0_event = False
self.run_action_for_mapped_key('s')