Skip to content

Added CreateDeviceOptions for Absmax, Absmin, etc... - #23

Open
Kam1ni wants to merge 1 commit into
holoplot:masterfrom
Kam1ni:master
Open

Kam1ni wants to merge 1 commit into
holoplot:masterfrom
Kam1ni:master

Conversation

@Kam1ni

@Kam1ni Kam1ni commented Oct 14, 2026 •

Copy link
Copy Markdown

I added the CreateDeviceWithOptions to for now specify Absmax, Absmin, Absfuzz and Absflat when creating a device. If any more options need to be specified in the future, you just need to include them in the CreateDeviceOptions. This makes it possible to add properties without breaking backwards compatibility.

Since CreateDeviceWithOptions does the same as CreateDevice with an empty Options object I changed it's definition to call CreateDeviceWithOptions instead.

Example usage:

options := evdev.CreateDeviceOptions{
	Absmax:  &[64]int32{},
	Absmin:  &[64]int32{},
	Absfuzz: &[64]int32{},
	Absflat: &[64]int32{},
}
absInfo, err := originalDevice.AbsInfos()
if err != nil {
	return nil, fmt.Errorf("failed to get AbsInfo\n%s", err.Error())
}
for key, val := range absInfo {
	options.Absmax[key] = val.Maximum
	options.Absmin[key] = val.Minimum
	options.Absflat[key] = val.Flat
	options.Absfuzz[key] = val.Fuzz
}

clonedDevice, err := evdev.CreateDeviceWithOptions(deviceName+" (CLONE)", inputId, capabilities, options)
if err != nil {
	return nil, fmt.Errorf("failed to create clone\n%s", err.Error())
}

#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant