Commit Graph

74 Commits

Author SHA1 Message Date
Benjamin Tissoires
54fa8b6fa4 drv-hidpp20: implement set_current_profile()
Only enabled for PROFILES_8100.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-02-09 14:42:45 +01:00
Benjamin Tissoires
a9a8e23d37 hidpp20: parse macros
I am pretty sure we could do a better job, but heh.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-17 11:39:34 +01:00
Benjamin Tissoires
94062a0881 hidpp20: implement hidpp20_onboard_profiles_destroy to free memory
Macros will be dynamically allocated, so we need a way to free them
reliably.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-16 14:17:30 +01:00
Benjamin Tissoires
dd7de2225c hidpp20: clean the button mapping code
The button mapping of the hid++ 2.0 devices is close to the one from
HID++ 1.0, but not entirely (1.0 have a size of 3 while and 2.0 a size
of 4).
The parsing was not clean, so reuse a the same logic than hidpp10.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-08 17:43:31 +01:00
Benjamin Tissoires
e063d7d5e1 hidraw: add Consumer Control Table
Most should be fine, though I did not tested each key.

HID++ 1.0 and 2.0 use it now, though HID++ 2.0 needs refinments (only a u8
is used though we need a u16)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-27 16:55:06 +01:00
Peter Hutterer
e769108bf6 Namespace the receiver/wired device idx defines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-23 13:45:33 +10:00
Benjamin Tissoires
98a58a0e5e hidpp20drv: implement dpi change for onboard memory profile devices
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:14:03 -04:00
Benjamin Tissoires
c534d7a619 hidpp20drv: fill in the capabilities when parsing the features
Or we need to maintain the list of supported capabilities in a different
place, and it gets error prone.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:14:03 -04:00
Benjamin Tissoires
6a522f5354 hidpp20drv: rename the internal per feature read_button
Allows to navigate in the source more easily if they share a common
name.
However, this is still not good because we need to know which feature
number is which.

Though the format is now in sync with write_button.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:14:03 -04:00
Benjamin Tissoires
3753bd3216 hidpp20drv: implement write_button for devices with profiles
Still missing the consumer control HID keys, but the rest works (minus
the modifier keys).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:14:03 -04:00
Benjamin Tissoires
6dfada8628 hidpp20drv: extract feature 1b04 from write_button
To support profiles assignments, we need to split the various write
button functions.
Start with 1b04.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-22 15:14:03 -04:00
Benjamin Tissoires
88083511db hidpp20: remove unused parameter
profiles_list is not used anymore in hidpp20_onboard_profiles_get_current_profile
let's remove it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-10-21 16:01:13 -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
43ac20de69 fix "Failed to get HID++1.0 device " 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
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
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
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
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
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
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
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
90fa2251fa drv-hidpp**: check if the device accepts the HID++ reports
Removes the broken pipe on invalid nodes

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-12 10:17:34 -04:00
Benjamin Tissoires
1cbbcae37c Add the G303 as a known device
The G303 is a wired device and we need to talk to it with 0xff (OK a
#define would be good). This was not a problem for all of the unifying
devices given that the kernel overwrites the device_id for us, but the
corded devices are a different kind, and this one rejects device id != ff.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-11 17:43:35 -04:00
Peter Hutterer
69bb5d2f48 Add a default profile capability
Not all devices allow setting a default profile, make it a capability

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-11 03:42:44 +10:00
Peter Hutterer
43386ae31d driver-hidpp20: enumerate all capability values
Don't use a default here, let the compiler tell us when we're not handling a
value expclicitly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-11 03:42:44 +10:00
Benjamin Tissoires
c2272c4f76 drv-hidpp20: change log priority
Kind of annoying when using the command "list".

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-10 08:46:45 -04:00
Benjamin Tissoires
a8e592e1bc hidraw: add ratbag_close_hidraw
Better to clean up the hidraw node too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-07 16:12:00 -04:00
Peter Hutterer
6c3a8aa90e Abort if zalloc fails
Let's not pretend we will handle out-of-memory errors correctly, and really,
it's not something we really need to be worried about.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:52:50 +10:00
Benjamin Tissoires
d2d5566156 data: add an SVG for the MX Master
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 11:59:55 -04:00
Benjamin Tissoires
4644614da5 hidppdrvs: remove terminating comma in LOGITECH_DEVICE() macro
Or it leads to interesting errors when adding fields to the table
of supported devices.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 10:48:49 -04:00
Benjamin Tissoires
9dd71c6b06 hidpp20drv: if the num_buttons has been filled, use it
Or we end up reading in non allocated memory in hidpp20drv_read_button().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 10:26:52 -04:00
Peter Hutterer
6ec078d43b Add hooks for getting/setting the default profile
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 17:03:34 +10:00
Peter Hutterer
c01c37fcbf Implement ratbag_button_has_action_type
etekcity suppports macros already, the other two don't. hidpp10 doesn't
support any write stuff but let's claim we do anyway.

The driver hook for this isn't ideal, read_button is called during init but
we should set all this up during probe and then use read_button exclusively to
update the button, not set the capabilities as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 17:03:34 +10:00
Thomas Hindoe Paaboel Andersen
6e21d75b5c fix indentation 2015-09-01 17:39:06 +02:00
Benjamin Tissoires
f476f03762 make ratbag_resolution_init() return the struct resolution pointer
It is a common pattern to have:
ratbag_resolution_init(...)
profile->resolution.modes[i].xxx = yyy;
ratbag_resolution_set_cap(&profile->resolution.modes[i], zzz)

So instead of dealing with the internal fields of profile/resolution/modes,
just return the resolution that has been initialized.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-01 09:49:18 -04:00
Peter Hutterer
99a9752104 Add per-resolution capabilities
Currently only the hooks for x/y resolution, the rest is unimplemented. Also
the etekcity driver needs an update here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 17:30:47 +10:00
Peter Hutterer
9383097fd2 Namespace the ratbag capabilities to the ratbag device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 17:25:55 +10: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
d620683e38 Add a helper function to init a resolution mode
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:21:49 +10:00
Peter Hutterer
aa27fbae8d Remove the get_active_profile driver hook
Long-term we should have probe() and read_profile(), the latter of which
should read each profile and fill in _all_ information.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:05:52 +10:00
Benjamin Tissoires
84b0195688 hidpp20: initialize the profiles when the device has been enumerated
When we read the profiles, we need to know the capabilities of the device.
If the device has not been enumerated, then we are screwed.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 18:11:38 -04:00
Benjamin Tissoires
2309228dbe drivers: make .write_resolution_dpi() takes the resolution, not the profile
This allows to set whichever resolution we want within the profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 15:27:08 -04:00