1
0
forked from drath/libratbag
Commit Graph

129 Commits

Author SHA1 Message Date
Benjamin Tissoires
c437882e96 tools: ratbag-command: info: make use of _cleanup_
Better code :)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-13 09:21:53 +02:00
Benjamin Tissoires
be1fb30751 tools: ratbag-command: fix a memory leak
valgrind complains that we did not release the profile, so we shall.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-13 09:21:53 +02:00
Peter Hutterer
c868c43179 tools: fix use of unset variable
Found in #312

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-31 09:48:52 +02:00
Benjamin Tissoires
e0e4d5062a hidpp20: fix resolution active set/get
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-07-28 16:19:26 +01:00
Benjamin Tissoires
aa50df8eaf tools: ratbag-command: fix enable/disable profiles
The usage help is wrong, it's not how it works.
It'll be too much pain to fix it the other way around, and I prefer
using "ratbag* profile N enable" than "ratbag* profile enable N".

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-07-25 11:06:59 +10:00
Peter Hutterer
37c8dec45c Fix the various scan-build warnings for dead assignments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 10:50:22 +02:00
Peter Hutterer
e311f89357 Provide a min/max dpi for the resolutions
For a GUI application like Piper, it's required that we know the range to
present to the user.

This patch includes the code for HID++ 1.0 and 2.0, other drivers need to
follow.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-29 09:07:18 +02:00
Benjamin Tissoires
dc92abb5e5 tools: replace tabs by spaces in ratbag-command usage
It's a mix of tabs and spaces. Let's use spaces to keep the formatting.

And move "switch-etekcity" back to the end, it's a special case.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-06-06 15:03:47 +02:00
Benjamin Tissoires
b0c515b59d tools: allow to set more than one setting for the LEDs
Or we will take the defaults that are not intuitive (like white color
when setting to on).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-06-06 15:03:47 +02:00
Benjamin Tissoires
b31c1d5ff3 tools: ratbag-command: have only one function to dump the LED settings
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-06-06 15:03:47 +02:00
Benjamin Tissoires
f6949458b7 tools: make led a first class citizen of ratbag-command
Allows to follow the usage message: we do not need to provide the
currently active profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-06-06 15:03:47 +02:00
Christian Kellner
c05c3dcaa3 tools: consistently call led mode "breathing"
Rename "breath" in the help text and reporting for the led mode to
"breathing". The actual command to set the mode was already called
that way.

Signed-off-by: Christian Kellner <christian@kellner.me>
2017-05-24 09:05:15 +10:00
Peter Hutterer
eb01399f26 tools: fix OOB for LED color parsing
Let's not forget about the null-terminator, he feels lonely otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-09 10:14:47 +02:00
Peter Hutterer
c815654c94 tools: add --version to ratbag-command
Behold, the glory of our version number!

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-09 09:24:41 +02:00
Peter Hutterer
1e5648b11d tools: terminate option list with a zero entry
Because, well, that's what we're supposed to do. Unless you want to think
outside the (array) box, but that has never helped anyone, has it?

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-09 09:24:41 +02:00
Peter Hutterer
0902e3420f tools: replace getopt magic number 2 with 'optional_argument'
So *that's* what 2 means...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-09 09:24:41 +02:00
Peter Hutterer
dfd2d88953 tools: fix coverity warnings
Assigned but not used.

Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-02 09:52:59 +02:00
Benjamin Tissoires
5bc4470a8c Fix warning: ‘x’ may be used uninitialized in this function
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-04-20 11:20:07 +02:00
Peter Hutterer
bb35821c45 tools: fix signed vs unsigned comparison warnings
And use this to start using C99 variable style, for pure loop variables it's
better to have them declared in the loop itself.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-03 09:55:53 +02:00
Peter Hutterer
bbec42c426 tools: include config.h for ratbag-command
And that then pulls in _GNU_SOURCE for us

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-03 09:55:53 +02:00
Peter Hutterer
f60f8a12ab tools: fix string parsing for LED colors 2017-03-31 15:07:01 +10:00
Peter Hutterer
fd348d456d tools: add missing LED_OFF switch case
And add the missing break
2017-03-31 15:07:01 +10:00
Peter Hutterer
0f73a97bc8 tools: move variable declaration up
We do C99, but not this :)
2017-03-31 15:07:01 +10:00
Peter Hutterer
7783f50110 tools: fix unused variable warnings 2017-03-31 15:07:01 +10:00
Ilia guterman
6c18b16a00 align ratbag-command usage documentation (#135) 2017-03-08 01:44:29 +02:00
Ilya Guterman
8e5ad717c4 ratbag-command: implement LED commands 2017-03-07 11:07:50 +10:00
Lyude
52d4e35192 Add the ability to enable or disable profiles
This is especially important for the mx780, so we can get rid of the
rude workaround we currently have in the driver for it.

Signed-off-by: Lyude <lyude@redhat.com>

Changes since v1:
- Just have profile enable/disable in ratbag-command
- Use bool instead of int
Changes since v2:
- Remove leftover function, whoops
- Fix leftover ints to bools
- Lots of style fixes
2016-11-16 09:45:01 +10:00
Lyude
01fcef9b9d Introduce new profile-oriented API
Almost all of the devices we've worked with here are the same: they have
some sort of profile on them, and if they don't (which is quite rare)
it's rather easy to simulate one in the driver. In fact basically all of
the device drivers in ratbag just update the profile and rewrite it on
calls to the write_resolution_dpi() and write_button() calls. This is
annoying since profile writes can take a good bit of time, and we're
wasting a lot of time with redundant profile writes that way.

During XDC this year, we came up with an idea that makes more sense: a
profile oriented API. Instead of having multiple entrypoints in the API
to writing and updating the profile we just cache all of the profile
changes until ratbag_device_commit_profiles() is called, at which point
we do a single set of writes for each profile and button that changed.

This has a lot of advantages:
- Where the profile is and is not written out to the device is now
  explicit.
- Changing attributes of each profile won't result in any sort of delay
  up until the library user commits the profiles, allowing us to avoid
  hanging the application every time a simple attribute is changed.
- We can cut down on workarounds in drivers to cater to the previous
  API.

Since this commit doesn't handle converting all of the device drivers
over to the new API, we also add a temporary wrapper for devices that
haven't yet been converted to this new API so that they're still usable.
Once all of the drivers have been converted to the new API, the wrapper
will be removed along with the internal driver API calls.

Signed-off-by: Lyude <thatslyude@gmail.com>

Changes since v1:
- has_changed→dirty
- Change namespace to LIBRATBAG_0.5.0
Changes since v2:
- Remove unneeded note about not setting dirty bit
- commit_profiles->commit
- Make FIXMEs more obvious
- Minor styling nitpicks
- Split up capability check fixes into seperate patch
2016-10-14 08:00:54 +10:00
Peter Hutterer
4054616190 Revamp the button macro code
The previous API was inconsistent and different to the rest of libratbag's
API. Replace with one where a macro is a separate struct, can be initialized
and then written to the device with a set_macro() call. The device copies the
contents, the macro is otherwise unmodified and can be re-used by the client
if need be.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-03-14 14:22:22 +10:00
Benjamin Tissoires
ff2d9713f7 Remove the default profile capability
We do not have any driver using it, and we are not sure this will even
be required. Before releasing a version with this, remove it. We
can always re-add this later if the need appears.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-02-10 15:22:25 +01:00
Palle Ravn
61dc211e04 Correct index check in ratbag-command
When initializing N profiles they are indexed 0 to N-1. However,
when setting the active profile to X the validation of X is a
check for X > N. Notice that N is invalid as the maximum index
is N-1.

Change the validation check of the new active profile to X >= N.

Signed-off-by: Palle Ravn <ravnzon@gmail.com>
2015-10-25 12:54:30 +01:00
Peter Hutterer
5b8f3c4744 Add snprintf_safe() and sprintf_safe helpers
Blows up when sprintf encounters an error, the result string is empty or the
result string is truncated.

Note: sprintf_safe only works on static buffers, it uses ARRAY_LENGTH.

Fixes #14

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 07:01:09 +10:00
Peter Hutterer
1abc7cdb69 Add strdup_safe() as a reliable strdup function
Handles NULL and guarantees a successful strdup

Fixes #14

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 07:00:16 +10:00
Peter Hutterer
a3aacd3a99 Drop the _by_index suffix
This is the default, if we need a _by_name or so later we can add it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-16 00:55:12 +10:00
Peter Hutterer
2d922012fd tools: fix usage() indentation, add exit status
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +10:00
Peter Hutterer
7ff92c4226 tools: add another "action" subcommand to set/get buttons
Like usage() already documented

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +10:00
Peter Hutterer
1c84e74572 tools: Support macros
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +10:00
Peter Hutterer
3b452df36c tools: do a cap check before trying to set buttons/macros/..
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 06:23:27 +10:00
Peter Hutterer
fa06db8398 tools: use strtol(), not strtod() to convert ints
oops.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
834daebdd8 tools: support the button commands
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
c5d79f5806 tools: support resolution's "rate get/set"
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
d6153ddb92 tools: change the usage() output to a manual one
A bit easier to explain when we have more flexibility.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
0a3269dbdb tools: improve profile active get/set/
Drop some unnecessary code, make the functions a bit smaller. Drop the printf
when we're activating the active profile.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
02b14046a3 tools: implement resolution active get/set
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:52:25 +10:00
Peter Hutterer
61d9c1006b tools: return the right error from device_from_arg
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00
Peter Hutterer
7df7ed325a tools: automatically print usage() on ERR_USAGE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00
Peter Hutterer
839b31eb25 tools: categorize the return code
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00
Peter Hutterer
e7b421ae19 tools: fix resolution active get/set
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00
Peter Hutterer
6e56dec9ed tools: add an error message for a missing device path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00
Peter Hutterer
fb941b5f75 tools: let ratbag_device_from_arg reduce the argc
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 04:48:14 +10:00