Start rulemapping refactor to be more explicit about typing intentions.
This commit is contained in:
parent
08fc828b46
commit
a0949e719f
10 changed files with 128 additions and 100 deletions
23
internal/mappingrules/mapping_rule_button.go
Normal file
23
internal/mappingrules/mapping_rule_button.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package mappingrules
|
||||
|
||||
import "github.com/holoplot/go-evdev"
|
||||
|
||||
// A Simple Mapping Rule can map a button to a button or an axis to an axis.
|
||||
type MappingRuleButton struct {
|
||||
MappingRuleBase
|
||||
Input *RuleTargetButton
|
||||
Output *RuleTargetButton
|
||||
}
|
||||
|
||||
func (rule *MappingRuleButton) MatchEvent(device *evdev.InputDevice, event *evdev.InputEvent, mode *string) (*evdev.InputDevice, *evdev.InputEvent) {
|
||||
if !rule.MappingRuleBase.modeCheck(mode) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if device != rule.Input.GetDevice() ||
|
||||
event.Code != rule.Input.GetCode() {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return rule.Output.Device, rule.Output.CreateEvent(rule.Input.NormalizeValue(event.Value), mode)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue