diff --git a/cmd/joyful/main.go b/cmd/joyful/main.go index 61c583b..a633f4d 100644 --- a/cmd/joyful/main.go +++ b/cmd/joyful/main.go @@ -75,7 +75,7 @@ func main() { timerCount := 0 for _, rule := range rules { - if timedRule, ok := rule.(*mappingrules.ProportionalAxisMappingRule); ok { + if timedRule, ok := rule.(*mappingrules.MappingRuleProportionalAxis); ok { go timerWatcher(timedRule, eventChannel) timerCount++ } diff --git a/cmd/joyful/threads.go b/cmd/joyful/threads.go index dabd2c7..d3e270b 100644 --- a/cmd/joyful/threads.go +++ b/cmd/joyful/threads.go @@ -28,7 +28,7 @@ func eventWatcher(device *evdev.InputDevice, channel chan<- ChannelEvent) { } } -func timerWatcher(rule *mappingrules.ProportionalAxisMappingRule, channel chan<- ChannelEvent) { +func timerWatcher(rule *mappingrules.MappingRuleProportionalAxis, channel chan<- ChannelEvent) { for { event := rule.TimerEvent() if event != nil { diff --git a/internal/config/rules.go b/internal/config/rules.go index dd8fba4..a293cb9 100644 --- a/internal/config/rules.go +++ b/internal/config/rules.go @@ -63,19 +63,19 @@ func setBaseRuleParameters(ruleConfig RuleConfig, vDevs map[string]*evdev.InputD }, nil } -func makeSimpleRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.SimpleMappingRule, error) { +func makeSimpleRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.MappingRuleSimple, error) { input, err := makeRuleTarget(ruleConfig.Input, pDevs) if err != nil { return nil, err } - return &mappingrules.SimpleMappingRule{ + return &mappingrules.MappingRuleSimple{ MappingRuleBase: base, Input: input, }, nil } -func makeComboRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.ComboMappingRule, error) { +func makeComboRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.MappingRuleCombo, error) { inputs := make([]mappingrules.RuleTarget, 0) for _, inputConfig := range ruleConfig.Inputs { input, err := makeRuleTarget(inputConfig, pDevs) @@ -85,20 +85,20 @@ func makeComboRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, b inputs = append(inputs, input) } - return &mappingrules.ComboMappingRule{ + return &mappingrules.MappingRuleCombo{ MappingRuleBase: base, Inputs: inputs, State: 0, }, nil } -func makeLatchedRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.LatchedMappingRule, error) { +func makeLatchedRule(ruleConfig RuleConfig, pDevs map[string]*evdev.InputDevice, base mappingrules.MappingRuleBase) (*mappingrules.MappingRuleLatched, error) { input, err := makeRuleTarget(ruleConfig.Input, pDevs) if err != nil { return nil, err } - return &mappingrules.LatchedMappingRule{ + return &mappingrules.MappingRuleLatched{ MappingRuleBase: base, Input: input, State: false, diff --git a/internal/mappingrules/matching_test.go b/internal/mappingrules/mapping_rule_simple_test.go similarity index 94% rename from internal/mappingrules/matching_test.go rename to internal/mappingrules/mapping_rule_simple_test.go index 00a6da5..b675a7b 100644 --- a/internal/mappingrules/matching_test.go +++ b/internal/mappingrules/mapping_rule_simple_test.go @@ -13,8 +13,8 @@ type SimpleMappingRuleTests struct { wrongInputDevice *evdev.InputDevice outputDevice *evdev.InputDevice mode *string - sampleRule *SimpleMappingRule - invertedRule *SimpleMappingRule + sampleRule *MappingRuleSimple + invertedRule *MappingRuleSimple } func (t *SimpleMappingRuleTests) SetupTest() { @@ -25,7 +25,7 @@ func (t *SimpleMappingRuleTests) SetupTest() { t.mode = &mode // TODO: implement a constructor function... - t.sampleRule = &SimpleMappingRule{ + t.sampleRule = &MappingRuleSimple{ MappingRuleBase: MappingRuleBase{ Output: NewRuleTargetButton("", t.outputDevice, evdev.BTN_TRIGGER, false), Modes: []string{"*"}, @@ -33,7 +33,7 @@ func (t *SimpleMappingRuleTests) SetupTest() { Input: NewRuleTargetButton("", t.inputDevice, evdev.BTN_TRIGGER, false), } - t.invertedRule = &SimpleMappingRule{ + t.invertedRule = &MappingRuleSimple{ MappingRuleBase: MappingRuleBase{ Output: NewRuleTargetButton("", t.outputDevice, evdev.BTN_TRIGGER, false), Modes: []string{"*"}, diff --git a/internal/mappingrules/matching.go b/internal/mappingrules/matching.go index b21245c..a8eb3da 100644 --- a/internal/mappingrules/matching.go +++ b/internal/mappingrules/matching.go @@ -17,7 +17,7 @@ func (rule *MappingRuleBase) modeCheck(mode *string) bool { return slices.Contains(rule.Modes, *mode) } -func (rule *SimpleMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { +func (rule *MappingRuleSimple) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { if !rule.MappingRuleBase.modeCheck(mode) { return nil } @@ -30,7 +30,7 @@ func (rule *SimpleMappingRule) MatchEvent(device *evdev.InputDevice, event *evde return rule.Output.CreateEvent(rule.Input.NormalizeValue(event.Value), mode) } -func (rule *ComboMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { +func (rule *MappingRuleCombo) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { if !rule.MappingRuleBase.modeCheck(mode) { return nil } @@ -68,7 +68,7 @@ func (rule *ComboMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev return nil } -func (rule *LatchedMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { +func (rule *MappingRuleLatched) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { if !rule.MappingRuleBase.modeCheck(mode) { return nil } @@ -91,14 +91,14 @@ func (rule *LatchedMappingRule) MatchEvent(device *evdev.InputDevice, event *evd return rule.Output.CreateEvent(value, mode) } -func (rule *ProportionalAxisMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { +func (rule *MappingRuleProportionalAxis) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) *evdev.InputEvent { // STUB return nil } // TimerEvent returns an event when enough time has passed (compared to the last recorded axis value) // to emit an event. -func (rule *ProportionalAxisMappingRule) TimerEvent() *evdev.InputEvent { +func (rule *MappingRuleProportionalAxis) TimerEvent() *evdev.InputEvent { // STUB return nil } diff --git a/internal/mappingrules/types.go b/internal/mappingrules/types.go index 35b1c77..546c1a9 100644 --- a/internal/mappingrules/types.go +++ b/internal/mappingrules/types.go @@ -11,26 +11,26 @@ type MappingRuleBase struct { } // A Simple Mapping Rule can map a button to a button or an axis to an axis. -type SimpleMappingRule struct { +type MappingRuleSimple struct { MappingRuleBase Input RuleTarget } // A Combo Mapping Rule can require multiple physical button presses for a single output button -type ComboMappingRule struct { +type MappingRuleCombo struct { MappingRuleBase Inputs []RuleTarget State int } -type LatchedMappingRule struct { +type MappingRuleLatched struct { MappingRuleBase Input RuleTarget State bool } // TODO: How are we going to implement this? It needs to operate on a timer... -type ProportionalAxisMappingRule struct { +type MappingRuleProportionalAxis struct { MappingRuleBase Input RuleTarget Output RuleTarget