Commit Graph

88 Commits

Author SHA1 Message Date
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
Peter Hutterer
a838d6d1cd tools: add the stubs for the button/resolution command
Only stubs, and the usage() output isn't correct anymore. But we need to fix
this anyway, the combination of arguments will be too complex to handle them
in such a simple approach.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:28:00 +10:00
Peter Hutterer
6f93b0da69 tools: add another helper to open the device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:28:00 +10:00
Peter Hutterer
59123945a7 tools: add profile active get|set commands
This replaces the switch-profile command

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:27:56 +10:00
Peter Hutterer
eb46a6581b tools: add a helper to get the device path
Doesn't do much, but it reduces some of the argc checking in the callers,
especially since we always expect the device as last argument

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:25:00 +10:00
Peter Hutterer
f99696e6d2 tools: use the parsed index instead of the argument
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:25:00 +10:00
Peter Hutterer
d0d5284132 tools: add ability to have subcommands in a ratbag_cmd
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 11:25:00 +10:00
Peter Hutterer
332a046cbb tools: stack the options into a struct passed to the functions
No functional changes, but this allows us to pass down profiles, resolutions,
etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-14 01:06:51 +10:00
Thomas Hindoe Paaboel Andersen
86960308e7 tools: add a missing prototype 2015-09-12 08:48:25 +02:00
Benjamin Tissoires
2bc5b1910a Add roccat implementation
This driver is basically a duplicate of the Etekcity.
After the copy-paste, I renamed all the the "etekcity"
by "roccat" and then rev-engineered the various constants.

Still a WIP, but it is getting usable.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-11 17:44:58 -04:00
Benjamin Tissoires
0429609634 tools: fix macro time conversion to str
Those breaks... I keep forgetting them

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-10 18:03:37 -04:00
Peter Hutterer
a4515a59ae tools: strncmp -> strneq
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-11 03:57:59 +10:00
Benjamin Tissoires
d7ef078c02 tools: Now, we have foo and bar as macro
Still not a parsing of the user input...

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-10 08:49:51 -04:00
Benjamin Tissoires
286f398763 tools: add a (currently fake) way of addressing a macro change
We need to implement a parsing of the given macro...

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-09 11:26:15 -04:00
Benjamin Tissoires
cdf710d807 add support for getting/setting the macro name
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-09 11:26:15 -04:00
Benjamin Tissoires
ce10bb1e84 macro: add first implementation
The doctext needs fixes and the API might not be final.
This however works and allow to read the macro.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-09 11:26:15 -04:00
Benjamin Tissoires
b9376bdc67 tools: split out some shared functions
Allows to reuse them in other tools

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-02 22:20:00 -04:00
Peter Hutterer
6ec078d43b Add hooks for getting/setting the default profile
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 17:03:34 +10:00
Benjamin Tissoires
4b9eae11d9 tools: cmd_info: if there is no profile, it's a bug...
...but we should not go further


Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-01 18:10:09 -04:00
Peter Hutterer
99a9752104 Add per-resolution capabilities
Currently only the hooks for x/y resolution, the rest is unimplemented. Also
the etekcity driver needs an update here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 17:30:47 +10:00
Peter Hutterer
9383097fd2 Namespace the ratbag capabilities to the ratbag device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 17:25:55 +10:00
Peter Hutterer
63e0ddc550 Add a LOG_LEVEL_RAW log level
Lower than debug, for spitting out all the protocol codes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 15:08:51 +10:00
Peter Hutterer
49d70577c0 Replace get_active_profile with profile_is_active
And the same for set_active_profile -> set_active. This API is more reliable,
the previous incarnation required the client to compare pointer values.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:04:58 +10:00
Peter Hutterer
eed48bd102 tools: resolutions with dpi 0 are disabled, print it as that
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 09:58:44 +10:00
Peter Hutterer
b427bd4a7b tools: print the right resolution index
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 09:57:09 +10:00
Peter Hutterer
e1836583a5 Add ratbag_resolution_set/get_default
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 09:49:03 +10:00
Benjamin Tissoires
07a0b0961b tools: profiles are 0-index based
It felt weird reading:
  Profile 2
    Resolutions:
      3: 1000dpi @ 500Hz (active)
      3: 1600dpi @ 500Hz
      3: 2400dpi @ 500Hz
      3: 3200dpi @ 500Hz
      3: 4000dpi @ 500Hz
      3: 8000dpi @ 500Hz

We could index the profiles to 1 too, but that would introduce slightly
more code change.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 14:31:58 -04:00
Peter Hutterer
7da10cc074 Add resolution modes
The devices we're dealing with all have multiple DPIs to configure. This API
will replace the current ratbag_profile_set_resolution_dpi() and friends.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 17:02:15 +10:00
Peter Hutterer
be58d91c63 Fix compiler warnings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 12:27:48 +10:00
Benjamin Tissoires
14c29322fd tools: fix switch-etekcity command
The purpose is to disable the buttons, not having them reporting BTN_LEFT.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04:00
Benjamin Tissoires
11d1a111a0 tools: dump the action mapped to the buttons
The buttons are given as plain numbers, not sure if we should
use BTN_LEFT, BTN_RIGHT, etc instead.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:12:27 -04:00
Benjamin Tissoires
d58ef45cfb etekcity: fill the type field of the buttons
This adds two button types: pinkie and pinkie2 when there are buttons
on the right side of the mouse.

OK, I could have called them left-handed-thumb.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:40:24 -04:00
Peter Hutterer
b1fc95ee74 tools: fix/implement ratbag-command change-button
New command syntax is:
  ratbag-command change-button 1 button 2 /dev/input/event0
  ... sets button 1 to logical button 2
  ratbag-command change-button 1 key KEY_UP /dev/input/event0
  ... sets button 1 to KEY_UP
  ratbag-command change-button 1 special "wheel up" /dev/input/event0
  ... sets button 1 to send wheel up

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 17:13:58 +10:00
Peter Hutterer
7db22756b7 Revamp button action handling
One giant commit, but I didn't know how to split this up easier. The problem
is a misunderstanding in what the button type is and the code that built on
that misunderstanding, requiring a lot of interdependent parts to be updated
at once.

The button _type_ is the physical description of the button.
The button _action type_ is what will happen when you hit the buttons.

The type is read-only, since we're not dealing with mr potato head here.
The action is adjustible and we now support buttons, keys and special
in-hardware actions (e.g. dpi changes). A few FIXMEs still in place, e.g. we
don't handle modifiers with keys.

For buttons we just take numerical button numbers. i.e. we can map a button to
button 4, which will result in BTN_SIDE, and eventually logical button 8 in X.
For keys we take KEY_FOO, since eventually we want this to come out as that
(could do this for button as well I guess). Modifiers are currently ignored.
For special actions we have a enum of actions we support.

The button type enum is thus reduced a lot, and everything needs to be
switched.

This breaks ratbag-command change-button, will be fixed later since it's
misdesigned as it is anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 16:46:01 +10:00
Peter Hutterer
7f508bdb77 Add two more thumb button types
The G500s has 3 thumb buttons, 4 is realistic too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:46:41 +10:00
Peter Hutterer
1eacc78397 Drop RATBAG_CAP_BUTTON_PROFILES, unnessary
The OS X tool for Logitech's gaming mouse did not allow button-profiles on the
G500s, but DPI modes could be configured. This is an issue with the software,
not the device itself since the device supports muliple profiles. So the
original assumption that there are devices that have profiles for DPIs but not
buttons is likely wrong, the devices we looked at so far all have profiles
with a set of DPI modes in it, one of which is currently active.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:19:00 +10:00
Peter Hutterer
93aaa3bba9 tools: add missing indentation for the button list
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:13:27 +10:00
Benjamin Tissoires
bfd6dc42a4 Add a MACRO button type
and relocate the raw value 0 of RATBAG_BUTTON_TYPE_NONE to be below 0x06.
The windows application sets 0x06 when disabling a button.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-25 13:19:30 -04:00