Some mice have a separate hid interface for configuring the advanced
features. It occurs that this is a common enough use case to be handled
directly by libratbag-hidraw instead of having a per-device quirk.
The idea is to allow opening the sibling hidraw devices during .probe()
and to give a matching callback. If the callback succeeds, then the
hidraw node will be used.
With this, one device might be opened several times, this has to be fixed
in a separate commit.
Fixes issue #19
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We want to be able to find sibling hidraw nodes. For that, we need to
open and test several different hidraw nodes. Makes the opening of a
specific hidraw node in its own function.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We were retrieving the hidraw information but did not use them.
Now the debug output "foo is device 'bar'" is only shown when there is
a match.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
libratbag.c does not need to initialize anything hidraw related, so
move out everything to libratbag-hidraw.c.
That means that calling ratbag_close_hidraw() is not a requirement
whithin the drivers to exit properly.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We are touching hidraw internals here, better having the function in
libratbag-hidraw.c.
No functional changes.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Command 0xA2 (Read Sector) takes only a one byte argument for the offset
(entry in the documentation).
Clean up the code and return an error if the page (sector in the doc)
is invalid (to avoid querying the device which would output an
ERR_INVALID_VALUE).
Fixes#15
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If the time is not given in the macro, the device still accepts it and
works properly by setting 10 ms of delay after a key press and 50 ms
between the keys.
Problem is: without this, the RATBAG_MACRO_EVENT_WAIT is not set during
parsing, so we end up having a RATBAG_MACRO_EVENT_NONE between 2 key
events, and the library ends up truncating the macro after the first
RATBAG_MACRO_EVENT_NONE.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Might not be the best solution for hidpp10, because it just removes the
duplicates, but this way all of the other drivers can benefit from the
raw debug parameter.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
For supported devices this can get and set the led colors in RGB.
This patch just adds the support in the lib. Later patches will
add it to the driver and expose it in libratbag.
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.
When writing a button, the given button should also be stored in the
memory of the device.
Amend the documentation
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
we should not require to actually write the profile to actually write the
button in the memory of the device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If there is any problem while retrieving a macro, the first element in
the report might not match. In such cases, abort.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
When the macro is not on profile 0, we need to set the mouse in the
correct mode first.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
When waiting for a status, the mouse sometimes answers 0x02, which seems
to be EINVAL (though it can be an ACK too). Treat this answer so we do
not end up in some infinite loops.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
we should not require to actually write the profile to actually write the
button in the memory of the device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The device can tell whether it is ready or not, so better poll for it
instead of waiting 100ms and hoping for the best.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
There is a slight difference with etekcity:
- there is no need to first set the config macro element we are about to
send (the information are already in the macro report)
- we need to be sure the mouse processed the macro and is ready to handle
a new command. Thus the introduction of roccat_is_ready()
We should see if the etekcity does not require such check too (IIRC it did,
but the timeout were sufficient).
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This caused a problem since the hidpp10_device would keep a ref to
the ratbag_device - and the hidpp10_device would only get destroyed
when the ratbag_device got a ref count 0.
mechanical patch
the hidraw_fd should only be used in libratbag_hidraw, so better having
it in its own struct so we can extend the hidraw elements without touching
ratbag_device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
# Conflicts:
# src/libratbag-hidraw.c