Implement axis targets, axis -> button and axis -> relative axis mappings. (#1)

Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com>
Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
Anna Rose Wiggins 2025-07-15 19:55:19 +00:00 committed by Anna Rose Wiggins
parent ff38db6596
commit e617a6eda6
25 changed files with 903 additions and 130 deletions

View file

@ -0,0 +1,30 @@
package mappingrules
import (
"golang.org/x/exp/constraints"
)
type Numeric interface {
constraints.Integer | constraints.Float
}
func Abs[T Numeric](value T) T {
return max(value, -value)
}
// LerpInt linearly interpolates between two integer values using
// a float64 index value
func LerpInt[T constraints.Integer](min, max T, t float64) T {
t = Clamp(t, 0.0, 1.0)
return T((1-t)*float64(min) + t*float64(max))
}
func Clamp[T Numeric](value, min, max T) T {
if value < min {
value = min
}
if value > max {
value = max
}
return value
}