* tools: canonicalize path first in udev_device_from_path
This fixes a problem in which running ratbag-command with the path to a
device node symlink (e.g. /dev/logi-g502 -> /dev/input/event4), such as
one created by a udev rule, would not work correctly, due to the code
failing to resolve the symlink prior to checking for the presence of the
"/dev/input/event" prefix.
This resulted in nonsensical error messages (shown below) and the
curious inability to run ratbag-command successfully with anything but
the actual raw path to the device node itself (e.g. /dev/input/event4
would work fine, but /dev/logi-g502 would not, despite both being valid
ways of getting to the same device node).
Error: Can't open '/dev/logi-g502': Success
Error: Device '/dev/logi-g502' is not supported
Note that this same problem also prevented the usage of autogenerated
symlinks by udev, i.e. '/dev/input/by-id/' and '/dev/input/by-path/'.
* Update tools/shared.c
Co-Authored-By: jgottula <justin@jgottula.com>
A driver is supposed to know what type an LED is, unknown doesn't help anyone
here. So replace this with a private #define and abort when a driver doesn't
set the type. This also adds a requirement that any driver initializing a LED
must have the read_led() function, otherwise we can't fill it in correctly.
And bump the enum up by one, the first valid value should start at 1 (or some
other non-boolean value).
Related #365Fixes#364
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Rename "breath" in the help text and reporting for the led mode to
"breathing". The actual command to set the mode was already called
that way.
Signed-off-by: Christian Kellner <christian@kellner.me>
../tools/shared.c:132:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
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>
Setting the special command and displaying it were using a different
spelling. Fix that.
We should really only have one entry point for that.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_ALTERNATE (for the "sniper switch")
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_DEFAULT -> means what it means
And fix one missing entry in str_to_special_action.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Blows up when sprintf encounters an error, the result string is empty or the
result string is truncated.
Note: sprintf_safe only works on static buffers, it uses ARRAY_LENGTH.
Fixes#14
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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 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>