Big Refactor (#2)
Refactor Everything. Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com> Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
parent
a0949e719f
commit
ff38db6596
21 changed files with 413 additions and 309 deletions
40
internal/mappingrules/mapping_rule_mode_select.go
Normal file
40
internal/mappingrules/mapping_rule_mode_select.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package mappingrules
|
||||
|
||||
import "github.com/holoplot/go-evdev"
|
||||
|
||||
type MappingRuleModeSelect struct {
|
||||
MappingRuleBase
|
||||
Input *RuleTargetButton
|
||||
Output *RuleTargetModeSelect
|
||||
}
|
||||
|
||||
func NewMappingRuleModeSelect(
|
||||
base MappingRuleBase,
|
||||
input *RuleTargetButton,
|
||||
output *RuleTargetModeSelect,
|
||||
) *MappingRuleModeSelect {
|
||||
|
||||
return &MappingRuleModeSelect{
|
||||
MappingRuleBase: base,
|
||||
Input: input,
|
||||
Output: output,
|
||||
}
|
||||
}
|
||||
|
||||
func (rule *MappingRuleModeSelect) 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.Device ||
|
||||
event.Code != rule.Input.Button ||
|
||||
rule.Input.NormalizeValue(event.Value) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, rule.Output.CreateEvent(event.Value, mode)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue