Commit Graph

1256 Commits

Author SHA1 Message Date
Peter Hutterer
432d32bedc ratbagd: set the active profile before sending signals
Found by @bentiss, see #295

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-31 13:08:41 +10:00
Peter Hutterer
8cb2d21ff5 Remove unnecessary NULL check before free()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-31 13:03:07 +10:00
Peter Hutterer
1103c208a8 ratbagd: if the svg doesn't exist, supply the fallback one
We keep the hardcoded fallback.svg for the test device, otherwise we get an
error every time we start ratbagd.devel

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-31 10:48:38 +10:00
Peter Hutterer
7e59f0f974 data: add a fallback.svg file
This SVG is generic enough to cover 7-button mice with up to 3 LEDs that are
supported but don't have an SVG. The SVG style is intentionally NOT a generic
mouse to make it obvious that something isn't right here. If we use a generic
mouse, people may not put the effort into a proper SVG style because the
generic mouse is good enough.

The fallback is currently only used for test devices
2017-08-31 10:48:38 +10:00
Benjamin Tissoires
c647d6df99 profiles: add name get/set capability
Some devices can have a custom name, so let's export that capability.

In ratbagd, libratbag/ratbag_profile_set_name() returns an error, we
put it under silence, the client has to check for the capabilities
before asking ratbagd to change the profile name.

Fixes: #266

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-31 10:22:51 +10:00
Benjamin Tissoires
97a927bb7d profiles: add a per profile capabilities field
Doesn't do much now without the next commit

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-31 10:22:51 +10:00
Benjamin Tissoires
7c650aeeca tools: ratbagctl: add "name" command to return the device name
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-31 10:22:51 +10:00
Thomas Hindoe Paaboel Andersen
3fd7cd0137 improve error for missing device files 2017-08-31 08:17:15 +10:00
Thomas Hindoe Paaboel Andersen
7e97936f0e reset GError before reuse
If the error variable is not reset then we may end up freeing it
again in the next block. This can cause problems later for glib.

Fixes #311
2017-08-31 08:07:19 +10:00
Peter Hutterer
643a4a89f4 ratbagd: fix assertion error when quitting with more than 1 devices attached
RATBAGD_FOREACH_DEVICE does not allow unlinking the device during the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-30 09:42:47 +10:00
Peter Hutterer
cfd93cf332 drop now obsolete ratbag_device_get_udev_property
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 17:50:20 +02:00
Peter Hutterer
340e5b7d86 Switch to a .ini-file based device database
The hwdb was a quick and easy way to add entries for new devices but we need
more and more info about the various types of devices. It's better to move
this to a proper database.

Side-effect: this also gives us an easy way to point to the list of devices
supported and makes checking for e.g. missing svgs easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 17:50:20 +02:00
Peter Hutterer
be624fe943 Move dpi range parsing to a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 17:50:20 +02:00
Peter Hutterer
cb102e115c Add xasprintf
Like asprintf, but leaves strp as NULL on failure

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 17:50:20 +02:00
Clément Vuchener
952eb1cf0e Add Logitech G900 SVG for gnome theme 2017-08-28 12:16:49 +02:00
Peter Hutterer
709ffa37b2 hwdb: add two missing driver assignments
We have autodetection for Logitech, but let's always specify the driver for
devices we have in the hwdb.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 09:18:00 +02:00
Peter Hutterer
f4f206f3e5 Add missing config.h includes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-28 09:18:00 +02:00
Peter Hutterer
7036428066 meson.build: libratbag 0.9.900
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
v0.9.900
2017-08-25 13:48:39 +10:00
Peter Hutterer
18239f1aee DBusInterface: add missing 'Methods' header
And consistently use ':' after Properties/Methods headers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-24 09:25:29 +10:00
Benjamin Tissoires
fe8fde79f6 tools: ratbagctl: fix len(array) > 0 check
"for python, instead of checking len > 0 we're supposed to use
if input_string"

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 09:28:07 +02:00
Peter Hutterer
9f805a4ebe tools: don't return a ratbagd_process if things failed
If we couldn't find the name on the bus or the ratbagd process already
terminated, return None and fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-23 08:05:17 +02:00
Peter Hutterer
572f00cf2a Add GNOME svg for Roccat Kone XTD 2017-08-23 08:04:12 +02:00
Benjamin Tissoires
330b4641ad tools: ratbagctl: have a full description of the commands in the usage
I originally intended to have a dynamic use of argparse to generate
the commands, but it turned out to be a nightmare.

Just go down the tree of arguments and format the help properly.

Fixes #288

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
c1c8b1eda2 tools: ratbagctl: fixes for parsing arguments
We shouldn't try to access input_string[0] if len(input_string) is null.
Meaning a condition in the break in the while loop could be checked
earlier (or later).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
aa251448d3 tools: rabtagctl.devel: only output the dbus name when using keepalive
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
e27b1eb99f tools: ratbagctl: remove useless try/catch
ns is never reset, so once it has a subparser, it'll keep it, so the try
catch is just too much

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
faaf93b194 tools: ratbagctl: kill an infinite loop in parsing
Calling "ratbagctl profile -t" resulted in an infinite loop because it
tried again and again to parse "-t" in the profile

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
58957667e1 tools: ratbagctl: shout the usage if the parsing is incomplete
Too easy to trigger ("ratbagctl.devel profile" is just enough), so we
probably better have a proper usage call here.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
0db7ba0c85 tools: ratbagctl: rename .parse into add_to_subparsers
.parse did not consumed the input_string, it only appends the given
parsing to the parent. Rename the function and kill the debug output
in nested calls as this was misleading while re-reading the code.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
c42c15ad0e tools: ratbagctl: have the global options global
The help option (or verbose FWIW) were not global which makes some random
behavior when using -h at different places for the input string.

Retrieve those options once and remove them from the list of things to
process.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
fc50e38ae2 tools: ratbagctl.devel: honor --help too
Now that ratbagctl properly shows the help, the devel version should
too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Benjamin Tissoires
b2d29a0285 tools: ratbagctl.devel: fix exception if the given arguments are wrong
"sudo ./build/ratbagctl.devel profile 2 4" returns an exception with cmd
being unknown.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-23 14:25:35 +10:00
Peter Hutterer
87ecd6e252 tools: add --keepalive option to ratbagd devel
Keeps the ratbagd daemon running until a signal is received. This is helpful
for using an external client (like piper) to run against the ratbagd.devel
instance. And to make that even easier, print the RATBAGCTL_DEVEL environment
variable for use with ratbagd.py. In the future, this should probably be a
more generic name.

The integration is a bit odd because we need to add --keepalive to the actual
parser, but we recreate that on every parse() call. So we set a flag on the
parent object and check for that during parser creation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-22 08:17:21 +02:00
Peter Hutterer
2b49550b9b tools: ratbagctl: skip on AttributeError exception handling for --help
We default to False anyway, so it's guaranteed to be an attribute on the
parser

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-22 08:17:21 +02:00
Jente Hidskes
6ddba76c93 RatbagdButton: make mapping properties writable
This brings RatbagdButton in line with the other Ratbagd* objects, and
more importantly solves https://github.com/libratbag/piper/issues/140.
2017-08-22 10:22:51 +10:00
Peter Hutterer
d9e7298aee ratbagctl: improve the top-level --help output
Don't automatically handle the help output - call print_help() on the parser
manually.

It's unclear why this doesn't just get called correctly, but at least this
fixes the immediate issue. The subcommand help is still pretty terrible
though.

https://github.com/libratbag/libratbag/issues/288

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-21 11:06:32 +02:00
Clément Vuchener
49b7029506 hidpp: Fix error string array size
Extend error strings array so reading 0xFF as an error code would not overflow.
2017-08-18 04:26:50 +10:00
Clément Vuchener
468787601e hidpp: Distinguish 1.0 and 2.0 error codes 2017-08-18 04:26:50 +10:00
Jente Hidskes
804d8f7969 RatbagdResolution: emit properties changed from resolution_set_default
This allows clients to respond to changes in the default resolution. It's
not the cleanest approach, but it works. To clean it up, we could cache
the changed resolutions and make sure to only emit the signal on those,
just as the FIXME already notes.

References https://github.com/libratbag/piper/pull/36.
2017-08-17 10:35:09 +10:00
Jente Hidskes
9b53119121 RatbagdResolution: emit properties changed from resolution_set_active
This allows clients to respond to changes in the active resolution. It's
not the cleanest approach, but it works. To clean it up, we could cache
the changed resolutions and make sure to only emit the signal on those,
just as the FIXME already notes.

References https://github.com/libratbag/piper/pull/132.
2017-08-17 10:35:09 +10:00
Jente Hidskes
b773ac085b ratbagd.c: unlink before emitting property changed 2017-08-11 11:12:24 +01:00
Peter Hutterer
13419dcbb8 doc: drop documentation
Our DBus interface is the only API now and libratbag is just the internal
library. Let's not build doxygen for it, there's no need.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-02 10:14:23 +01:00
Benjamin Tissoires
c9322fa983 tools: ratbagctl.devel: do not spawn a subprocess to run a python script
We do not really care using the actual ratbagctl command, we just want
to run it. So we can simply call out the python functions directly
and live happily ever after.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-01 10:31:43 +01:00
Benjamin Tissoires
6cfca9e34b tools: share the devel boiler plate in a separate python file
We want to share as much as possible between ratbagctl.devel and
ratbagctl.test, so better have a separate file that knows how to
properly spawn the dbus daemon and terminate it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-08-01 10:31:43 +01:00
Jente Hidskes
282398493b ratbagd_button: emit property changed on ActionType when setting mappings 2017-07-31 14:38:24 +01:00
Jente Hidskes
022dc74354 ratbagd_button: emit property changed on Macro 2017-07-31 14:38:24 +01:00
Jente Hidskes
cd6ffca413 ratbagd_button: emit property changed on KeyMapping 2017-07-31 14:38:24 +01:00
Jente Hidskes
b19a6ebcfc DBusInterface: document Macro and SetMacro 2017-07-31 14:38:24 +01:00
Peter Hutterer
811281372b ratbagd: fix return code for SetSpecialMapping (#262)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-30 14:23:25 +02:00
Benjamin Tissoires
c361b8500f test: make sure the dbus daemon is available before starting the test suite
On CircleCI, the builds fail one over four times because we are launching
the testsuite while ratbagd.devel is still not ready.

Do a basic polling after we launch the daemon so that we are aware when
the ratbagd daemon is ready.

A proper solution would be to use "new" for querying the proxy, not
"new_sync". However, this would require us to have a GTK mainloop
running, so it's a PITA.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-07-29 09:05:43 +01:00