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
|
@ -35,6 +35,7 @@ func (parser *ConfigParser) CreateVirtualDevices() map[string]*evdev.InputDevice
|
|||
map[evdev.EvType][]evdev.EvCode{
|
||||
evdev.EV_KEY: makeButtons(int(deviceConfig.Buttons)),
|
||||
evdev.EV_ABS: makeAxes(int(deviceConfig.Axes)),
|
||||
evdev.EV_REL: makeRelativeAxes(deviceConfig.RelativeAxes),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -116,3 +117,20 @@ func makeAxes(numAxes int) []evdev.EvCode {
|
|||
|
||||
return axes
|
||||
}
|
||||
|
||||
func makeRelativeAxes(axes []string) []evdev.EvCode {
|
||||
codes := make([]evdev.EvCode, 0)
|
||||
|
||||
for _, axis := range axes {
|
||||
code, ok := evdev.RELFromString[axis]
|
||||
|
||||
if !ok {
|
||||
logger.Logf("Relative axis '%s' invalid. Skipping.", axis)
|
||||
continue
|
||||
}
|
||||
|
||||
codes = append(codes, code)
|
||||
}
|
||||
|
||||
return codes
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue