Completed implementation.

This commit is contained in:
Anna Rose Wiggins 2025-07-15 15:27:49 -04:00
parent 0915ea059a
commit 58abd4cc34
10 changed files with 260 additions and 66 deletions

View file

@ -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
}

View file

@ -16,12 +16,13 @@ type Config struct {
}
type DeviceConfig struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
DeviceName string `yaml:"device_name,omitempty"`
Uuid string `yaml:"uuid,omitempty"`
Buttons int `yaml:"buttons,omitempty"`
Axes int `yaml:"axes,omitempty"`
Name string `yaml:"name"`
Type string `yaml:"type"`
DeviceName string `yaml:"device_name,omitempty"`
Uuid string `yaml:"uuid,omitempty"`
Buttons int `yaml:"buttons,omitempty"`
Axes int `yaml:"axes,omitempty"`
RelativeAxes []string `yaml:"rel_axes,omitempty"`
}
type RuleConfig struct {