Read events from multiple devices.
This commit is contained in:
parent
a5b59bf39e
commit
a078dcb193
4 changed files with 59 additions and 31 deletions
|
@ -64,6 +64,7 @@ func makeRuleTarget(targetConfig RuleTargetConfig, devs map[string]*evdev.InputD
|
|||
ruleTarget.Type = eventType
|
||||
ruleTarget.Code = eventCode
|
||||
ruleTarget.Inverted = targetConfig.Inverted
|
||||
ruleTarget.DeviceName = targetConfig.Device
|
||||
|
||||
return ruleTarget, nil
|
||||
}
|
||||
|
@ -83,8 +84,7 @@ func decodeRuleTargetValues(target RuleTargetConfig) (evdev.EvType, evdev.EvCode
|
|||
if !ok {
|
||||
return 0, 0, fmt.Errorf("skipping rule due to invalid button code '%s'", target.Button)
|
||||
}
|
||||
}
|
||||
if target.Axis != "" {
|
||||
} else if target.Axis != "" {
|
||||
eventType = evdev.EV_ABS
|
||||
eventCode, ok = evdev.ABSFromString[target.Axis]
|
||||
if !ok {
|
||||
|
|
|
@ -78,3 +78,11 @@ func (rule *ComboMappingRule) MatchEvent(device *evdev.InputDevice, event *evdev
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rule *SimpleMappingRule) OutputName() string {
|
||||
return rule.Output.DeviceName
|
||||
}
|
||||
|
||||
func (rule *ComboMappingRule) OutputName() string {
|
||||
return rule.Output.DeviceName
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import "github.com/holoplot/go-evdev"
|
|||
|
||||
type MappingRule interface {
|
||||
MatchEvent(*evdev.InputDevice, *evdev.InputEvent) *evdev.InputEvent
|
||||
OutputName() string
|
||||
}
|
||||
|
||||
// A Simple Mapping Rule can map a button to a button or an axis to an axis.
|
||||
|
@ -22,8 +23,9 @@ type ComboMappingRule struct {
|
|||
}
|
||||
|
||||
type RuleTarget struct {
|
||||
Device *evdev.InputDevice
|
||||
Type evdev.EvType
|
||||
Code evdev.EvCode
|
||||
Inverted bool
|
||||
DeviceName string
|
||||
Device *evdev.InputDevice
|
||||
Type evdev.EvType
|
||||
Code evdev.EvCode
|
||||
Inverted bool
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue