Commit Graph

337 Commits

Author SHA1 Message Date
Peter Hutterer
1d464767e1 tools: fix error code names in ratbagd.py documentation 2018-09-27 09:44:05 +10:00
Peter Hutterer
9551dddbb8 tools: handle NULL svgs in ratbag-command
Showed up in #526
https://github.com/libratbag/libratbag/issues/526#issuecomment-420016451
2018-09-27 09:39:44 +10:00
Peter Hutterer
563c274705 tools: remove the unnecessary prefix from the error code enum
It's already encoded as part of the enum, no need to have it again for the
value
2018-09-26 13:17:36 +02:00
Peter Hutterer
46d5fae2e5 tools: ratbagc - allow for the device to be just 'event7'
ratbagctl requires 'eventX' as argument, but ratbag-command requires
/dev/input/eventX. That's not smart, let's do better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-14 10:23:11 +10:00
Peter Hutterer
4b31945e1d tools: change the exception to just RatbagdUnavailable
ratbag-command has an 'except RatbagdDBusUnavailable' line despite that class
never being defined. That's ok because we'll never throw it in this case but
it's still confusing (to flake8). So let's change the class name to something
more generic and define it in ratbagc.py

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-14 10:23:11 +10:00
Peter Hutterer
7e685f5196 tools: fix flake8 warnings about missing double empty lines 2018-09-13 10:51:15 +10:00
Peter Hutterer
eb9f98e58d tools: ratbagc - set the LIBRATBAG_DATA_DIR environment before context start
This way we use the data files from the source directory, not the installed
ones.

Fixes #530

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-06 13:33:58 +02:00
Peter Hutterer
6d996bf1aa tools: add get_svg_fd() to ratbagc
Missing from 6000688c30

Fixes #31

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-06 13:33:58 +02:00
Peter Hutterer
34fbfe105c tools: return the full svg path for ratbagc get_svg()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-06 13:33:58 +02:00
Peter Hutterer
dfeac1bcbc tools: generate ratbagc.py from configuration_data()
No functional changes, this is prep work only

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-06 13:33:58 +02:00
Peter Hutterer
6000688c30 ratbagd: add GetSvgFd() to return an fd to the SVG
If we're sandboxing the client we don't have access to the SVG files directly.
So pass a read-only file descriptor to the client over DBus and let them deal
with the SVG that way.

In ratbagd.py we pull the fd off but we convert the quirky dbus error into a
normal FileNotFoundError(), much easier to catch in the caller.

On the ratbagctl side we now have to search the SVG for it's name - stored in
the 'sodipodi:docname' attribute by Inkspace. This isn't guaranteed to exist
or be always correct, but meh, it's close enough. We could continue to use the
GetSvg() call here but I want to deprecate that and remove it in the near
future.

Fixes #521

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-05 08:31:35 +10:00
Peter Hutterer
01c362eadc ratbagd: log the device list by default
Without --verbose ratbagd just starts up with no message whatsoever. It's hard
to tell if any devices are supported or if the server just hangs. Let's log
the devices detected by default, at least that way we get some feedback.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-30 08:20:23 +02:00
Peter Hutterer
f24cb6dc66 ratbagd: always return an empty list for array-like properties []
In some cases we get Piper trying to use None as a list, see
https://github.com/libratbag/piper/issues/237

This can be reproduced by returning an error (e.g. -ENOMEM) from
ratbagd_get_devices(). That error isn't handled anywhere on the client side,
the effective result is that the property is None when calling
proxy.get_cached_property().

The error is visible on the bus:

method call time=1535084121.223284 sender=:1.1311 -> destination=:1.1310
  serial=7 path=/org/freedesktop/ratbag1;
  interface=org.freedesktop.DBus.Properties; member=GetAll
  string "org.freedesktop.ratbag1.Manager"
error time=1535084121.223433 sender=:1.1310 -> destination=:1.1311
  error_name=org.freedesktop.DBus.Error.NoMemory reply_serial=7
  string "Cannot allocate memory"

Make ratbagd.py more robust here and always return an empty list for those
properties where we expect an array. This papers over the real bug which is
that a) we need better logging in ratbagd on errors and b) something on the
other side needs to handle this error.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-24 10:01:56 +02:00
Peter Hutterer
0ed621db8f tools: make the dbus directory before trying to copy to it (#517)
Popped up in https://github.com/libratbag/libratbag/pull/515

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-22 04:08:10 +01:00
Peter Hutterer
5ae473dcd1 tools: make ratbagd a bit more robust regarding None object path lists
Not sure why this is happening exactly, but it's better to handle this case
without an immdiate exception.

Fixes https://github.com/libratbag/piper/issues/228

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-20 12:53:18 +10:00
maxice8
e43cf7ab08 src/libratbag-data.c tools/lur-command.c: add missing limits.h includes (#507) 2018-08-16 12:46:36 +01:00
Gui Ambros
08f3f7daf2 Fix UTF-8 encoding on merge_ratbagd.py, per #493 2018-07-05 20:31:34 +02:00
Benjamin Tissoires
8eddf99823 circle: allow to annotate clang static analyzer false positives
https://bugs.llvm.org/show_bug.cgi?id=3888

clang analyzer doesn't know how to handle __attribute__(cleanup()).

There are only 2 warnings raised because the analyzer only look at the
current compilation unit for checking the malloc call. So only those
2 are detected by clang and then marked as memory leak.

This also means our current continuous integration doesn't check for
memory leaks.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-05-25 08:45:47 +02:00
Yanko Kaneti
02cbfc23b7 tools: Heed various PyGIDeprecationWarnings 2018-02-21 12:10:48 +10:00
Ignacio Vazquez-Abrams
573d3d399e Allow meson to skip the test that requires root if root is unavailable 2017-12-04 09:05:09 +10:00
Jente Hidskes
9b3c33a2fe Convert LED effect rate in Hz to effect duration in ms
As discussed in https://github.com/libratbag/piper/issues/175
2017-11-15 08:53:56 +01:00
Benjamin Tissoires
9c75a7cc7e tools: ratbagctl: add --nocommit
Allows to batch commands for setting multiple parameters at once.

Fixes #399

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-25 09:19:24 +02:00
Benjamin Tissoires
0337ae41ab tools: valgrind: shut up some non relevant memory leaks
Fixes #405

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-24 08:25:17 +10:00
Thomas Hindoe Paaboel Andersen
790c5e90bd add RATBAG_LED_TYPE_SCROLL_WHEEL 2017-10-18 00:19:12 +02:00
Peter Hutterer
cb4be02a56 tools: add 'rate get-all' to the resolutions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-17 10:55:14 +02:00
Peter Hutterer
ec7bb2f63a Add list of report rates to the resolutions
Same blueprint as the list of DPI values

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-17 10:55:14 +02:00
Peter Hutterer
55682c3a5d tools: add dpi get-all to the ratbagctl man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-17 10:55:14 +02:00
Peter Hutterer
03c264cec1 tools: remove erroneous 'self' in function call
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-17 10:55:14 +02:00
Benjamin Tissoires
366fbc3fda Fix some flake8 warnings
$> flake8-3 tools/ratbagctl.devel.in tools/ratbagctl.in tools/ratbagctl.test.in .
tools/ratbagctl.in:166:1: E302 expected 2 blank lines, found 1
tools/ratbagctl.in:173:25: E201 whitespace after '['
tools/ratbagctl.in:173:68: E202 whitespace before ']'
tools/ratbagctl.in:314:1: E302 expected 2 blank lines, found 1
tools/ratbagctl.in:318:1: E302 expected 2 blank lines, found 1
tools/ratbagctl.test.in:281:43: E261 at least two spaces before inline comment
tools/ratbagctl.test.in:302:31: E261 at least two spaces before inline comment
tools/ratbagctl.test.in:306:43: E261 at least two spaces before inline comment
tools/ratbagctl.test.in:337:43: E261 at least two spaces before inline comment
tools/ratbagctl.test.in:576:1: E302 expected 2 blank lines, found 1

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
f1d20f1f35 tools: ratbag-command.py: fix new resolutions list
This one gets a little bit meesy given that the libratbag expects a
C array. Provide some wrapping aound it and hope we won't have to
do it again and again.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
558f59b52c tools: replace ratbag-command.c with ratbag-command.py
Let the .c file die, and try to maintain the python version only.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
1a3ef63519 tools: ratbag-command.py: add verbose mode
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
17380baae9 tools: ratbag-command.py: lazy evaluation of the devices
We do not need to parse all the devices, but only the one given in the
command line. Make ratbagc.py handle this case properly.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
314c3e2f78 ratbag-command.py: allow valgrind to show something useful
sudo valgrind --suppressions=./tools/valgrind-ratbag-command.supp \
              --leak-check=full \
              python3 ./build/ratbag-command.py

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
1148d172b5 Generate a direct python wrapper around libratbag with swig
And use it to create ratabg-command.py

Benefits are that we bypass ratbagd, meaning we can attach gdb or run
valgrind on the tools themselves.

Problem is the python wrapper doesn't clean up after itself, and so
running valgrind is moot

Fixes #274

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 19:06:57 +02:00
Benjamin Tissoires
a930cdad87 ratbagctl: update man
Should be closer to the truth now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-16 12:02:56 +02:00
Peter Hutterer
b951d83a64 Add ratbagd_led_has_mode() and the required dbus additions
To be able to query which modes are available.

Exposed via ratbagctl as
./build/ratbagctl.devel led 0 capabilities event4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-16 08:47:32 +10:00
Peter Hutterer
251efd3b40 tools: add dpi get-all to ratbagctl
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-13 17:46:05 +02:00
Peter Hutterer
f592cabcd7 Replace the resolutions min/max with an explicit list of dpi values
Previously, we could get a min/max value but there was no guarantee that it
any value in between would actually work on the device. Some devices have a
discrete number of resolutions (e.g. 500, 1000, 2000, 2500), most others have
at least a minimum step size (so 1234 isn't a valid dpi value).

Change the min/max to a discrete list of which resolutions are supported. This
allows a UI to adjust its interface dynamically - e.g. a combobox if there are
only 3 resolutions or a slider if there are a million of them.

This is a DBus API break

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-13 17:46:05 +02:00
Peter Hutterer
a58096fade tools: always print 'dpi' after resolutions
We printed '500' but '500x500dpi', let's make this consistent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-13 17:46:05 +02:00
Benjamin Tissoires
5c71f9552d tools: ratbagctl: make flake8 happy
tools/ratbagctl.in:146:92: E128 continuation line under-indented for visual indent
tools/ratbagctl.in:147:92: E126 continuation line over-indented for hanging indent
tools/ratbagctl.in:154:91: E128 continuation line under-indented for visual indent
tools/ratbagctl.in:155:91: E126 continuation line over-indented for hanging indent
tools/ratbagctl.in:161:118: E128 continuation line under-indented for visual indent
tools/ratbagctl.in:162:118: E126 continuation line over-indented for hanging indent

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-09 19:17:32 +02:00
Benjamin Tissoires
c3be9e1af1 tools: ratbagctl: add missing led types
Or the G502 fails while reading the LEDs

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-10-09 19:14:04 +02:00
Peter Hutterer
186d626c40 Remove RATBAG_LED_TYPE_UNKNOWN from the enum list
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 #365
Fixes #364

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-09 19:12:17 +02:00
Peter Hutterer
d26d5b83f1 test: set RATBAG_TEST in code, not in meson
It's a fixed value so it's much easier to set this in the test binaries rather
than requiring the user to set this in the env before running a test manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-04 18:53:25 +10:00
Peter Hutterer
c401414310 tools: update ratbagd.py for the new logo types
Added in 835a694c4b

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-04 10:13:53 +10:00
Ogier Bouvier
8edf6e7609 tools: use new RATBAG_LED_TYPEs
Signed-off-by: Ogier Bouvier <obouvier@logitech.com>
2017-10-03 19:48:32 +10:00
Peter Hutterer
186a1deda8 led: change RGB to RGB888 and add 1-bit RGB
1-bit RGB is needed for the Logitech G300, let's rename the main RGB to
indicate how many bits we actually have.

See #335

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-03 08:58:34 +02:00
Peter Hutterer
f62940c1e5 tools: specify the full path for the dbus permissions file
Since we unconditionally call unlink() on that path later, let's make sure
we actually copy to that file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-02 10:25:24 +02:00
Peter Hutterer
0f808ed387 tools: fix a linebreak to be less confusing
We os.path.join the first to arguments, fix the line breaks so this is obvious

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-02 10:25:24 +02:00
Peter Hutterer
d8edf2d9e4 tools: unlink the dbus file if ratbagd.devel fails to start
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-02 10:25:24 +02:00