Add tests for RuleTargetAxis.
This commit is contained in:
parent
8f3b8f4b47
commit
6646044d28
8 changed files with 164 additions and 9 deletions
|
@ -9,12 +9,11 @@ import (
|
|||
|
||||
type RuleTargetAxis struct {
|
||||
DeviceName string
|
||||
Device *evdev.InputDevice
|
||||
Device RuleTargetDevice
|
||||
Axis evdev.EvCode
|
||||
Inverted bool
|
||||
DeadzoneStart int32
|
||||
DeadzoneEnd int32
|
||||
Sensitivity float64 // TODO: is this even a value that makes sense?
|
||||
axisSize int32
|
||||
deadzoneSize int32
|
||||
}
|
||||
|
@ -25,7 +24,7 @@ const (
|
|||
)
|
||||
|
||||
func NewRuleTargetAxis(device_name string,
|
||||
device *evdev.InputDevice,
|
||||
device RuleTargetDevice,
|
||||
axis evdev.EvCode,
|
||||
inverted bool,
|
||||
deadzoneStart int32,
|
||||
|
@ -83,8 +82,7 @@ func (target *RuleTargetAxis) NormalizeValue(value int32) int32 {
|
|||
}
|
||||
|
||||
func (target *RuleTargetAxis) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
// TODO: we can use the axis begin/end to decide whether to emit the event
|
||||
// TODO: oh no we need center deadzones actually...
|
||||
value = ClampInt(value, MinAxisValue, MaxAxisValue)
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_ABS,
|
||||
Code: target.Axis,
|
||||
|
@ -92,9 +90,9 @@ func (target *RuleTargetAxis) CreateEvent(value int32, mode *string) *evdev.Inpu
|
|||
}
|
||||
}
|
||||
|
||||
func (target *RuleTargetAxis) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent) bool {
|
||||
func (target *RuleTargetAxis) MatchEvent(device RuleTargetDevice, event *evdev.InputEvent) bool {
|
||||
return device == target.Device &&
|
||||
event.Type == evdev.EV_ABS &&
|
||||
event.Code == target.Axis &&
|
||||
(event.Value <= target.DeadzoneStart || event.Value >= target.DeadzoneEnd)
|
||||
(event.Value < target.DeadzoneStart || event.Value > target.DeadzoneEnd)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue