This is no longer needed. Use the device-iterator in ratbagd.c directly
and then drop ratbagd_device_list().
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add helper to retrieve the device path from outside of ratbagd-device.c.
This will be needed for the non-object-manager based enumerators and
signals introduced to org.freedesktop.ratbag1.Manager.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Profiles are static children of devices. Expose them as 2nd-level objects
underneath their parent devices on the bus.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Make sure the device management (lookup and enumeration and registration)
is done from the parent, not the child. Hence, move it into ratbagd.c over
ratbagd-device.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Make sure our dbus callbacks to not contain any logic themselves. They
should be simple wrappers around our internal object handling.
This also makes use of the new sd-bus pat helpers, to-be-released with
systemd-v227 next week.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This does not work, we cannot flag properties as UNPRIVILEGED. Drop it.
Lets figure out later what exactly we want as privilege level to
enumerate and query device properties.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add two device properties:
- Id: Returns the string ID to identify the device
- Description: Returns the ratbag-device name
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Make sure to create libratbag_device contexts for each device we add. If
libratbag returns NULL, we just ignore the devices. Otherwise, we keep
the context around and manage the device.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Make sure the ratbagd context has a reference to a valid libratbag
context at all times. We need this to access libratbag devices, so lets
reference on in our own context.
This also adds a dependency for libratbag via autotools.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add safe_close() helper that makes close(2) a bit nicer to use. This also
introduces PROTECT_ERRNO, which makes sure a function does not clutter
errno if called.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This adds two new components:
1) ratbagd
The ratbagd daemon is a very basic dbus daemon that provides an
org.freedesktop.DBus.ObjectManager based enumeration and modification
API for libratbag devices. So far, all it does is enumerate input
devices on the bus. However, this will be extended to advertise full
libratbag hierarchies on the bus and allow clients to modify
properties via DBus.
So far, it is root-only, but the DBus policy can be losened and PolKit
support can be added.
2) ratbagctl
A very basic command-line tool to manage ratbagd. It's basically a
command-line interface for the DBus API of ratbagd.
So far, it has no hookup for anything. This will be added once ratbagd
gains further DBus APIs.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Command 0xA2 (Read Sector) takes only a one byte argument for the offset
(entry in the documentation).
Clean up the code and return an error if the page (sector in the doc)
is invalid (to avoid querying the device which would output an
ERR_INVALID_VALUE).
Fixes#15
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Initial commit for the ratbagd project, a dbus daemon to manage libratbag
devices and proxy user accesses.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This is for the best case where it's just about adding a new device ID. In the
case where reverse engineering is required, some more detailed instructions
are necessary but they take more effort to write...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If the time is not given in the macro, the device still accepts it and
works properly by setting 10 ms of delay after a key press and 50 ms
between the keys.
Problem is: without this, the RATBAG_MACRO_EVENT_WAIT is not set during
parsing, so we end up having a RATBAG_MACRO_EVENT_NONE between 2 key
events, and the library ends up truncating the macro after the first
RATBAG_MACRO_EVENT_NONE.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Might not be the best solution for hidpp10, because it just removes the
duplicates, but this way all of the other drivers can benefit from the
raw debug parameter.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
For supported devices this can get and set the led colors in RGB.
This patch just adds the support in the lib. Later patches will
add it to the driver and expose it in libratbag.
On the M705 I frequently get usb timeouts here if the device has
not been active for a while. Retrying after 10 ms seems to reliably
fix the timeout problem.
We could have just added the 10 ms sleep directly but it does not
seem to be neccesary on wired devices so I chose not to. Setting the
ret value to a face positive number and looping would also work but
we risk an endless loop. In the end I just went for a single retry
as that fixed the problem for me.
When writing a button, the given button should also be stored in the
memory of the device.
Amend the documentation
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
we should not require to actually write the profile to actually write the
button in the memory of the device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If there is any problem while retrieving a macro, the first element in
the report might not match. In such cases, abort.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>