Commit Graph

59 Commits

Author SHA1 Message Date
Peter Hutterer
0726537a21 hidpp10: use a #define for the max page number
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-19 09:56:21 +10:00
Peter Hutterer
65db99334b hidpp10: allow the caller to set the open_lock timeout
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-19 09:56:13 +10:00
Thomas Hindoe Paaboel Andersen
7e5f77f402 hidpp10: read_memory should take offset in bytes
The current API takes offset in 2-byte values. Taking a byte value
is more natural. We need to upgrade the type of offset to uint16_t
to handle values > 256.
2015-10-18 13:20:07 +02:00
Peter Hutterer
8a3222204e hidpp: add hidpp_device_init()
Make this into a somewhat more sensible API and default to printf as log
handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10:00
Peter Hutterer
9e4bafba8f hidpp10: header file cleanups
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10:00
Peter Hutterer
70db86f0c4 hidpp10: make hidpp10_request_command static
For commands we support we have the wrapper functions, they're safer to use.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10:00
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
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
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
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
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
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
Thomas Hindoe Paaboel Andersen
cbc0f0c4c7 hidpp10: Read colors in profiles 2015-09-17 17:07:47 +02:00
Clément Vuchener
16c83975af Added set current resolution function for G500s 2015-09-16 19:10:34 +02: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
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
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
a3368a4a93 hidpp10: fix typo, reporing -> reporting
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
50d97bb33e hidpp10: mark the message struct as __attribute__((packed))
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:13:55 +10:00
Peter Hutterer
8aefa83b81 hidpp10: remove outdated comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:13:16 +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
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