fix bug where NullHandler would not work with Axis/Key combination

pull/595/head
Jonas Bosse 1 year ago
parent 0f10d06ab6
commit caa8f2c57b
No known key found for this signature in database
GPG Key ID: E77C7242D9D3EE18

@ -40,10 +40,16 @@ class NullHandler(MappingHandler):
return "Voids all events"
def needs_wrapping(self) -> bool:
return False in [input_.defines_analog_input for input_ in self.input_configs]
return False in [
input_.defines_analog_input for input_ in self.mapping.input_combination
]
def wrap_with(self) -> Dict[InputCombination, HandlerEnums]:
return {InputCombination(self.input_configs): HandlerEnums.combination}
if not self.mapping.input_combination.defines_analog_input:
return {self.mapping.input_combination: HandlerEnums.combination}
assert len(self.mapping.input_combination) > 1, "nees_wrapping ensures this!"
return {self.mapping.input_combination: HandlerEnums.axisswitch}
def notify(
self,

@ -910,6 +910,43 @@ class TestIdk(EventPipelineTestBase):
count_x = convert_to_internal_events(mouse_history).count(expected_rel_event)
self.assertEqual(len(mouse_history), count_x)
async def test_key_axis_combination_to_disable(self):
combination = InputCombination(
[
InputConfig(type=EV_ABS, code=ABS_X),
InputConfig(type=EV_ABS, code=ABS_Y, analog_threshold=5),
]
)
preset = Preset()
forward_history = self.forward_uinput.write_history
mapping = Mapping(
input_combination=combination,
output_symbol="disable",
target_uinput="keyboard",
)
preset.add(mapping)
event_reader = self.get_event_reader(preset, fixtures.gamepad)
await self.send_events(
[
InputEvent.from_tuple((EV_ABS, ABS_X, 10)), # forwarded
InputEvent.from_tuple((EV_ABS, ABS_Y, int(0.1 * MAX_ABS))),
InputEvent.from_tuple((EV_ABS, ABS_X, 20)), # disabled
InputEvent.from_tuple((EV_ABS, ABS_Y, int(0.02 * MAX_ABS))),
InputEvent.from_tuple((EV_ABS, ABS_X, 30)), # forwarded
],
event_reader,
)
self.assertEqual(
forward_history,
[
InputEvent.from_tuple((EV_ABS, ABS_X, 10)),
InputEvent.from_tuple((EV_ABS, ABS_X, 30)),
],
)
class TestAbsToAbs(EventPipelineTestBase):
async def test_abs_to_abs(self):

Loading…
Cancel
Save