Commit Graph

244 Commits

Author SHA1 Message Date
Benjamin Tissoires
08a568aed2 hidpp20: fix after button type revamp
the logical and physical bits were inverted:
- logical is the action of the button
- physical corresponds to the actual button on the mouse (so the 'type')
- there is a duplicate from driver-etekcity to match 2 actions, this should
  be factorized in a helper somewhere in a later commit

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 16:48:03 -04:00
Benjamin Tissoires
7ba2c7cee7 etekcity: check for return values before using them
If action is NULL, that's a problem.
If etekcity_button_action_to_raw() returns 0, we should not try to write
0x00 in the profile. The proper command for "none" is 0x06. 0x00 is thus
an error.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04: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
1b5eb84ac4 Export a button_disable function
This sets a button to RATBAG_BUTTON_ACTION_TYPE_NONE when we want
to disable a button completely.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04:00
Benjamin Tissoires
cc5c539fdb etekcity: fix the retrieval of the raw code given the action
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
52683a866c Fix copy/paste-o in ratbag_button_get_special
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 12:15:14 -04:00
Benjamin Tissoires
34d1550676 etekcity: register that 0x10 is a macro
Still not able to express this to user space

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:59:44 -04:00
Benjamin Tissoires
3ad0cacd0d Cleanup the profiles and buttons on exit
Now that the profiles and buttons have to be created once by the probe()
function, we need to clean them up when the device is unref-ed.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:54:56 -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
Benjamin Tissoires
b11c1f30f3 etekcity: rename local variable index into raw_index
this index is the position of the button in the report, so it's misleading
to keep it as "index". The actual index is the button->index.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:32:43 -04:00
Benjamin Tissoires
701c1b7d36 etekcity: the mouse has ten buttons, not nine
the button index starts at 0, so we need to add 1 to the max button number.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:31:41 -04:00
Benjamin Tissoires
c28edd2411 Add the ratchet mode switch button type and action type
Found on the Logitech MX Master. Most of other Logitech device with
physical ratchet disable capability do not show this button to the host
however.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:01:25 -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
ec9456c940 Make a note that button_get_type is the physical type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:52:00 +10:00
Peter Hutterer
91a033f157 Don't create a button when requesting one
The drivers are responsible for initializing the buttons during probe(), then
we just return the one we found

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:52:00 +10:00
Peter Hutterer
5a6c687c96 Create buttons during profile init
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:59 +10:00
Peter Hutterer
40a08f2a55 Add ratbag_profile_init_buttons
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:31 +10:00
Peter Hutterer
abe3244f6b ratbag_create_button doesn't need a device argument
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:31 +10:00
Peter Hutterer
442eb6391c Initialize the profiles during driver startup
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:30 +10:00
Peter Hutterer
73c2966d5c Don't create profiles when trying to read it from the client
Make the driver responsible for creating them on startup, then just return the
one we already have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:48:15 +10:00
Peter Hutterer
6abf0733c4 Drop ratbag_button_get_identifier
This is something better handled by mapping the various button types into a
specific string on the client-side.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:48:15 +10:00
Peter Hutterer
d444e2e1e8 hidpp10: use log_debug for HID++ errors
HID++ 1.0  doesn't have an index of functions available, so we pretty much
have to bang every request against the device, full of hope and optimism.
Reality demands that some of them fail and we handle that, but we don't need
to worry the user by screaming errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:57:43 +10:00
Peter Hutterer
008ab6a9d7 driver-hidpp10: hardcode button types for the G500s
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:49:49 +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
66d4d33857 hidpp10: rename hidpp10_buttons to hidpp10_button
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:38:14 +10:00
Peter Hutterer
6bb25bc824 driver-hidpp10: implement has_capability
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:22:45 +10:00
Peter Hutterer
2801ec070b Drop libratbag_get_button_by_index
Use libratbag_profile_get_button_by_index instead

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:20:10 +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
Peter Hutterer
6d55dae48d driver-hidpp10: fill the number of buttons from the first profile
We don't know the HID++ 1.0 request to check for the number of buttons or
profiles, this is the next-best thing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:11:04 +10:00
Peter Hutterer
1d80ea4898 hidpp10: store the number of dpi_modes/buttons in the profile
Makes it easier to iterate through the profile without relying on global
variables.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:55:25 +10:00
Peter Hutterer
cab9169e6f hidpp10: actually return the profile when we're fetching it
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:52:49 +10:00
Peter Hutterer
a147d4c545 driver-hidpp10: don't set the resolution when the request fails
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:13:56 +10:00
Peter Hutterer
a4356f21ba hidpp10: add more debugging information
To make it easier to find what failed in the wall of hexcodes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:11:59 +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
Benjamin Tissoires
57cb37fa62 hidpp20: found 2 physical descriptions from the m325
These 2 buttons are on each side of the wheel. They send back/forward by
default.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-25 11:38:21 -04:00
Benjamin Tissoires
270b089674 Add the M325 to the hidpp20 driver
Not that we can configure much, but 0x1b00 sends 5 buttons, which is
the reality, so trying to include it too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-25 11:37:12 -04:00
Peter Hutterer
98165fec0e hidpp10: add code to read the profile
Profiles are... interesting
https://github.com/cvuchener/g500/blob/master/doc/profile.md is pretty
detailed on the information, but there's some oddities.

The profile configured on my mouse is on page 5, not sure if that's the OS X
logitech tool though (which doesn't do profile configuration btw). Pages 3 and
3 are valid too, the rest looks to be garbage.

There's probably some magic string to detect a profile (cvuchener says maybe
FF 00 00 80), so more profiles may be lying around elsewhere in memory...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 16:58:00 +10:00
Peter Hutterer
e8b15ba7ee hidpp10: fix a comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:14:19 +10:00
Peter Hutterer
89728733bf hidpp: use a #define for the wired device index
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:13:17 +10:00
Peter Hutterer
4fca750977 hidpp10: make the device init API slightly more sane
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:13:17 +10:00
Peter Hutterer
a3368a4a93 hidpp10: fix typo, reporing -> reporting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:13:17 +10:00
Peter Hutterer
7d53adb3c3 hidpp10: revamp to only pass a hidpp10 device around
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:41:03 +10:00
Peter Hutterer
eba5a2b387 hidpp10: store the ratbag device ref in the struct
Saves us passing two args around everywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:28:48 +10:00
Peter Hutterer
3f6e94dfc6 Move driver checks into ratbag_register_driver
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:10:40 +10:00
Peter Hutterer
e5ebebe4a4 driver-hidpp10: read resolution/refresh rate on demand
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:24:14 +10:00
Peter Hutterer
f944f2410a hidpp10: convert the optical sensor bits into a function sensor
And it looks like the first byte is the surface quality

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
ad899506a7 hidpp10: convert get_usb_refresh_rate to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00