Commit Graph

1475 Commits

Author SHA1 Message Date
Benjamin Tissoires
63a1202890 hidraw: remove duplicated code
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>
2015-10-07 18:46:24 -04:00
Benjamin Tissoires
13c3d9a110 hidraw: do not open twice the same hidraw node
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>
2015-10-07 18:46:19 -04:00
Benjamin Tissoires
1cbb80b7b4 keep track of opened devices
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>
2015-10-07 18:46:15 -04:00
Benjamin Tissoires
e71ac0a088 hidpp20drv: add support of Logitech G502
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:22 -04:00
Benjamin Tissoires
975c91ae54 hidraw: allow opening of sibling devices
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
ce37417525 hidraw: break ratbag_open_hidraw in two
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
abde78e6c4 hidraw: check if the hidraw node corresponds to the ratbag device
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
4538d03b36 hidraw: remove now useless storage of the udev hidraw node
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
00f8f90288 hidraw: make ratbag-hidraw responsible for all hidraw related operations
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
7dfa8cb75e hidraw: move ratbag_device_init_hidraw() in libratbag-hidraw
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
936ad60da4 remove unused parameter in ratbag_device_init_hidraw()
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:21 -04:00
David Herrmann
958e86f67e ratbagctl: pick default device if none given for show-device
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>
2015-09-29 19:02:12 +02:00
David Herrmann
acb0118897 ratbagctl: split get_profile_path()
Split get_profile_path() and provide an helper for get_device_path() on
its own.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 19:00:27 +02:00
David Herrmann
85a045c538 ratbagctl: move get_profile_path()
Move get_profile_path() up to make it available to other verbs as well.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 18:57:42 +02:00
David Herrmann
fbffe241e6 ratbagctl: add show-profile verb
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>
2015-09-29 18:56:25 +02:00
David Herrmann
765fd1565a ratbagd: expose resolutions on the bus
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>
2015-09-29 18:55:03 +02:00
David Herrmann
1a677c0b1d ratbagd: add DBus methods to retrieve object paths
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>
2015-09-29 18:53:54 +02:00
David Herrmann
eeb8788413 ratbagctl: print the default profile
Include the default profile in 'show-device' output.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 16:35:00 +02:00
David Herrmann
c24ca68d63 ratbagd: expose 'DefaultProfile'
Add a new property that exposes the default profile.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 16:34:32 +02:00
David Herrmann
e189dc3b1f ratbagd: never return ENODATA for Get()
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>
2015-09-29 16:33:30 +02:00
David Herrmann
ff8f391e91 ratbagctl: implement list-devices and show-device
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>
2015-09-29 16:23:51 +02:00
David Herrmann
0a9c2824ba ratbagd: expose profile information
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>
2015-09-29 16:23:51 +02:00
David Herrmann
dc37d3bf62 ratbagd: ignore NULL profiles
Never return information about non-existant profiles. Just skip NULL
profiles silently, when iterating.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 16:23:51 +02:00
David Herrmann
2780e6f3d7 ratbagd: simplify profile DBus paths
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>
2015-09-29 16:23:51 +02:00
David Herrmann
260df58856 ratbagd: profile profile accessors
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>
2015-09-29 16:23:51 +02:00
David Herrmann
cba28a97a0 ratbagd: add ratbagd_device_get_name()
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>
2015-09-29 16:23:51 +02:00
David Herrmann
eca2203603 ratbagd: add manager interface
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>
2015-09-29 14:09:23 +02:00
David Herrmann
e926212554 ratbagd: remove ratbagd_device_list()
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>
2015-09-29 13:25:05 +02:00
David Herrmann
65463b6efb ratbagd: add device iterator
Add iterators for ratbagd_device objects.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 13:22:13 +02:00
David Herrmann
9ac799bc95 ratbagd: add ratbagd_device_get_path()
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>
2015-09-29 13:21:27 +02:00
David Herrmann
7e4d757bdf ratbagd: cache device path
Cache device path in device->path and avoid re-calculating it all the
time.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-29 13:09:45 +02:00
David Herrmann
1a8037cd6c ratbagd: expose profiles on the bus
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>
2015-09-26 18:53:55 +02:00
David Herrmann
dbc8a37b56 ratbagd: move dbus device management
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>
2015-09-26 18:07:18 +02:00
David Herrmann
b1851ada93 ratbagd: split dbus handling from object handling
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>
2015-09-26 18:02:00 +02:00
David Herrmann
c0799b0c1d ratbagd: drop UNPRIVILEGED from properties
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>
2015-09-26 17:59:58 +02:00
David Herrmann
e461710811 ratbagd: add basic device properties
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>
2015-09-25 16:27:45 +02:00
David Herrmann
bea8e89cc7 ratbagd: create libratbag_device contexts
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>
2015-09-25 16:05:26 +02:00
David Herrmann
17d66153b0 ratbagd: ignore anything but event devices
We are only interested in evdev, so ignore anything but input-event
devices.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-25 15:57:14 +02:00
David Herrmann
8ca0c11154 ratbagd: keep libratbag context around
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>
2015-09-25 12:51:11 +02:00
David Herrmann
c4afc3d5c0 shared: add safe_close()
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>
2015-09-25 12:49:44 +02:00
David Herrmann
c22d51e439 build: be more consistent in variable names
Rename UDEV_* to LIBUDEV_* to be more consistent regarding other
pkg-build dependencies.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2015-09-25 12:35:43 +02:00
Benjamin Tissoires
0ece3c1a9e hidpp10: fix comment
Looks like the page 1 is not a RAM page but a directory, and is in the
flash too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-24 14:13:39 -04:00
David Herrmann
aa052ae005 Import initial components
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>
2015-09-24 20:05:27 +02:00
Benjamin Tissoires
c26ce20c5c hidpp10: fix reading memory
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>
2015-09-24 13:35:04 -04:00
David Herrmann
3f0b41ec3c Initialize ratbagd repository
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>
2015-09-24 16:45:22 +02:00
Peter Hutterer
ba2bf42ff5 Update TODO
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-19 06:47:02 +10:00
Peter Hutterer
a5b166c525 README: add basic instructions for adding new devices
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>
2015-09-19 06:43:54 +10:00
Peter Hutterer
f71f10277a README: add the missing extra space for monospace formatting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-19 06:23:07 +10:00
Peter Hutterer
44d0fd6d93 README.md: add semaphore build status badge
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-19 06:14:53 +10:00
Benjamin Tissoires
bb4b8d729b roccat-drv: fix macro parsing
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>
2015-09-18 11:08:37 -04:00