Rename mapping rules for consistent prefix.
This commit is contained in:
parent
80bfdfde90
commit
7ef62cbdc7
6 changed files with 21 additions and 21 deletions
|
@ -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,
|
||||
|
|
|
@ -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{"*"},
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue