Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Nov 20, 2024
1 parent 57d8e96 commit d63428b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion inputremapper/injection/macros/tasks/mod_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import asyncio
from collections import deque
from typing import Deque

from evdev.ecodes import EV_KEY

Expand Down Expand Up @@ -64,7 +65,7 @@ class ModTapTask(Task):

async def run(self, callback) -> None:
tapping_term = self.get_argument("tapping_term").get_value() / 1000
jamming_asyncio_events = deque()
jamming_asyncio_events: Deque[asyncio.Event] = deque()

async def listener(event: InputEvent) -> None:
trigger = self.mapping.input_combination[-1]
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/test_macros/test_mod_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,21 @@ async def wait_for_timeout(self, macro):
macro = Parser.parse(macro, self.context, DummyMapping, True)

start = time.time()
# Awaiting the macro run will cause it to wait for the tapping_term
# Awaiting macro.run will cause it to wait for the tapping_term.
# When it injects the modifier, release the trigger.
macro.press_trigger()
await macro.run(lambda *_, **__: macro.release_trigger())
return time.time() - start

async def test_tapping_term_configuration_default(self):
time_ = await self.wait_for_timeout("mod_tap(a, b)")
# + 3 times 10ms of keycode_pause
self.assertAlmostEqual(time_, 0.23, delta=0.01)
# + 2 times 10ms of keycode_pause
self.assertAlmostEqual(time_, 0.22, delta=0.02)

async def test_tapping_term_configuration_100(self):
time_ = await self.wait_for_timeout("mod_tap(a, b, 100)")
self.assertAlmostEqual(time_, 0.13, delta=0.01)
self.assertAlmostEqual(time_, 0.12, delta=0.02)

async def test_tapping_term_configuration_100_kwarg(self):
time_ = await self.wait_for_timeout("mod_tap(a, b, tapping_term=100)")
self.assertAlmostEqual(time_, 0.13, delta=0.01)
self.assertAlmostEqual(time_, 0.12, delta=0.02)

0 comments on commit d63428b

Please sign in to comment.