Add tests for AxisToButton rule. (WIP)

This commit is contained in:
Anna Rose Wiggins 2025-07-11 21:20:43 -04:00
parent 47fac539da
commit e93187b8a5
4 changed files with 76 additions and 14 deletions

View file

@ -8,8 +8,6 @@ import (
// MappingRuleAxisToButton represents a rule that converts an axis input into a (potentially repeating)
// button output.
//
// TODO: Add Tests
type MappingRuleAxisToButton struct {
MappingRuleBase
Input *RuleTargetAxis
@ -38,9 +36,8 @@ func NewMappingRuleAxisToButton(base MappingRuleBase, input *RuleTargetAxis, out
}
}
func (rule *MappingRuleAxisToButton) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) (*evdev.InputDevice, *evdev.InputEvent) {
// TODO: we're using this instead of the RuleTarget's MatchEvent because we need to check inside the deadzone
// We should find a cleaner way to do this...
func (rule *MappingRuleAxisToButton) MatchEvent(device RuleTargetDevice, event *evdev.InputEvent, mode *string) (*evdev.InputDevice, *evdev.InputEvent) {
if !rule.MappingRuleBase.modeCheck(mode) ||
!rule.Input.MatchEventDeviceAndCode(device, event) {
return nil, nil