1
0
forked from drath/libratbag
Commit Graph

153 Commits

Author SHA1 Message Date
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
cb487a6d1a tools: fix compiler warning 'no previous prototype'
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-03 09:55:53 +02:00
Peter Hutterer
7fdcf62bf2 tools: fix compiler warning
../tools/shared.c:132:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-03 09:55:53 +02:00
Peter Hutterer
f82c1119bf tools: fix Makefile, it's SOURCES, not SOURCeS
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
mxmgh
4d6390ea66 Teach ratbag-command the "ratchet mode switch" special action name 2017-02-13 08:10:45 +10:00
Clément Vuchener
c4013ca4b0 Add special actions for cycling down resolutions and profiles
Signed-off-by: Clément Vuchener <clement.vuchener@gmail.com>
2017-01-24 07:41:22 +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
f67389c017 lur: fix the index parsing for disconnect
argv[3] is the /dev/hidraw path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-23 16:13:57 +10:00
Benjamin Tissoires
a8897ca8ca tools: hidpp20-dump: prevent segfault when called on non HID++ device
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-17 17:19:55 +02: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
Peter Hutterer
37bd43511b Switch to using an emum for error codes
Whenever we do something that may fail, return an enum of possible errors.

This also changes the API for ratbag_device_new_from_udev_device() to return
an error code now too instead of just NULL on failure.

Error numbers start at -1000 to avoid overlap with errnos, error_code() should
be used internally to avoid returning an errno.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-03-14 14:20:47 +10:00
Peter Hutterer
b3237fd001 lur: change new_from_hidraw to return an errno
Makes debugging slightly more useful than just returning NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-03-02 09:08:13 +01:00
Benjamin Tissoires
b54d28ec1a tools: add a man for ratbag-command
Just duplicated the help.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-03-01 16:46:31 +01:00
Benjamin Tissoires
e07839bcee tools: remove no-install flag for lur-command
The resulting RPM complains about RPATH.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-02-18 14:25:18 +01: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
Benjamin Tissoires
ff7a59f46a bump max events the macros can handle
We should probably dynamically alloc those then.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-16 16:01:30 +01:00
Peter Hutterer
23e3a09968 Add liblur, a library for logitech unifying receivers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-10 09:16:03 +10:00
Benjamin Tissoires
cb4c34337a hidpp10: implement parsing of special keys
Create new RATBAG_BUTTON_ACTION_SPECIAL_BATTERY_LEVEL.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:57:00 +01:00
Benjamin Tissoires
41d6bba4cd hidpp10: add mandatory udev prop RATBAG_HIDPP10_PROFILE
Allows to specify a type of profile and speed up the discovery of
hidpp10 devices when they are not actual gaming with a known profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Jan Engelhardt
c52dbc64f7 build: kill -no-install for installed binaries
With -no-install present in ratbag_command_LDFLAGS, the program would
get directly copied from .libs/ratbag-command to /usr/bin, retaining
the undesired rpath tag in the ELF file.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2015-11-12 19:20:51 +01:00
bentiss
e9be30cd26 Merge pull request #48 from paller/tools
Correct index check in ratbag-command
2015-10-25 08:01:58 -04: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
e769108bf6 Namespace the receiver/wired device idx defines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-23 13:45:33 +10:00
Peter Hutterer
c024de52ea Merge hidpp10.la and hidpp20.la together into one single helper lib
No real reason to keep the two separate, and if we do and need to include both
libraries, we get double-defined symbols (all the ones in hidpp-generic.c).
This is a helper lib only anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-23 07:21:38 +10:00
Benjamin Tissoires
32e18e5cad tools: shared: keep only one instance of the mapping action/str
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:13:58 -04:00
Benjamin Tissoires
f85a700c27 tools: shared: fix reporting of RATBAG_BUTTON_ACTION_SPECIAL_SECOND_MODE
Setting the special command and displaying it were using a different
spelling. Fix that.

We should really only have one entry point for that.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:13:29 -04:00
Peter Hutterer
07dbf22f38 Merge pull request #44 from bentiss/wip/rename_hidpp10_device_new_from_idx
hidpp10: rename hidpp10_device_new_from_idx into hidpp10_device_new
2015-10-21 12:53:40 +10:00
Peter Hutterer
ee87c389c0 tools: fix missing return value
hidpp20-dump-page.c: In function ‘dump_everything’:
hidpp20-dump-page.c:85:1: warning: control reaches end of non-void function
[-Wreturn-type]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-21 12:44:00 +10:00
Benjamin Tissoires
7da4bd7e1e hidpp10: rename hidpp10_device_new_from_idx into hidpp10_device_new
There is only one constructor left.
Get rid of the static hidpp10_device_new() that is not adding much.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 21:43:59 -04:00
Benjamin Tissoires
06c742d172 tools: add a tool to dump the memory of hidpp20 devices
Mostly copy/paste from hidpp10-dump-page

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:38:19 -04:00
Benjamin Tissoires
a2a1f296e6 Add 2 special keys found on the Logitech G502
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_ALTERNATE (for the "sniper switch")
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_DEFAULT -> means what it means

And fix one missing entry in str_to_special_action.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 15:25:01 -04:00
Thomas Hindoe Paaboel Andersen
123254c737 tools: Dump the full page
The pages are 512 bytes. Increase the limit to dump the full page.
2015-10-18 13:20:07 +02:00
Peter Hutterer
0cb1fe44ad tools: ad a hidpp10-dump-page tool to dump a HID++1.0 device's memory
For protocol debugging, it's a lot easier to go have a simple helper than
having to go through the whole of libratbag.

And remove the page-dump helper from the main code.

Note that this tool needs a /dev/hidraw device directly, not an event node. It
is a debugging tool after all.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10:00
Peter Hutterer
31dc1f4772 Use _cleanup_ functions for udev/udev_device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:33:55 +10: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
218f9abce6 tools: include config.h instead of defining _GNU_SOURCE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-17 07:31:48 +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
24bbf4b6db tools: add test for macro arguments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +10:00
Peter Hutterer
6ddc529ff3 tools: append commands to array in test script, don't use manual indices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-15 23:36:29 +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