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
Peter Hutterer
aee827efa1
tools: drop active profile check in "profile active set"
...
Once we have the profile, we can call set_active and be done with it. No need
to check if another profile is currently active.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-15 04:48:14 +10:00
Peter Hutterer
f97a3142d1
tools: use the new flags for switch-etekcity and change-button
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-15 04:48:14 +10:00
Peter Hutterer
87881fd9d5
tools: change error messages into a more terse format
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-15 04:48:14 +10:00
Peter Hutterer
5e3ca7692e
tools: auto-fill profile, resolution, device for each command
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
8af1530ea5
tools: make the top-level command list a subcommand itself
...
Allows us to reuse all the subcommand code, and factor out a bunch of helpers
later.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
26f82c7ecc
tools: use the same error path in main()
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
f2bbd411fe
tools: enable a plain dpi get/set
...
Works on the active profile, active resolution by default.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
9e02b26d74
tools: implement dpi get
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
b39a00d9e6
tools: update dpi set to work on the right resolution
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
ce4771456f
tools: pre-load profile/resolution for the respective commands
...
So anything below either will have options->profile/resolution pre-set to the
right one.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
c504d8c029
tools: always open the device for all args
...
Except for "list", all commands need a device argument. Open it ahead of time
to reduce the boilerplate in each function.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
a0fb3a82f6
tools: implement dpi set, drop switch-dpi
...
Same code, except that we use a helper function to get the active profile.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00
Peter Hutterer
c89eb2f37b
tools: improve the usage() output a bit
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net >
2015-09-14 11:28:00 +10:00