From 1f6c2517c0e03b51199d006a347506235fc3f114 Mon Sep 17 00:00:00 2001 From: Anna Rose Wiggins Date: Fri, 4 Jul 2025 19:11:39 -0400 Subject: [PATCH] Fix inverted buttons. --- internal/mappingrules/matching.go | 2 +- internal/mappingrules/targets.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/mappingrules/matching.go b/internal/mappingrules/matching.go index 7bbad7c..b21245c 100644 --- a/internal/mappingrules/matching.go +++ b/internal/mappingrules/matching.go @@ -11,7 +11,7 @@ func (rule *MappingRuleBase) OutputName() string { } func (rule *MappingRuleBase) modeCheck(mode *string) bool { - if len(rule.Modes) == 1 && rule.Modes[0] == "*" { + if rule.Modes[0] == "*" { return true } return slices.Contains(rule.Modes, *mode) diff --git a/internal/mappingrules/targets.go b/internal/mappingrules/targets.go index 81c6022..bc2129c 100644 --- a/internal/mappingrules/targets.go +++ b/internal/mappingrules/targets.go @@ -20,10 +20,13 @@ func (target *RuleTargetBase) GetDevice() *evdev.InputDevice { } func (target *RuleTargetButton) NormalizeValue(value int32) int32 { - if value == 0 { - return 1 + if target.Inverted { + if value == 0 { + return 1 + } + return 0 } - return 0 + return value } func (target *RuleTargetButton) CreateEvent(value int32, mode *string) *evdev.InputEvent {