The onboard profile do not store the current value but the default.
To retrieve the current value, we need to access the switchable resolution
feature.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The G900 advertises 5 profiles, which do not fit in only 16 bytes.
We need to read at least 32 bytes, so be it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The device can report how much rom it has through profile_count_oob.
Make sure we have something in ROM before accessing it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If the macro has not been retrieved, it's more likely that the button
is not bound to anything.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
A negative error means a communication error, while a positive one means
a HID++ one. Make sure we abort early enough.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
rc is set to 0 by ratbag_open_hidraw_node(), and if matched failed, we
close the hidraw node and end the loop.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Once we start probing devices for multiple drivers we shouldn't just print
error messages for every failed driver. In the hidpp20 case an error would be
printed for any hidpp10 logitech device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If a device is not specifically assigned a driver, try hidpp20 and then
hidpp10 hoping that one of them will work.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Prep work for being able to probe multiple drivers on a device. The function
that tests the actual driver simply takes a const char * with the driver name,
so in the future we can loop through multiple driver names easily.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
No need for two separate cleanup blocks, they're doing the same thing anyway.
Just make the function more robust to uninitalized fields and we're good to
go.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
hidpp10 devices have their own driver, let's not initialize them here and just
fail. If a hidpp10 device is assigned the hidpp20 driver this is a bug.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
No reason for the drivers to have their own printf each, just return the
negative errno and let the common code print it.
This now also means that we only return -ENODEV on something that's not really
an error, for anything else we print the strerror.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We now get an error message for all devices that have duplicate event nodes
because we use -ENODEV for 'device not found', 'device is a duplicates' and
'device doesn't have the hidraw report'.
The original commit was triggered by a misunderstanding of the error message,
will be fixed in a follow-up.
This reverts commit 855a6bd831.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit b3237fd0 ("lur: change new_from_hidraw to return an errno") broke
the API, so we need to bump the version too.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Otherwise, as soon as we set an action for a button, we get a nice
invalid free on cleanup.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The previous API was inconsistent and different to the rest of libratbag's
API. Replace with one where a macro is a separate struct, can be initialized
and then written to the device with a set_macro() call. The device copies the
contents, the macro is otherwise unmodified and can be re-used by the client
if need be.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We don't do anything with the return value anyway and we do assign the driver
in this function. Rename it and return a boolean only.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Whenever we do something that may fail, return an enum of possible errors.
This also changes the API for ratbag_device_new_from_udev_device() to return
an error code now too instead of just NULL on failure.
Error numbers start at -1000 to avoid overlap with errnos, error_code() should
be used internally to avoid returning an errno.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Let the caller check that what they're passing in is correct, we don't have to
respond with sensible error codes here.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Designates a device that can be queried for the current configuration. Some
devices lack this ability so we rely on the caller to upload a known
configuration to the device before we can really proceed.
Set by default, devices without that capability should be the exception, not
the norm.
This patch just adds the capability, actual handling for this needs to be
added when we add the first device without this capability.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
On the G9 the response to a 0x63 is a short report. The G9 does
not have individual resolutions for X and Y and thus only needs
to report a single value.
The set version of 0x63 should probably also be updated. However,
while my testing of such a change worked better than with long
reports there are still strange side effects of setting resolution,
like turning off all the LED's. LGS also seems to do a full profile
read/write instead of using 0x63 when changing the resolution.
The G303 shares the same profile than the G402/G502. The only difference
is an extension at the end of the profile, but they are compatible.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Mostly inherited from our zalloc() implementation. But really,
if you have no memory left, should you be trying to talk to receivers?
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>