Commit Graph

58 Commits

Author SHA1 Message Date
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
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
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
Thomas Hindoe Paaboel Andersen
bb5a7cbd1f hidpp10: drop internal ref counts
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.
2015-09-13 23:14:29 +02:00
Thomas Hindoe Paaboel Andersen
9011876d1b drop inconsistent null check
We do not check dev for null in any of the other functions. If it
was actually null then we would also already have got a null pointer
dereference earlier in the function.
2015-09-02 22:03:05 +02: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
Peter Hutterer
0d951724dc driver-hidpp10: hook up the active profile bits
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:16:48 +10:00
Peter Hutterer
2fbf156403 hidpp10: use 0x00 to talk to all devices, skip receiver handling
The kernel overwrites the device ID with the correct one for our device, so we
can just use 0x00 for all devices and skip the search for the unifying
receiver hidraw device.

Since we're not talking to the receiver anymore, we can/have to drop the
pairing information queries and the related info. Since we weren't using this
anyway it's not a big loss.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 11:42:48 +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
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
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
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
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
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
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
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
Peter Hutterer
24c23a3f13 hidpp10: convert get_hidpp_notifications to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
aadfefe752 hidpp10: convert enable_specific_feature into proper functions
This also changes from the "toggle" to a plain "set". If a caller needs to
toggle a specific function, it can run get + set instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
18f4e13b59 hidpp10: add set_led_status
Only enabled for 4 leds and I'm not even sure they're the same on all
devices. Still, works on the G500s so that's a good enough start.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
0891510d32 hidpp10: convert get_led_status to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
d1aec43c18 hidpp10: switch get current resolution to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
40ea55729c hidpp10: split pairing information into a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
268fbbbf40 hidpp10: convert fw information fetching into a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
33455a3245 hidpp10: store the resolution/refresh rate in the hidpp device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 17:00:33 +10:00
Peter Hutterer
aa6ded5d03 hidpp10: fix device type table
looks like a copy/paste-o

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:22:07 +10:00
Peter Hutterer
f5e62bd80c hidpp10: use helper function to extract wpid/build information
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:21:11 +10:00
Peter Hutterer
1b696397c7 hidpp10: shuffle things around to tidy up a bit
Looks a bit more like the hidpp20 driver now, and easier to get a handle on
everything. Command-specific functions/defines are grouped together and sorted
by command index.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:22:08 +10:00
Peter Hutterer
61377554ef hidpp10: move the various defines into the c file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:04:30 +10:00
Peter Hutterer
872d522364 hidpp: move the shared defines into a generic header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:03:29 +10:00
Peter Hutterer
bbec568055 hidpp10: use quotes for local includes, not lt/gt
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:01:31 +10:00
Peter Hutterer
a0d882d2e5 hidpp10: implement refresh rate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
adf1b9a99d hidpp10: add Optical sensor settings command
From:
https://github.com/cvuchener/g500/blob/master/doc/report.md
but we don't know what the return value is...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
ed320bcdea hidpp10: add resolution and LED status
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
58585bfb19 hidpp10: switch the idx base to 1, not 0
Only two receiver-specific requests have a 0-based index, everything else
wants 1-indexed devices. This currently makes it impossible to address wired
devices with a device index of 0. Switch it around, so that we use a 1-based
index.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
f5df7f0ec9 hidpp10: split the commands into helper functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
ecca960bd9 hidpp10: __u8 -> uint8_t
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
1b799d2d84 hidpp10: only run the pairing information commands if the first one succeeds
Still try to run the other commands though, they're not receiver-related and
may work on a device that's not on a unifying receiver.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
e5df589c84 hidpp10: fix up coding style a bit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
1563efd988 hidpp10: request individual features
Not doing anything with it, this is just playing around.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:08 +10:00
Peter Hutterer
4c7fb6f803 hidpp10: Add support for the HID++1.0 Notifications request
They're off by default, but I have to start testing somewhere...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:37:43 +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