Commit Graph

550 Commits

Author SHA1 Message Date
Peter Hutterer
35d24890ae hidpp10: drop a couple of unused fields from the hidpp10 device
Some were truly unused, others were write-only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:21:59 +10:00
Peter Hutterer
498a2882df hidpp: disentangle hidpp from libratbag
We now only use libratbag for logging. Abstract that away so we can use
hidpp10 separate from libratbag where needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:21:59 +10:00
Peter Hutterer
a51cf76477 hidpp: move read/write to hidpp into the generic headers
Part 2 of disentangling libratbag from the hidpp10 library. Copy the hidraw_fd
into the hidpp_device struct and use that during read/write.

This temporarily disables logging, will be re-enabled with an upcoming commit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:21:41 +10:00
Peter Hutterer
2314437e05 hidpp10: use direct read/write instead of the ratbag_hidraw functions
HID++ 1.0 doesn't need hidraw other than the fd itself, and this is the first
step to disentangling the hidpp10 code from libratbag.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:21:41 +10:00
Peter Hutterer
f0fbe6b725 hidpp10: drop hidpp10_list_devices - it's broken anyway
Requires a ratbag_device argument (with the hidraw fd open) but then tries to
list them - that doesn't quite work.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:21:41 +10:00
Peter Hutterer
afba5302d5 hidpp10: move open_lock and disconnect to the correct section in the header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:20:55 +10:00
bentiss
99fc44812d Merge pull request #36 from whot/wip/hidpp10-individual-features
hidpp10 individual features/enable hid++ reporting cleanup
2015-10-15 10:44:47 -04:00
Peter Hutterer
bf44465ff5 Don't use double-underscores before function names
Reserved for compilers.

Fixes #35

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 13:37:36 +10:00
Peter Hutterer
48549e6f6f hidraw: use the struct we already have a pointer to
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 11:43:43 +10:00
Peter Hutterer
05cd108059 hidpp10: make hidpp10_read_memory public
We have documentation for that, it does what it's already doing. It's called
sector + entry in the doc, but leave it at page + offset since we've been
using this in other comments.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 11:43:01 +10:00
Peter Hutterer
a83edffdbe hidpp10: shuffle 0xF1 to list after 0xB5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 11:42:57 +10:00
Peter Hutterer
bf4e288dfe Mark log_msg and log_msg_va with attribute(printf)
And fix the warnings resulting from that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 10:38:12 +10:00
Peter Hutterer
1b20beaada README: fix device-notes repository link
We renamed it, a bit less awkward this way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 09:48:51 +10:00
Peter Hutterer
0b74605779 README: link to mailing list, devices-notes repo, etc.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-15 09:15:45 +10:00
Peter Hutterer
9363f36fd1 hidpp10: convert 0x00 Enable HID++ Reporting into a proper bitmask
The caller doesn't need to worry about registers or something here, let's just
expose one single bitmask, provided by an enum.
This also adds s couple of missing bits from the previous implementation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-14 09:00:30 +10:00
Peter Hutterer
71b6c19f1d hidpp10: convert 0x01 Enable Individual Features into a proper bitmask
The caller doesn't need to worry about registers or something here, let's just
expose one single bitmask, provided by an enum.
This also adds s couple of missing bits from the previous implementation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-14 08:41:02 +10:00
Peter Hutterer
2bd900822e hidpp10: align the "received" message with the "expected" messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-14 08:10:53 +10:00
Peter Hutterer
c37f45f125 hidpp10: ignore the response length when comparing expected vs real response
The request length doesn't tell us what the expected response length is, e.g.
0x63 (current resolution) is set with a long request but replies with a short
ack.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-14 08:10:53 +10:00
Peter Hutterer
2f5b49fb68 Merge pull request #34 from whot/wip/hidpp10-specs
a bunch of HID++ 1.0 requests fixed or added
2015-10-14 07:13:32 +10:00
Peter Hutterer
1b6e65bf88 hidpp10: implement 0x64 set usb refresh rate call
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-14 06:38:48 +10:00
Peter Hutterer
7003fd567c hidpp10: implement 0x0D Battery Mileage
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:44:17 +10:00
Peter Hutterer
9617baf647 hidpp10: add a helper function to dump all pages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:33:48 +10:00
Peter Hutterer
633c5cb106 hidpp10: extend handling of 0x51 LEDs
First: there are 6 LEDs, not just 4. If the LEDs don't exist, the value is
UNCHANGED on the read request.

The value is more than a simple on/off, though at least the G500s only looks
at the lower two bits, so heartbeat and slow off both translate into "on" and
blink and slow on both translate to "off".

There doesn't seem to be a detection mechanism for what a device really
supports.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:33:42 +10:00
Peter Hutterer
bc7c48ecc0 hidpp10: implement 0x54 LED intensity
Untested, my devices don't handle this request

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:33:38 +10:00
Peter Hutterer
3c5443d203 hidpp10: Add a note to the 0x57 LED color command
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:33:34 +10:00
Peter Hutterer
cef532e51e hidpp10: add 0x07 Battery Status parsing
Untested, my M570 just gives me 0, 0, 0 and all the other devices are wired.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:33:20 +10:00
Peter Hutterer
da1f11cc7b Drop the remainder of the uLogitech project
We've moved the bits we're interested in out already.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:30:51 +10:00
Peter Hutterer
9089478e29 semaphore: add the two lines we're now using as build script in semaphore
Rather than copy/pasting the script, let semaphore fetch it and execute it.
This way we only need to maintain it in one place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:30:51 +10:00
Peter Hutterer
3b38e5a009 semaphore: fix wrong linebreak added by copy/paste
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 11:22:53 +10:00
Peter Hutterer
fcbc930ca3 Add the build script used by SemaphoreCI 2015-10-13 08:55:38 +10:00
Peter Hutterer
9d686d8dc3 Whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:35:55 +10:00
Peter Hutterer
31dc1f4772 Use _cleanup_ functions for udev/udev_device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:33:55 +10:00
Peter Hutterer
2d7f874a57 Merge pull request #31 from whot/master
extra _safe() helper functions, start of the cleanup attribute
2015-10-13 08:22:48 +10:00
Peter Hutterer
a36f83606c Always return NULL from the _unref() calls
There's no good reason to return the object from the unref() call other than
for testing purposes, and we can work around this by using valgrind instead.
The API is a lot more consistent when we always return NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:19:30 +10:00
Benjamin Tissoires
3d380af3a8 prevent error to be shouted when the .probe() returns -ENODEV
Seen on the second input node of the Roccat Kone XTD:
"ratbag error: ROCCAT Kone XTD: driver specified in hwdb not found: roccat

With the new hwdb matching, we should not try any other driver not having
the right id, so simplify the for loop to find the driver only.

Fixes #32

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-12 17:26:37 -04:00
Peter Hutterer
46b7a15663 Start using the __attribute__((cleanup))
Not a lot of use-cases in the main libratbag code yet, but the protocol
handling and hidraw bits may make more use of it.
2015-10-13 07:01:49 +10:00
Peter Hutterer
5b8f3c4744 Add snprintf_safe() and sprintf_safe helpers
Blows up when sprintf encounters an error, the result string is empty or the
result string is truncated.

Note: sprintf_safe only works on static buffers, it uses ARRAY_LENGTH.

Fixes #14

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 07:01:09 +10:00
Peter Hutterer
1abc7cdb69 Add strdup_safe() as a reliable strdup function
Handles NULL and guarantees a successful strdup

Fixes #14

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 07:00:16 +10:00
Benjamin Tissoires
c464c86fa4 fix ratbag_button_get_special
looks like a cpy-paste-o

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-12 16:08:06 -04:00
Peter Hutterer
357191b1e0 Improve the README a bit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-12 10:55:26 +10:00
Benjamin Tissoires
d9645c0e4b hidpp20: document the names of the features in gaming mice
This patch adds nothing but some debug outputs and prepares the code
to support the recent gaming mice from Logitech.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-11 10:28:37 -04:00
Benjamin Tissoires
4abdb634cf hidpp20: add a define to document feature 0x0003
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-11 10:25:16 -04:00
Benjamin Tissoires
f4777e7b71 hidpp20: fix adjustable DPI for older mice
The G502 uses the version 0 of the adjustable DPI feature. This version
does not echo the given parameters which raised a -EIO in libratbag.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-11 10:24:45 -04:00
Benjamin Tissoires
439e287776 fix readme for the doc
github is happy with the current README but doxygen is not.
Use the same formatting than the architecture.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-09 17:23:42 -04:00
Benjamin Tissoires
e606473198 update README
update README to reflect the hwdb change.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-09 17:19:16 -04:00
Benjamin Tissoires
9b18b877a7 hwdb: fix MX master entry
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-09 17:03:44 -04:00
Benjamin Tissoires
f48ee7e25b hwdb: fix udev rule for uhid devices
The MX Master is using BLE to connect, and so the system sees it as a uhid
device. The current rule ignores it because uhid devices do not have the
ID_BUS set.

Fix that by detecting uhid devices and put the bus in the hwdb accordingly.

For completeness, also add usb through uhid so we can also replay devices
and test their drivers.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-09 17:03:25 -04:00
Benjamin Tissoires
ebad4ecd0a test: fix the loading of the test driver
This test driver is already twisting a little bit the API, so twist it
a little bit more.

An other solution would be to just add a (void* data) parameter to .probe()
but there is no point in it because only test_driver would be used.

Create a new probe callback only used when using the test driver, so make
check is happy.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-09 16:26:39 -04:00
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