Commit Graph

381 Commits

Author SHA1 Message Date
Thomas Hindoe Paaboel Andersen
3605bede48 Use udev rules/hwdb to match mice to drivers and SVGs
This adds udev rules/hwdb that sets RATBAG_DRIVER and RATBAG_SVG
properties to the event devices. We then use this property to select
the correct driver instead of checking the hardcoded list in the
drivers. Having this in a hwdb makes it easier for users to test
if drivers match their mouse with a system installed libratbag.

Each driver now has an "id" which is used to match the driver set
in RATBAG_DRIVER. A SVG can optionally be set as well.

All entries in the hwdb are currently without a name as that
information was not available in the hardcoded lists.

Note that this patch breaks the test-driver.
2015-10-09 21:05:33 +02:00
Benjamin Tissoires
5278d43429 hidraw: add 2 hidraw functions to fetch the usage page and the usage of a report
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-08 11:43:07 -04:00
Benjamin Tissoires
44dc1f7462 Revert "hidraw: ratbag_hidraw_has_report() can also match the usage and usage page"
This reverts commit d5a20efd8b.

The API is horrible. Better having 2 additional functions to get
the usage and usage pageof the report.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-08 08:27:43 -04:00
Benjamin Tissoires
48ce20ae21 hidraw: allow uhid devices to detect siblings
When using uhid devices, we might want to check for siblings too. This is
a corner case so that's why it might not work in 100% of the cases.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
d5a20efd8b hidraw: ratbag_hidraw_has_report() can also match the usage and usage page
Add a match against the usage page and the usage.
If we are not interested in this new match, we can just use 0.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
d95885c52c hidraw: fix endianness when parsing the report descriptor
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
a207fa0989 hidraw: store the report usage page and usage
We might need to check against them too, so parse them and store them.

It is a little bit tricky when there is no report ID. In this case, assume
that the Collection(Application) is a match.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
aacdb9923e hidraw: the report ID can be of arbitrary size
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
1175d69741 hidraw: store a struct when parsing the report descriptor
We will be interested in the type of reports, so prepare the storage
by using an external struct to store the reports.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 20:14:10 -04:00
Benjamin Tissoires
63a1202890 hidraw: remove duplicated code
ratbag_open_hidraw is a special case of ratbag_find_hidraw() when
we do not check for the parent and we do not have a match.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:46:24 -04:00
Benjamin Tissoires
13c3d9a110 hidraw: do not open twice the same hidraw node
When using the same context, we do not want to open twice the same
hidraw node if two input node match it.
Store the sysname in the ratbag_device so we can check if it has been
opened previously.

Note that ratbag-command list still shows all input node as working
because we just close them as soon as we opened them.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:46:19 -04:00
Benjamin Tissoires
1cbb80b7b4 keep track of opened devices
If we want to remove the duplicate nodes opened when using
ratbag_find_hidraw(), we need to somehow keep track of all opened
ratbag_device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:46:15 -04:00
Benjamin Tissoires
e71ac0a088 hidpp20drv: add support of Logitech G502
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:22 -04:00
Benjamin Tissoires
975c91ae54 hidraw: allow opening of sibling devices
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
ce37417525 hidraw: break ratbag_open_hidraw in two
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
abde78e6c4 hidraw: check if the hidraw node corresponds to the ratbag device
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
4538d03b36 hidraw: remove now useless storage of the udev hidraw node
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
00f8f90288 hidraw: make ratbag-hidraw responsible for all hidraw related operations
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
7dfa8cb75e hidraw: move ratbag_device_init_hidraw() in libratbag-hidraw
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>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
936ad60da4 remove unused parameter in ratbag_device_init_hidraw()
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-07 18:30:21 -04:00
Benjamin Tissoires
0ece3c1a9e hidpp10: fix comment
Looks like the page 1 is not a RAM page but a directory, and is in the
flash too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-24 14:13:39 -04:00
Benjamin Tissoires
c26ce20c5c hidpp10: fix reading memory
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>
2015-09-24 13:35:04 -04:00
Benjamin Tissoires
bb4b8d729b roccat-drv: fix macro parsing
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>
2015-09-18 11:08:37 -04:00
Benjamin Tissoires
0f1b11a874 debug: put the raw debug logs in hidraw, not in per-driver handlers
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>
2015-09-18 10:56:58 -04:00
Thomas Hindoe Paaboel Andersen
5ee30e5a65 hidpp10: don't skip the first profile
Only skip the first two profiles that seem like garbage.
2015-09-17 17:07:47 +02:00
Thomas Hindoe Paaboel Andersen
cbc0f0c4c7 hidpp10: Read colors in profiles 2015-09-17 17:07:47 +02:00
Peter Hutterer
5d992faf1f Merge pull request #20 from cvuchener/small_fixes
hidpp10: add G5 2007
2015-09-18 00:19:13 +10:00
Clément Vuchener
249ad1e639 hidpp10: add G5 2007 2015-09-17 16:11:07 +02:00
NoXPhasma
c5ad1a0e42 hidpp10: add G9x 2015-09-17 03:48:18 +02:00
Clément Vuchener
bfd9c62963 Abort when the report id is invalid 2015-09-16 21:14:04 +02:00
Clément Vuchener
863b26eee2 Use defines instead of values for button types 2015-09-16 19:13:15 +02:00
Clément Vuchener
16c83975af Added set current resolution function for G500s 2015-09-16 19:10:34 +02:00
Clément Vuchener
91dd957618 Added long command in hidpp_request_command 2015-09-16 19:08:56 +02:00
Clément Vuchener
cedab5cacc Added G500 id 2015-09-16 18:42:59 +02:00
Peter Hutterer
298205f02e Merge pull request #11 from phomes/led-colors
hidpp10: Add support for get/set of led color
2015-09-17 00:03:04 +10:00
Thomas Hindoe Paaboel Andersen
81dfec8f79 hidpp10: Add support for get/set of led color
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.
2015-09-15 23:46:11 +02:00
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
a85a40b713 hidpp10: add G9 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
e514da8218 drv interface: make the commit to the device mandatory
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>
2015-09-15 11:06:30 -04:00
Benjamin Tissoires
c7f8e851c1 etekcity: write the profile to commit the button asap
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>
2015-09-15 11:06:30 -04:00
Peter Hutterer
a3aacd3a99 Drop the _by_index suffix
This is the default, if we need a _by_name or so later we can add it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-16 00:55:12 +10:00
Benjamin Tissoires
41cf0176f0 roccat: remove spurious errors when waiting for the device to be ready
Not perfect but we need to figure out what 0x02 means eventually.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-15 10:46:26 -04:00
Benjamin Tissoires
3dc8f466ec roccat: abort if the macro does not match
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>
2015-09-15 10:38:12 -04:00
Benjamin Tissoires
892497ca60 roccat: retrieve the macro if we are not in the default profile
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>
2015-09-15 10:37:17 -04:00
Benjamin Tissoires
ee0c58ca35 roccat: break infinite loops
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>
2015-09-15 10:36:10 -04:00
Benjamin Tissoires
8a99ed6436 roccat: write the profile to commit the button asap
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>
2015-09-15 10:34:42 -04:00
Benjamin Tissoires
8e1d750ba1 roccat: add SVG for the Kone XTD
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-13 18:40:40 -04:00
Benjamin Tissoires
e73e1e2ab1 roccat: replace various msleep with actual device wait for readiness
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>
2015-09-13 18:40:40 -04:00
Benjamin Tissoires
84edfc23fc roccat: add support for changing the DPI
Again, this differs from the etekcity by not having to set the config
report first.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-13 18:40:40 -04:00