1
0
forked from drath/libratbag
Commit Graph

138 Commits

Author SHA1 Message Date
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
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
5f4b770283 tools: add a test for the ratbag commands
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