rules: Test: Fix divergence between crown and wheel

All wheel tests return signed rotation amounts so that they can share
the same rule to multiply the rotation, as per the example rules in the
documentation.

However, this doesn't apply to crown tests and thumb_wheel rules with an
argument, which makes no sense as they also return rotation amount.
Hence, fix them by returning signed rotation amounts.

Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
Rongrong 2026-06-18 00:25:19 +08:00
parent 1e6272a15f
commit b56f30d24d
No known key found for this signature in database
GPG Key ID: 1C2D45D45AB7FE94
1 changed files with 17 additions and 5 deletions

View File

@ -384,7 +384,7 @@ def thumb_wheel_up(f, r, d, a):
return signed(d[0:2]) < 0 and signed(d[0:2])
elif thumb_wheel_displacement <= -a:
thumb_wheel_displacement += a
return 1
return -1
else:
return False
@ -414,10 +414,22 @@ def charging(f, r, d, _a):
TESTS = {
"crown_right": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[1] < 128 and d[1], False],
"crown_left": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[1] >= 128 and 256 - d[1], False],
"crown_right_ratchet": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[2] < 128 and d[2], False],
"crown_left_ratchet": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[2] >= 128 and 256 - d[2], False],
"crown_right": [
lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and signed(d[1:2]) > 0 and signed(d[1:2]),
False,
],
"crown_left": [
lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and signed(d[1:2]) < 0 and signed(d[1:2]),
False,
],
"crown_right_ratchet": [
lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and signed(d[2:3]) > 0 and signed(d[2:3]),
False,
],
"crown_left_ratchet": [
lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and signed(d[2:3]) < 0 and signed(d[2:3]),
False,
],
"crown_tap": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[5] == 0x01 and True, False],
"crown_start_press": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[6] == 0x01 and True, False],
"crown_end_press": [lambda f, r, d, a: f == SupportedFeature.CROWN and r == 0 and d[6] == 0x05 and True, False],