Commit Graph

57 Commits

Author SHA1 Message Date
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
Peter Hutterer
3782b37853 Drop the 'device' argument from libratbag_device_set_active_profile
The profile is bound to a device anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Peter Hutterer
82338aadcd Use strneq instead of strncmp
Less error-prone

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Benjamin Tissoires
88154c2438 hidpp20drv: implement button remapping
Problem: when a button is diverted, it stops sending its original button,
which is good, but then reports only on the HID++ long report collection.

That is a little bit embarrassing.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:50:01 -04:00
Benjamin Tissoires
cf4a932d34 Implement set profile resolution dpi
Works only in Logitech with adjustable DPI for now (MX Master).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 13:26:43 -04:00
Peter Hutterer
2894ece95a tools: use dash, not underscore in commands
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 08:17:37 +10:00
Peter Hutterer
b1ae0682bd tools: print an error if no supported devices are found
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 08:07:37 +10:00
Benjamin Tissoires
0a683e3cc6 tools: add a "list" command to easily know which event nodes are supported
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 17:13:30 -04:00
Benjamin Tissoires
85df22d360 tools: actually install ratbag-command
looks like this tool is going to be interesting after all.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 16:34:40 -04:00
Benjamin Tissoires
25faa1c174 tools: add a very specific command for etekcity devices
Etekcity mice have volume up/down mapped on the 2 buttons on the right
side of the mouse. They get easily pressed by the hand and can annoy the
user. This command switches on and off these buttons.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 14:30:56 -04:00
Benjamin Tissoires
e6a7259c40 tools: do not update the profile if we are currently on this one
there is no specific gain besides not writing to the flash of the device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 14:29:17 -04:00
Benjamin Tissoires
e3f9e0ffc0 Add a "none" button type for disabled buttons
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 14:10:32 -04:00
Benjamin Tissoires
ace830eb91 tools: add switch_profile command
This allows to test ratbag_device_set_active_profile() and the
.write_profile() callback from the drivers.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 13:49:29 -04:00
Benjamin Tissoires
a357766dbb tools: factor out the opening of the dev node
And fixes on a fly a missing unref to udev when udev_device_from_path()
fails.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 13:42:02 -04:00
Benjamin Tissoires
5bd973a1f1 tools: Dynamically create the usage help for the commands
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 13:40:49 -04:00
Benjamin Tissoires
abc7ac1029 tools: fix 2 valgrind complains
When accessing the buttons of a profile, we should not unref it until
we are done (or there will be some illegal access to a free-ed pointer).

The last profile_unref should be called against the active_profile, not
the last profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 11:31:58 -04:00
Benjamin Tissoires
f7ecf67cd3 Add a bunch of buttons used by the Etekcity mice
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 10:51:55 -04:00
Peter Hutterer
e3a25ccd91 tools: implement ratbag-command info
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 14:03:07 +10:00
Peter Hutterer
3327cbad7c tools: rename "rb" to "device"
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:25:04 +10:00
Peter Hutterer
ec321bb43e tools: handle --verbose
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:23:36 +10:00
Peter Hutterer
5d609de747 tools: use a custom error function
Wrap the fprintf calls into something consistent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:22:01 +10:00
Peter Hutterer
f9a6b5ff3c tools: print an error if the command is unknown
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:18:50 +10:00
Peter Hutterer
44a675534e Rename "libratbag" to just "ratbag"
Naming scheme is now:
* ratbag - the context
* ratbag_device - the device
* ratbag_profile
* ratbag_button
...

Only leftovers of "libratbag" are the header file name, #defines that are
exported through that header file and anything that has to do with the actual
library iself (e.g. the symbol export file).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:15:20 +10:00
Peter Hutterer
b8be026032 Rename "struct ratbag" to "struct ratbag_device"
Less ambiguous naming this way

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:15:20 +10:00
Peter Hutterer
c51b7a9653 tools: exit early if we fail to find a udev device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 10:39:05 +10:00
Peter Hutterer
5e9e408ce0 tools: re-add support for opening /dev/input/event nodes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 10:38:00 +10:00
Peter Hutterer
d64b9eeb22 tools: rename list_ratbags_usage() to just usage()
Looks like a command name before the current ratbag-command one, and since
this is a static method anyway just usage() will do.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 10:22:44 +10:00
Peter Hutterer
0b833aa195 tools: revamp the ratbag-command option handling
Put the code in place for a multi-command tool, first command is
  ratbag-command info /path/to/device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 10:22:30 +10:00
Peter Hutterer
45777d9a96 Fix a typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 09:23:34 +10:00
Peter Hutterer
0259e69241 Add an open_restricted/close_restricted interface
Same as libinput. Since we need to open device files we need something that's
authorized to open them. So we punt that to the caller.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 08:33:49 +10:00
Peter Hutterer
6ca2de81dd tools: use getopt parsing for the ratbag-command
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 08:33:49 +10:00
Peter Hutterer
fcda14df61 Drop from_fd, replace with from_udev_device
We don't need the evdev fd, it's more flexible to start with a udev device.
This changes ratbag-command to take a /sys path as well, but for not it'll
do.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 08:33:49 +10:00