mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-04 12:00:16 +00:00
#44 more stable check_add_row
This commit is contained in:
parent
4e2d23437c
commit
57ee86fe9b
@ -266,18 +266,34 @@ class Window:
|
||||
|
||||
def check_add_row(self):
|
||||
"""Ensure that one empty row is available at all times."""
|
||||
num_rows = len(self.get('key_list').get_children())
|
||||
rows = self.get('key_list').get_children()
|
||||
|
||||
# verify that all mappings are displayed. One of them
|
||||
# is possible the empty row
|
||||
# verify that all mappings are displayed.
|
||||
# One of them is possibly the empty row
|
||||
num_rows = len(rows)
|
||||
num_maps = len(custom_mapping)
|
||||
if num_rows < num_maps or num_rows > num_maps + 1:
|
||||
raise AssertionError(
|
||||
logger.error(
|
||||
f'custom_mapping contains {len(custom_mapping)} rows, '
|
||||
f'but {num_rows} are displayed'
|
||||
)
|
||||
logger.spam(
|
||||
'Mapping %s',
|
||||
list(custom_mapping)
|
||||
)
|
||||
logger.spam(
|
||||
'Rows %s',
|
||||
[(row.get_key(), row.get_character()) for row in rows]
|
||||
)
|
||||
|
||||
if num_rows == len(custom_mapping):
|
||||
# iterating over that 10 times per second is a bit wasteful,
|
||||
# but there were problems with the old approach which involved
|
||||
# just counting the number of mappings and rows.
|
||||
for row in rows:
|
||||
if row.get_key() is None or row.get_character() is None:
|
||||
# unfinished row found
|
||||
break
|
||||
else:
|
||||
self.add_empty()
|
||||
|
||||
return True
|
||||
|
@ -156,12 +156,14 @@ class Injector(multiprocessing.Process):
|
||||
needed = False
|
||||
for key, _ in self.context.mapping:
|
||||
if is_in_capabilities(key, capabilities):
|
||||
logger.debug('Grabbing "%s" because of "%s"', path, key)
|
||||
needed = True
|
||||
break
|
||||
|
||||
gamepad = is_gamepad(device)
|
||||
|
||||
if gamepad and self.context.maps_joystick():
|
||||
logger.debug('Grabbing "%s" because of maps_joystick', path)
|
||||
needed = True
|
||||
|
||||
if not needed:
|
||||
|
Loading…
Reference in New Issue
Block a user