Add documentation.
This commit is contained in:
parent
2e8c2c5404
commit
fc2f999faa
2 changed files with 17 additions and 11 deletions
|
|
@ -105,11 +105,19 @@ func NewRuleTargetAxis(device_name string,
|
|||
// Typically this function is called after RuleTargetAxis.MatchEvent, which checks whether we are
|
||||
// in the deadzone, among other things.
|
||||
func (target *RuleTargetAxis) NormalizeValue(value int32) int32 {
|
||||
for _, dz := range target.Deadzones {
|
||||
state, dzValue := dz.Match(value)
|
||||
if state == DeadzoneEmit {
|
||||
return Clamp(dzValue, target.OutputMin, target.OutputMax)
|
||||
}
|
||||
}
|
||||
|
||||
axisStrength := target.GetAxisStrength(value)
|
||||
return LerpInt(target.OutputMin, target.OutputMax, axisStrength)
|
||||
}
|
||||
|
||||
func (target *RuleTargetAxis) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
fmt.Println("DEBUG: Emitting event")
|
||||
value = Clamp(value, AxisValueMin, AxisValueMax)
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_ABS,
|
||||
|
|
@ -149,12 +157,6 @@ func (target *RuleTargetAxis) InDeadZone(value int32) bool {
|
|||
func (target *RuleTargetAxis) GetAxisStrength(value int32) float64 {
|
||||
adjValue := value
|
||||
for _, dz := range target.Deadzones {
|
||||
state, dzValue := dz.Match(value)
|
||||
if state == DeadzoneEmit {
|
||||
adjValue = dzValue
|
||||
break
|
||||
}
|
||||
|
||||
if value > dz.End {
|
||||
adjValue -= dz.Size
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue