Fix up refactored rule targets.
This commit is contained in:
parent
c14ec074d1
commit
db848db810
5 changed files with 71 additions and 38 deletions
|
@ -7,6 +7,18 @@ import (
|
|||
"github.com/holoplot/go-evdev"
|
||||
)
|
||||
|
||||
func (target *RuleTargetBase) GetCode() evdev.EvCode {
|
||||
return target.Code
|
||||
}
|
||||
|
||||
func (target *RuleTargetBase) GetDeviceName() string {
|
||||
return target.DeviceName
|
||||
}
|
||||
|
||||
func (target *RuleTargetBase) GetDevice() *evdev.InputDevice {
|
||||
return target.Device
|
||||
}
|
||||
|
||||
func (target *RuleTargetButton) NormalizeValue(value int32) int32 {
|
||||
if value == 0 {
|
||||
return 1
|
||||
|
@ -14,6 +26,14 @@ func (target *RuleTargetButton) NormalizeValue(value int32) int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (target *RuleTargetButton) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_KEY,
|
||||
Code: target.Code,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (target *RuleTargetAxis) NormalizeValue(value int32) int32 {
|
||||
if !target.Inverted {
|
||||
return value
|
||||
|
@ -37,19 +57,6 @@ func (target *RuleTargetAxis) NormalizeValue(value int32) int32 {
|
|||
return value
|
||||
}
|
||||
|
||||
// RuleTargetModeSelect doesn't make sense as an input type
|
||||
func (target *RuleTargetModeSelect) NormalizeValue(value int32) int32 {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (target *RuleTargetButton) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_KEY,
|
||||
Code: target.Code,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (target *RuleTargetAxis) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
return &evdev.InputEvent{
|
||||
Type: evdev.EV_ABS,
|
||||
|
@ -58,6 +65,11 @@ func (target *RuleTargetAxis) CreateEvent(value int32, mode *string) *evdev.Inpu
|
|||
}
|
||||
}
|
||||
|
||||
// RuleTargetModeSelect doesn't make sense as an input type
|
||||
func (target *RuleTargetModeSelect) NormalizeValue(value int32) int32 {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (target *RuleTargetModeSelect) CreateEvent(value int32, mode *string) *evdev.InputEvent {
|
||||
if value == 0 {
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue