Skip to content

Commit

Permalink
Don't suppress combinations that map to an analog axis
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Feb 2, 2025
1 parent 230aac3 commit 2a09af5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
12 changes: 10 additions & 2 deletions inputremapper/injection/mapping_handlers/combination_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ def _handle_freshly_activated(
# Send key up events to the forwarded uinput if configured to do so.
self._forward_release()

logger.debug("Sending %s to sub-handler", self.mapping.input_combination)
logger.debug(
"Sending %s to sub-handler %s",
self.mapping.input_combination,
repr(self._sub_handler),
)
self._output_previously_active = bool(event.value)
sub_handler_result = self._sub_handler.notify(event, source, suppress)

Expand All @@ -176,7 +180,11 @@ def _handle_freshly_deactivated(
# In the case of output axis, this will enable us to activate multiple
# axis with the same button.

logger.debug("Sending %s to sub-handler", self.mapping.input_combination)
logger.debug(
"Sending %s to sub-handler %s",
self.mapping.input_combination,
repr(self._sub_handler),
)
self._output_previously_active = bool(event.value)
self._sub_handler.notify(event, source, suppress=False)

Expand Down
14 changes: 10 additions & 4 deletions inputremapper/injection/mapping_handlers/hierarchy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ def notify(

success = False
for handler in self.handlers:
if not success:
success = handler.notify(event, source)
else:
handler.notify(event, source, suppress=True)
# We want to be able to map EV_REL to EV_ABS, and while moving the gamepad,
# still trigger keys using EV_REL and an analog_threshold. In this case, we
# have two combinations activated at the same time.
defines_analog_input = True in [
input_config.defines_analog_input
for input_config in handler.input_configs
]
suppress = success and not defines_analog_input
success = handler.notify(event, source, suppress=suppress) or success

return success

def reset(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/injection/mapping_handlers/mapping_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _create_hierarchy_handlers(
)
sub_handlers: List[MappingHandler] = []
for combination in sorted_combinations:
sub_handlers.append(*handlers[combination])
sub_handlers.extend(handlers[combination])

sorted_handlers.add(
HierarchyHandler(
Expand Down

0 comments on commit 2a09af5

Please sign in to comment.