From a499e8d67677368b395088b3e9bc4c935f572a3f Mon Sep 17 00:00:00 2001 From: Rongrong Date: Tue, 26 May 2026 02:27:10 +0800 Subject: [PATCH] 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, which makes no sense as they also return rotation amount. Hence, do the same for crown tests. Signed-off-by: Rongrong --- lib/logitech_receiver/diversion.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 537b9755..7f117c27 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -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],