Commit Graph

443 Commits

Author SHA1 Message Date
Benjamin Tissoires
d3abebf202 hidpp20: change hidpp20_onboard_profiles_read_memory API
It looks like we can not use a section > 0xff and that the first
parameter corresponds to the type of the available memory (rom or flash).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:31:46 -04:00
Benjamin Tissoires
3294c5c048 hidpp20: parse the special keys in the profiles
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:28:47 -04:00
Benjamin Tissoires
fa3419b3c0 hidpp20: parse the key mapping
Still lack the modifiers, but this should eventually be exported as a
macro...

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:26:14 -04:00
Benjamin Tissoires
26fdafb881 hidpp20: parse the buttons mapping in the profiles
Only export the actual buttons in ratbag_button for now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:25:59 -04:00
Benjamin Tissoires
24f7319a6f hidpp20: read the button count from the mouse
When using onboard profiles, it looks like we have the button count.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:24:03 -04:00
Benjamin Tissoires
7c1718d316 hidpp20: first parsing of feature 0x8100 - onboard profiles
Obtained by rev-engineering the protocol.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 17:24:02 -04:00
Benjamin Tissoires
4991118bcd hidpp20: simplify internal hidpp20_feature_set_get API
We do not export it anymore and we plan to use it only in
hidpp20_device_new().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:59:48 -04:00
Benjamin Tissoires
dcf0a0e89d hidpp20: use the internal list of features instead of asking the device
We already know the indexes in the table, so there is no point in making
a round trip to the device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:49:17 -04:00
Benjamin Tissoires
43ac20de69 fix "Failed to get HID++1.0 device " 2015-10-20 16:49:17 -04:00
Benjamin Tissoires
2ff7bff6df hidpp20: remove uninitialized variable use
get_mousepointer_info does not take any parameters.
Remove the warning.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:49:17 -04:00
Benjamin Tissoires
6ac92f8479 hidpp20: retrieve and store the list of features once for all
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:49:13 -04:00
Benjamin Tissoires
8ffa2f9b96 hidpp20: retrieve the protocol version in hidpp20.c
We need hidpp20 to handle the list of available features. So we need to be
sure in hidpp20 that we are talking to a hidpp20 device.

Move the version retrieval in hidpp20 where it makes sense.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:19:02 -04:00
Benjamin Tissoires
65888eedd4 hidpp20: add new struct hidpp20_device
This struct will be used to store the table features/index and probably
others. It also allows a single entry point to set the device index.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 16:18:56 -04:00
Benjamin Tissoires
39345f6e85 hidraw: add input/hid usage mapping for keyboard usages
Etekcity and Roccat are using raw HID code to send the macros. The Logitech
hid++ 2.0 are too so let's centralize the code in hidraw and simplify
the code per-driver.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 15:25:09 -04:00
Benjamin Tissoires
e89566c5c9 hidraw: add the HID usage table values for keyboard usages
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 15:25:05 -04:00
Benjamin Tissoires
a2a1f296e6 Add 2 special keys found on the Logitech G502
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_ALTERNATE (for the "sniper switch")
RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_DEFAULT -> means what it means

And fix one missing entry in str_to_special_action.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 15:25:01 -04:00
Benjamin Tissoires
ae587826ca hidpp20drv: rename field 'base' into 'dev'
'base' was wrongly inherited from the hidpp10 implementation, but actually
it makes no sense in this context.
Also, we want to reserve the keyword 'base' for when we introduce
hidpp20_device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-20 15:24:43 -04:00
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
Benjamin Tissoires
3b3b9ce0a2 hidpp20: switch hidpp20 to use the non-libratbag dependencies too
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-16 16:43:46 -04:00
Peter Hutterer
0cb1fe44ad tools: ad a hidpp10-dump-page tool to dump a HID++1.0 device's memory
For protocol debugging, it's a lot easier to go have a simple helper than
having to go through the whole of libratbag.

And remove the page-dump helper from the main code.

Note that this tool needs a /dev/hidraw device directly, not an event node. It
is a debugging tool after all.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10:00
Peter Hutterer
2186dd90c6 hidpp: wrap the log handler init into a function
Almost a decent API now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-16 08:22:11 +10: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
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
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
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
9d686d8dc3 Whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:35:55 +10:00