mechanical patch
the hidraw_fd should only be used in libratbag_hidraw, so better having
it in its own struct so we can extend the hidraw elements without touching
ratbag_device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
# Conflicts:
# src/libratbag-hidraw.c
This driver is basically a duplicate of the Etekcity.
After the copy-paste, I renamed all the the "etekcity"
by "roccat" and then rev-engineered the various constants.
Still a WIP, but it is getting usable.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The G303 is a wired device and we need to talk to it with 0xff (OK a
#define would be good). This was not a problem for all of the unifying
devices given that the kernel overwrites the device_id for us, but the
corded devices are a different kind, and this one rejects device id != ff.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Don't use a default here, let the compiler tell us when we're not handling a
value expclicitly.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The current code was checking if the previous action assigned to a button
was a macro, not that the action we are assigning will be a macro.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
The doctext needs fixes and the API might not be final.
This however works and allow to read the macro.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
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>
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>