-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix RapidFireKey argument expansion * Add basic unit test * Fix calling keyboard.tap() from within a scheduled task * Simplify code and memory management
- Loading branch information
Showing
2 changed files
with
143 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import unittest | ||
|
||
from kmk.keys import KC | ||
from kmk.modules.rapidfire import RapidFire | ||
from tests.keyboard_test import KeyboardTest | ||
|
||
t_interval = 4 * KeyboardTest.loop_delay_ms | ||
t_timeout = 10 * KeyboardTest.loop_delay_ms | ||
t_hold = t_timeout + 5 * t_interval + KeyboardTest.loop_delay_ms | ||
|
||
|
||
class TestKeyRepeat(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
KC.clear() | ||
|
||
cls.keyboard = KeyboardTest( | ||
[RapidFire()], | ||
[ | ||
[ | ||
KC.RF(KC.N0, interval=t_interval, timeout=t_timeout), | ||
KC.RF(KC.N1, interval=t_interval, timeout=t_timeout, toggle=True), | ||
], | ||
], | ||
debug_enabled=False, | ||
) | ||
|
||
def test_rapidfire(self): | ||
self.keyboard.test( | ||
'', | ||
[(0, True), (0, False)], | ||
[{KC.N0}, {}], | ||
) | ||
|
||
self.keyboard.test( | ||
'', | ||
[(0, True), t_timeout // 2, (0, False)], | ||
[{KC.N0}, {}], | ||
) | ||
|
||
self.keyboard.test( | ||
'', | ||
[(0, True), t_timeout + t_interval // 2, (0, False)], | ||
[{KC.N0}, {}, {KC.N0}, {}], | ||
) | ||
|
||
self.keyboard.test( | ||
'', | ||
[(0, True), t_timeout + (3 * t_interval) // 2, (0, False)], | ||
[{KC.N0}, {}, {KC.N0}, {}, {KC.N0}, {}], | ||
) | ||
|
||
self.keyboard.test( | ||
'', | ||
[(0, True), t_hold, (0, False)], | ||
[ | ||
{KC.N0}, | ||
{}, | ||
{KC.N0}, | ||
{}, | ||
{KC.N0}, | ||
{}, | ||
{KC.N0}, | ||
{}, | ||
{KC.N0}, | ||
{}, | ||
{KC.N0}, | ||
{}, | ||
], | ||
) | ||
|
||
self.keyboard.test( | ||
'', | ||
[ | ||
(1, True), | ||
t_timeout + t_interval // 2, | ||
(1, False), | ||
3 * t_interval, | ||
(1, True), | ||
(1, False), | ||
], | ||
[ | ||
{KC.N1}, | ||
{}, | ||
{KC.N1}, | ||
{}, | ||
{KC.N1}, | ||
{}, | ||
{KC.N1}, | ||
{}, | ||
{KC.N1}, | ||
{}, | ||
], | ||
) |