The current code has the profile ref the device, but the device has no back-ref to
the profile. The following code will free the profile from underneath the
client, despite the caller still having a valid ref:
p = ratbag_device_get_profile_by_index(device, 0);
ratbag_profile_ref(p);
ratbag_device_unref(device);
Fix this by not using refs internally. After probe, the device is static
anyway, so the various refs internally aren't needed. Instead, we also ref/unref
the parent struct whenever we ref/unref a struct. Thus, whenevever the device
refcount reaches zero, we know the caller has no ref active.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If a device has missing profiles, profile will be null and we will
have a segfault.
Better say that the device failed the sanity check.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Two components are added here: a test driver that takes a struct
ratbag_test_device and sets that device up as a ratbag device.
That device is returned to the tests and then checked for sanity.
The ratbag_device_new_test_device() requires the environment variable
RATBAG_TEST set, otherwise we abort. It's also 'hidden' in a separate source
file, so it won't show up in doxygen. And if the test are disabled, this
function does nothing and the test driver never gets registered.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The client-exposed API requires a valid device, but internally we can handle
NULL - this way we can hook up the test suite easier.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If the anchor of the text is on the left but the leader on the right,
there will be artefacts when changing the name. Make sure all of the
labels are prooperly set.
This forced us to also relocate the labels on the G500s and the etekcity
scroll alpha.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The etekcity seems to use the last profile as default. The G500s apparently
always comes up with the same profile but it's unclear if it's changeable.
This function may need to be removed later.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Let's not pretend we will handle out-of-memory errors correctly, and really,
it's not something we really need to be worried about.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We do not check dev for null in any of the other functions. If it
was actually null then we would also already have got a null pointer
dereference earlier in the function.
Or it leads to interesting errors when adding fields to the table
of supported devices.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This should never happen on the Etekcity Scroll Alpha, but we might end
up in a situation where this is required.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Still a mystery of what it is. Though I know how to get/set it, so let's
make it public until somebody claims what it is.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Otherwise the symbol leak test won't recognize it and fails. It's not worth
hacking up that test to avoid implementing those few, so just write them out
instead.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
etekcity suppports macros already, the other two don't. hidpp10 doesn't
support any write stuff but let's claim we do anyway.
The driver hook for this isn't ideal, read_button is called during init but
we should set all this up during probe and then use read_button exclusively to
update the button, not set the capabilities as well.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This is the physical description of the button, so there's a distinct
difference between the two, even when the logical action is the same.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Move the struct declarations together (and move ratbag_device to the ratbag
device page), have the defgroup tags at the top of the file.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
profile was already dereferenced earlier in the function and cannot
be null anyway from the current callers of the function.
Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
If we goto err early then both dev and drv_data will contain
garbage values. We free one and dereference the other. Let's
null them and add proper checks.
Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
separate x/y resolution -> check!
has_capability for resolution -> check!
sensitivity -> new item
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
It is a common pattern to have:
ratbag_resolution_init(...)
profile->resolution.modes[i].xxx = yyy;
ratbag_resolution_set_cap(&profile->resolution.modes[i], zzz)
So instead of dealing with the internal fields of profile/resolution/modes,
just return the resolution that has been initialized.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
In the end, we just ignore the sensitivity setting.
On the Etekcity, it looks like it is ignored by the mouse, or
maybe the Windows software just messes things up and should
not update the per-axis dpi when playing with sensitivity.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Currently only the hooks for x/y resolution, the rest is unimplemented. Also
the etekcity driver needs an update here.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>