(WIP) Move rule initialization into rule package.
This commit is contained in:
parent
727985f91c
commit
9e4062ba30
21 changed files with 366 additions and 489 deletions
|
@ -3,6 +3,7 @@ package mappingrules
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.annabunches.net/annabunches/joyful/internal/configparser"
|
||||
"github.com/holoplot/go-evdev"
|
||||
"github.com/jonboulle/clockwork"
|
||||
)
|
||||
|
@ -23,23 +24,32 @@ type MappingRuleAxisToRelaxis struct {
|
|||
clock clockwork.Clock
|
||||
}
|
||||
|
||||
func NewMappingRuleAxisToRelaxis(
|
||||
base MappingRuleBase,
|
||||
input *RuleTargetAxis,
|
||||
output *RuleTargetRelaxis,
|
||||
repeatRateMin, repeatRateMax, increment int) *MappingRuleAxisToRelaxis {
|
||||
func NewMappingRuleAxisToRelaxis(ruleConfig configparser.RuleConfigAxisToRelaxis,
|
||||
pDevs map[string]Device,
|
||||
vDevs map[string]Device,
|
||||
base MappingRuleBase) (*MappingRuleAxisToRelaxis, error) {
|
||||
|
||||
input, err := makeRuleTargetAxis(ruleConfig.Input, pDevs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
output, err := makeRuleTargetRelaxis(ruleConfig.Output, vDevs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MappingRuleAxisToRelaxis{
|
||||
MappingRuleBase: base,
|
||||
Input: input,
|
||||
Output: output,
|
||||
RepeatRateMin: repeatRateMin,
|
||||
RepeatRateMax: repeatRateMax,
|
||||
Increment: int32(increment),
|
||||
RepeatRateMin: ruleConfig.RepeatRateMin,
|
||||
RepeatRateMax: ruleConfig.RepeatRateMax,
|
||||
Increment: int32(ruleConfig.Increment),
|
||||
lastEvent: time.Now(),
|
||||
nextEvent: NoNextEvent,
|
||||
clock: clockwork.NewRealClock(),
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (rule *MappingRuleAxisToRelaxis) MatchEvent(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue