fix(CapabilityMap): use min/max range for unsigned axis normalization#569
fix(CapabilityMap): use min/max range for unsigned axis normalization#569honjow wants to merge 3 commits intoShadowBlip:mainfrom
Conversation
- normalize_unsigned_value now accounts for min offset: (value - min) / (max - min) - denormalize_unsigned_value updated accordingly - Add `inverted` field to EvdevConfig for capability maps, allowing axes with reversed hardware polarity (e.g. ADC triggers) to be properly mapped without device tree changes
pastaq
left a comment
There was a problem hiding this comment.
Just a small bit, everything else looks good.
| "maximum": 65535, | ||
| "minimum": 0 | ||
| }, | ||
| "inverted": { |
There was a problem hiding this comment.
Let's call this invert as well to keep terms consistent
There was a problem hiding this comment.
Let's call this invert as well to keep terms consistent
Changes pushed
| "maximum": 65535, | ||
| "minimum": 0 | ||
| }, | ||
| "invert": { |
There was a problem hiding this comment.
I don't think the inversion stuff is particularly necessary. It appears to be redundant with #534. It is also out of scope for fixing the bug with axes not starting at 0. If you think there is a valid case for it please submit that as a separate PR.
There was a problem hiding this comment.
Would inverting triggers in a similar manner as in #534 be acceptable?
There was a problem hiding this comment.
There was a problem hiding this comment.
In either case it's a separate issue so a separate PR is necessary
Remove the invert field added to EvdevConfig as it is out of scope for the unsigned axis normalization fix and overlaps with existing invert support in PR ShadowBlip#534.
normalize_unsigned_valuewas computingvalue / max, which only works when min is 0. For axes where min is non-zero — such as ADC-based triggers found on some ARM handhelds (e.g. Gameforce Ace, which uses theadc-joystickdriver and reports triggers asABS_HAT2X/ABS_HAT2Ywith a range of 890 to 1530) — the values are never correctly scaled to 0.0 to 1.0.Changed to
(value - min) / (max - min)with a.clamp(0.0, 1.0), and updateddenormalize_unsigned_valueaccordingly.Also adds an
invertedfield toEvdevConfig(source side). This complements the existinginvertoption onAxisCapability(target side): the existing one handlesVector2joystick axes after translation, but there's no way to invert a trigger (Floatvalue) at the source. ADC triggers on some hardware report values in reverse — high at rest, low when pressed — and without this option there's currently no way to handle it in a capability map.No behavior change for devices where min is already 0.