1
0
forked from drath/libratbag
Commit Graph

38 Commits

Author SHA1 Message Date
Thomas Hindoe Paaboel Andersen
ab7b620dd4 hidpp10/20: fix a buffer overflow
We pass a negative length into log_buffer which expects a size_t.
This causes it to write past the allocated output_buf.
2015-09-15 20:24:56 +02:00
Thomas Hindoe Paaboel Andersen
6155d86923 hidpp10/20: retry on usb timeout
On the M705 I frequently get usb timeouts here if the device has
not been active for a while. Retrying after 10 ms seems to reliably
fix the timeout problem.

We could have just added the 10 ms sleep directly but it does not
seem to be neccesary on wired devices so I chose not to. Setting the
ret value to a face positive number and looping would also work but
we risk an endless loop. In the end I just went for a single retry
as that fixed the problem for me.
2015-09-15 20:24:56 +02:00
Benjamin Tissoires
1cbbcae37c Add the G303 as a known device
The G303 is a wired device and we need to talk to it with 0xff (OK a
#define would be good). This was not a problem for all of the unifying
devices given that the kernel overwrites the device_id for us, but the
corded devices are a different kind, and this one rejects device id != ff.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-11 17:43:35 -04:00
Peter Hutterer
6c3a8aa90e Abort if zalloc fails
Let's not pretend we will handle out-of-memory errors correctly, and really,
it's not something we really need to be worried about.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:52:50 +10:00
Thomas Hindoe Paaboel Andersen
5f2d538e10 Avoid overflow when reading dpi list
LONG_MESSAGE_LENGTH is the length of the full message so we should
take the first parts of the union into account.
2015-09-02 21:59:06 +02:00
Peter Hutterer
5cb15524d4 hidpp: move the button lookup tables to the generic code
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 10:55:19 +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
Benjamin Tissoires
6bc44f4d5f Factor out ratbag_button_action_match
This will be used often in drivers, so let's have a helper for it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 16:55:29 -04:00
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
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
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
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
Peter Hutterer
bbc4af6419 hidpp20: add support for 0x1b00 reprogrammable keys
As seen on the T650.

Reusing most of 0x1b04 here, except this one only gives us control id, task id
and flags.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-22 18:04:02 +10:00
Peter Hutterer
5e61dc4800 hidpp20: add control/task ID mappings from 0x1b00
Let's hope that the range is the same here and 0x1b04 doesn't redefine some of
them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-22 17:42:29 +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
bc05440477 hidpp20: do not shout one more time the recieved data
well, there is no fine grain while outputing the raw events, so that
means that we have always shown the actual answer just before.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:24:33 -04:00
Benjamin Tissoires
7fb5c2f81d hidpp20: handle new errors reporting
Looks like HID++2.0 devices report errors with 0xff also.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:24:33 -04:00
Benjamin Tissoires
8b0221554e hidpp20: invert logical/physical in function 1b04
I misread the documentation. The task_id corresponds to what the button
has been physically designed to, and the control_id is the logical
remapping.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:24:33 -04:00
Benjamin Tissoires
0eb6bd3948 hidpp: fill the ratbag_button info
We still need to differentiate logical from physical in button types.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:23:14 -04:00
Benjamin Tissoires
d6186c0c5a hidpp20: re-order the features by numeric order
no functional changes, just moving code.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 13:44:36 -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
Benjamin Tissoires
1ad8b49be0 hidpp20: avoid writing of uninitialized value
The function does not take any argument, so the device ignores it,
but valgrind complains.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 13:26:43 -04:00
Peter Hutterer
472b394858 hidpp20: Implement support for battery level
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 15:11:57 +10:00
Peter Hutterer
d361bcb09f hidpp22: add a helper to not log some HID++ errors
The 2.0 GetProtocolVersion request will fail on 1.0 devices but there is no
equivalent for 1.0. The doc even suggests to detect this error to determine
whether a device is a 1.0 device. Thus, make it conditional on whether we
print the error or not (log it as debug message if turned off).

This should be reconsidered when we have everything in place and can think
about refacturing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 11:01:17 +10:00
Peter Hutterer
25036f6e3b hidpp20: automatically add the sw ID to the hid requests
0x8 was a random SW number picked, add that consistently and automatically so
it doesn't look like the command names require this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:46:53 +10:00
Peter Hutterer
75f4badbbb hidpp20: Fix copy/paste-o hidpp20_mousepointer_get_mousepointer_info
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:28:39 +10:00
Peter Hutterer
5e19d4e536 Print feature names as we're initializing them
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:10:18 +10:00
Peter Hutterer
35b5fa975e hidpp: Log the errno including strerror
Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:01:52 +10:00
Peter Hutterer
7f2d060ff9 Make libratbag-hidraw return negative errnos on error
Be consistent here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:01:52 +10:00
Benjamin Tissoires
a0f76f18f8 hidpp20: make the hidpp20_root_get_protocol_version compatible with bluetooth and corded
Lokks like the G500 needs a device_idx of 0x00, and the MX Master while on
Bluetooth only answers to report longs

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 19:56:38 -04:00
Benjamin Tissoires
eeccaa023c hidpp20: properly handle errors
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 17:19:46 -04:00
Benjamin Tissoires
81a77adf2d hidpp20: Implement feature 0x1b04: Special keys and mouse buttons
Still not writable.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 17:05:49 -04:00
Benjamin Tissoires
168473d6e3 hidpp20: export the defines for the page numbers
so the drivers could use them.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 15:38:00 -04:00
Benjamin Tissoires
0426f85163 hidpp20: use hidpp20_get_unaligned_u16
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 15:35:00 -04:00
Benjamin Tissoires
fdd47609cf hidpp20: implement 0x2201, adjustable dpi
only the getter right now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 15:32:21 -04:00
Benjamin Tissoires
88a54e7acf hidpp20: add mouse pointer basic optical sensors
untested right now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 14:38:31 -04:00
Benjamin Tissoires
9754810c38 unifying: retrieve the list of features available on HID++ 2.0 devices
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 14:12:56 -04:00
Benjamin Tissoires
b8637f0bc3 Add first hid++ 2.0 protocol support
The Logitech devices talk HID++, and we need a lib to handle that.
The first implemented command is the get protocol version which allows
to know if the device is using hid++ 1.0 or 2.0.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 14:12:08 -04:00