ratbag_open_hidraw is a special case of ratbag_find_hidraw() when
we do not check for the parent and we do not have a match.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
When using the same context, we do not want to open twice the same
hidraw node if two input node match it.
Store the sysname in the ratbag_device so we can check if it has been
opened previously.
Note that ratbag-command list still shows all input node as working
because we just close them as soon as we opened them.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If we want to remove the duplicate nodes opened when using
ratbag_find_hidraw(), we need to somehow keep track of all opened
ratbag_device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Some mice have a separate hid interface for configuring the advanced
features. It occurs that this is a common enough use case to be handled
directly by libratbag-hidraw instead of having a per-device quirk.
The idea is to allow opening the sibling hidraw devices during .probe()
and to give a matching callback. If the callback succeeds, then the
hidraw node will be used.
With this, one device might be opened several times, this has to be fixed
in a separate commit.
Fixes issue #19
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We want to be able to find sibling hidraw nodes. For that, we need to
open and test several different hidraw nodes. Makes the opening of a
specific hidraw node in its own function.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We were retrieving the hidraw information but did not use them.
Now the debug output "foo is device 'bar'" is only shown when there is
a match.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
libratbag.c does not need to initialize anything hidraw related, so
move out everything to libratbag-hidraw.c.
That means that calling ratbag_close_hidraw() is not a requirement
whithin the drivers to exit properly.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We are touching hidraw internals here, better having the function in
libratbag-hidraw.c.
No functional changes.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Lets use the new get_device_path() helper to allow calling show-device
without any argument. This follows what show-profile does already.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
New verb: show-profile
This simply prints a profile of a given device by querying ratbagd for
all information on the selected profile.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add a new property to profiles that exposes resolutions on the bus. We
simply expose a dictionary entry for each resolution, hence, we can
easily extend it in the future. However, we avoid the full overhead of
real dbus objects, as there is no real need for it.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Add two new helpers to query ratbagd for the object-paths of a specific
object:
GetDeviceByName: Return device given a device name
GetProfileByIndex: Return a profile given a profile index
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
We should always provide valid data if requested via Get().
Unfortunately, DBus still does not include 'maybe' types, so we just
return something that is clearly invalid data.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Two new verbs for ratbagctl:
- list-devices: list all available devices
- show-device: show detailed information about a single device
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Expose a list of profiles, including a tag for the active profile, from
within each ratbagd device via DBus.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Never return information about non-existant profiles. Just skip NULL
profiles silently, when iterating.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Refrain from hierarchical paths and instead use object prefixes with
unique paths each. This avoids several nasty DBus-enforced behaviors
regarding deep hierarchies. Furthermore, it keeps the names shorter,
which is always a nice side-effect.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Provide two new profile accessors that return the path and index of a
profile. This also requires us to cache the dbus path in the profile
itself.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
New helper to return the name of a device. This will be required to build
hierarchical paths in the sub-classes, like profiles.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Instead of relying on the cricket ObjectManager interface, use our own
manager interface. This gets rid of ridiculous recursive behavior of the
ObjectManager interface and instead allows us to control the behavior.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
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>