Skip to content

Commit 3e45d28

Browse files
committed
hotfix empty/None key
1 parent ab593c1 commit 3e45d28

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

free_snap_tap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
# Define File name for saving of everything, can be any filetype
3030
# But .txt or .cfg recommended for easier editing
31-
# CONSTANTS.FILE_NAME = 'FSTconfig.txt'
32-
CONSTANTS.FILE_NAME = 'FSTconfig_test.txt'
33-
# CONSTANTS.FILE_NAME = 'allinone.txt'
31+
CONSTANTS.FILE_NAME = 'FSTconfig.txt'
32+
# CONSTANTS.FILE_NAME = 'FSTconfig_test.txt'
33+
3434

3535
# Control key combinations (vk_code and/or key_string)
3636
# (1,2 or more keys possible - depends on rollover of your keyboard)
@@ -87,7 +87,7 @@ def __init__(self, root, fst_keyboard):
8787
self.context_menu.add_separator()
8888
self.context_menu.add_command(label="Close Indicator", command=self.close_window)
8989
self.context_menu.add_command(label="Toggle Crosshair", command=self.toggle_crosshair)
90-
#self.context_menu.add_command(label="Display internal state", command=self._fst.display_internal_repr_groups)
90+
self.context_menu.add_command(label="Display internal state", command=self._fst.display_internal_repr_groups)
9191

9292
# Bind right-click to show the context menu
9393
self.canvas.bind("<Button-3>", self.show_context_menu)

fst_keyboard.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ def convert_to_vk_code(self, key):
128128
except KeyError:
129129
try:
130130
key_int = int(key)
131-
if 0 < key_int < 256:
131+
###XXX 241014-0223
132+
if 0 <= key_int < 256:
133+
# if 0 < key_int < 256:
132134
return key_int
133135
except ValueError as error:
134136
print(error)
@@ -175,8 +177,9 @@ def extract_data_from_key(key_string):
175177
constraints = [self._arg_manager.ALIAS_MAX_DELAY_IN_MS, self._arg_manager.ALIAS_MIN_DELAY_IN_MS]
176178

177179
# if string empty, stop
178-
if key_string == '':
179-
return False
180+
###XXX 241014-0223 to enable None ke with empty string
181+
# if key_string == '':
182+
# return False
180183

181184
# recognition of mofidiers +, -, !, ^
182185
# only interpret it as such when more then one char is in key
@@ -201,10 +204,7 @@ def extract_data_from_key(key_string):
201204

202205
# convert string to actual vk_code
203206
vk_code = self.convert_to_vk_code(key_string)
204-
###XXX None Key handling s up to prevent double eval of constraints and is always valid in trigger
205-
if vk_code == 0:
206-
key_modifier == 'up'
207-
207+
208208
if key_modifier is None:
209209
new_element = (Key(vk_code, constraints=constraints, key_string=key_string))
210210
elif key_modifier == 'down':
@@ -230,7 +230,9 @@ def convert_key_string_group(list_of_strings, is_trigger_group = False):
230230
key_group.append(new_element)
231231
elif isinstance(new_element, Key):
232232
key_press, key_releae = new_element.get_key_events()
233-
key_group.append(key_press)
233+
###XXX hacks to enable empty ke with only one + element
234+
if new_element.vk_code > 0:
235+
key_group.append(key_press)
234236
# if not in trigger group - so Key Instances as triggers are handled correctly
235237
if not is_trigger_group:
236238
key_group.append(key_releae)
@@ -746,8 +748,8 @@ def is_trigger_activated(current_ke, trigger_group):
746748
# to be not used to filter out opposing sim keys
747749
if alias_fired:
748750
self.state_manager.remove_key_press_state(current_ke.vk_code)
749-
if CONSTANTS.DEBUG4:
750-
print(f"D4: -- removed {current_ke} from pressed keys")
751+
if CONSTANTS.DEBUG3:
752+
print(f"D3: -- removed {current_ke} from pressed keys")
751753
if CONSTANTS.DEBUG4:
752754
print(f"D4: {"-- | XX" if is_simulated else "XX"} SUPPRESSED: {current_ke}")
753755

@@ -827,6 +829,8 @@ def check_debug_numpad_actions(self):
827829
CONSTANTS.DEBUG3 = not CONSTANTS.DEBUG3
828830
if self.check_for_combination(['num4']):
829831
CONSTANTS.DEBUG4 = not CONSTANTS.DEBUG4
832+
if self.check_for_combination(['num5']):
833+
self.display_internal_repr_groups()
830834
if self.check_for_combination(['num7']):
831835
pprint.pp(f"real_key_state: {self.state_manager._real_key_press_states_dict}")
832836
pprint.pp(f"sim_key_state: {self.state_manager._simulated_key_press_states_dict}")
@@ -880,9 +884,9 @@ def reset_macro_sequence_by_alias(self, alias_name, current_ke = ''):
880884
try:
881885
macro_to_reset = self._macros_alias_dict[alias_name]
882886
macro_to_reset.reset_sequence_counter()
883-
print(f"--- Macro ({alias_name}) reseted successfully by {current_ke}")
887+
if CONSTANTS.DEBUG4:
888+
print(f"D4: -- Macro ({alias_name}) reseted successfully by {current_ke}")
884889
except KeyError:
885-
886890
print(f"--- No Macro Sequence with name {alias_name} - reset failed")
887891
if CONSTANTS.DEBUG:
888892
print(f"all sequence names: {self._macros_alias_dict.keys()}")

fst_manager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,12 +895,12 @@ def display_groups(self):
895895
for group in self._macros_hr:
896896
alias, *group = group
897897
group = group[0]
898-
position = len(alias)-2
899-
first_line = f"{alias} " + f'\n{' '*position}:: '.join([', '.join(group[0]),', '.join(group[1])])
898+
position = len(alias)-1
899+
first_line = f"{alias} {', '.join(group[0])} :"
900900
print(first_line)
901-
if len(group) > 2:
902-
for gr in group[2:]:
903-
print(f"{' '*position} : " + ', '.join(gr))
901+
if len(group) > 1:
902+
for gr in group[1:]:
903+
print(f"{' '*position}: " + ', '.join(gr))
904904

905905
def add_group(self, new_group, data_object):
906906
"""
@@ -1026,6 +1026,8 @@ def extract_delays(arg):
10261026
if arg == "-debug":
10271027
self.DEBUG = True
10281028
CONSTANTS.DEBUG = True
1029+
if arg == "-debug_numpad":
1030+
CONSTANTS.DEBUG_NUMPAD = True
10291031
# start directly without showing the menu
10301032
elif arg == "-nomenu":
10311033
self.MENU_ENABLED = False

fst_threads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ def run(self):
7676
if self.reset:
7777
self.macro_stop_event = Event()
7878
self.reset = False
79-
print(f"{self.alias_name} reset")
79+
#print(f"D4: Repeat: {self.alias_name} reset")
8080
else:
81-
print(f"{self.alias_name} execute")
81+
#print(f"D4: Repeat: {self.alias_name} execute")
8282
self._fst.start_macro_playback(self.alias_name, self._fst.key_group_by_alias[self.alias_name], self.macro_stop_event)
8383
for index in range(self.number_of_increments):
8484
if self.stop_event.is_set():

0 commit comments

Comments
 (0)