Allow all buttons and axes on virtual devices to be specified by either number or an explicit list. #5

Merged
anna merged 8 commits from device-config into main 2025-07-17 20:04:21 +00:00
Showing only changes of commit 72d0d21e18 - Show all commits

View file

@ -17,7 +17,7 @@ func TestRunnerDevicesConfig(t *testing.T) {
func (t *DevicesConfigTests) TestMakeAxes() {
t.Run("8 axes", func() {
axes := makeAxes(8)
axes := makeAxes(8, []string{})
t.Equal(8, len(axes))
t.Contains(axes, evdev.EvCode(evdev.ABS_X))
t.Contains(axes, evdev.EvCode(evdev.ABS_Y))
@ -30,12 +30,12 @@ func (t *DevicesConfigTests) TestMakeAxes() {
})
t.Run("9 axes is truncated", func() {
axes := makeAxes(9)
axes := makeAxes(9, []string{})
t.Equal(8, len(axes))
})
t.Run("3 axes", func() {
axes := makeAxes(3)
axes := makeAxes(3, []string{})
t.Equal(3, len(axes))
t.Contains(axes, evdev.EvCode(evdev.ABS_X))
t.Contains(axes, evdev.EvCode(evdev.ABS_Y))
@ -45,17 +45,17 @@ func (t *DevicesConfigTests) TestMakeAxes() {
func (t *DevicesConfigTests) TestMakeButtons() {
t.Run("Maximum buttons", func() {
buttons := makeButtons(VirtualDeviceMaxButtons)
buttons := makeButtons(VirtualDeviceMaxButtons, []string{})
t.Equal(VirtualDeviceMaxButtons, len(buttons))
})
t.Run("Truncated buttons", func() {
buttons := makeButtons(VirtualDeviceMaxButtons + 1)
buttons := makeButtons(VirtualDeviceMaxButtons+1, []string{})
t.Equal(VirtualDeviceMaxButtons, len(buttons))
})
t.Run("16 buttons", func() {
buttons := makeButtons(16)
buttons := makeButtons(16, []string{})
t.Equal(16, len(buttons))
t.Contains(buttons, evdev.EvCode(evdev.BTN_DEAD))
t.NotContains(buttons, evdev.EvCode(evdev.BTN_TRIGGER_HAPPY))