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:
parent
ff38db6596
commit
e617a6eda6
25 changed files with 903 additions and 130 deletions
46
internal/mappingrules/rule_target_relaxis.go
Normal file
46
internal/mappingrules/rule_target_relaxis.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package mappingrules
|
||||
|
||||
import (
|
||||
"github.com/holoplot/go-evdev"
|
||||
)
|
||||
|
||||
type RuleTargetRelaxis struct {
|
||||
DeviceName string
|
||||
Device RuleTargetDevice
|
||||
Axis evdev.EvCode
|
||||
Inverted bool
|
||||
}
|
||||
|
||||
func NewRuleTargetRelaxis(device_name string,
|
||||
device RuleTargetDevice,
|
||||
axis evdev.EvCode,
|
||||
inverted bool) (*RuleTargetRelaxis, error) {
|
||||
|
||||
return &RuleTargetRelaxis{
|
||||
DeviceName: device_name,
|
||||
Device: device,
|
||||
Axis: axis,
|
||||
Inverted: inverted,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NormalizeValue takes a raw input value and converts it to a value suitable for output.
|
||||
//
|
||||
// Relative axes are currently only supported for output.
|
||||
// TODO: make this have an error return?
|
||||
func (target *RuleTargetRelaxis) NormalizeValue(value int32) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (target *RuleTargetRelaxis) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_REL,
|
||||
Code: target.Axis,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
// Relative axis is only supported for output.
|
||||
func (target *RuleTargetRelaxis) MatchEvent(device RuleTargetDevice, event *evdev.InputEvent) bool {
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue