Commit Graph

667 Commits

Author SHA1 Message Date
bentiss
2bfab83470 Merge pull request #57 from NoXPhasma/NoXPhasma-patch-1
Add G500 profile to G9x mice
2016-01-12 14:06:46 +01:00
NoXPhasma
65e104d588 Add G500 profile to G9x mice 2016-01-12 12:58:26 +01:00
bentiss
accece5ed0 Merge pull request #56 from phomes/G9-profile-parse
hidpp10: Parse G9 profile
2016-01-08 09:48:12 +01:00
Thomas Hindoe Paaboel Andersen
14ca639270 hidpp10: Parse G9 profile
This allows to read but not write profiles from the G9.

The dpi mode sturct is a little different as the mouse only supports
symetrical dpi for x/y. Given the current naming a suffix of _sym
was the best I could come up with.

The G9 profile has some additional unknown bytes compared to the
others. Unfortunately the content of them varies for the 4 first
profiles and the last. So adding a default value for the like with
the G700 is not possible. For this reason I dropped implementing
the write part for now.

Something else to address is that this mouse only has 10 buttons
compared to the usual 13 that we have in PROFILE_NUM_BUTTONS. For
now I just hardcoded it in the profile and hidpp10_get_profile.
2016-01-07 22:30:23 +01:00
Benjamin Tissoires
8ed646fd7f hidpp20: do not overwrite macros when writing a profile
Same commit for hidpp20:
Previously, we would put a random address in the macro value, meaning we
lose the content of the macros.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-18 13:27:15 +01:00
Benjamin Tissoires
f05aafc786 hidpp10: do not overwrite macros when writing a profile
Previously, we would put a random address in the macro value, meaning we
lose the content of the macros.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-18 13:19:37 +01:00
Benjamin Tissoires
06d0c03ea1 hidpp10: parse macros
Macros are somewhat properly parsed in hidpp10.
The driver, however, supports only key press/release and delays.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-17 13:19:19 +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
ff7a59f46a bump max events the macros can handle
We should probably dynamically alloc those then.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-16 16:01:30 +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
4673b62eb4 hidpp10: enable metadata parsing on G500(s) too
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 17:28:21 +01:00
Benjamin Tissoires
8f18357e47 hidpp10: properly parse metadata in profiles
unknown3 in G700 is the constant string "LGS02". This string is a marker
for LGS to specify that the rest of the data is the names of the profiles
and macros.

SetPoint doesn't set those, so they are considered as metadata.

In libratbag, we will parse those properly and always set them, no matter
if the user used SetPoint or not.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 17:26:07 +01:00
Benjamin Tissoires
b3834f48c8 hidpp10: do not reject profiles with invalid CRC
The mouse accept them, so they are not invalid.

Only the profile directory seems to be checking for the CRC.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 16:52:55 +01:00
Benjamin Tissoires
59cd7b1091 hidpp10drv: do not look for profile specifics when the device doesn't support them
This prevents the M705 to shout that we need to set RATBAG_HIDPP10_DPI
and also allows the mice with only 1 profile to be configured.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 11:52:22 +01:00
Benjamin Tissoires
a23cb4f22d hidpp10drv: enable writing of resolution for programmable devices
Need to dance a little bit to preserve the current settings.

Fixes #23

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 11:52:22 +01:00
Benjamin Tissoires
eb6e312bf3 hidpp10: implement full write of profiles
The complexity when writing the profile to ROM at first allows:
- to prevent the user to temper with a non full profile
- in case of a USB failure (disconnect or loss of power for the batteries)
  we don't use partially overwrite the profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 11:52:22 +01:00
Benjamin Tissoires
390a82bce9 hidpp10: fill in the profile and fake its writing
To not have a giant patch that writes profiles to the HID++1.0 mice,
this first patch only convert the user profile into the actual data
that needs to be sent to the mouse.
We use hidpp_error to output it but no end user will ever see that
because it will be removed in a later commit.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 11:52:22 +01:00
Benjamin Tissoires
fe8c850fe4 hidpp10: implement set current profile
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-14 11:52:22 +01:00
Benjamin Tissoires
bc1a940c82 hidpp10: store the names of the profiles and the names of the macros
Currently only in G700(s), as we don't know the mappings for the
other mice.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-11 17:06:20 +01:00
Benjamin Tissoires
76376b3b8f hidpp10: use uint16_t directly in _hidpp10_button_binding
much easier to deal with, especially when we need to write them back.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-11 16:07:15 +01:00
Benjamin Tissoires
c8c6fc6f1d hidpp10: fix valgrind complaint in get_profile
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-11 16:05:21 +01:00
Benjamin Tissoires
ab471f98f5 hidpp10: add missing line ending in log_error
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-11 16:05:21 +01:00
bentiss
105fce1697 Merge pull request #53 from whot/liblur
Add liblur, a library for logitech unifying receivers
2015-12-11 16:04:42 +01:00
Peter Hutterer
23e3a09968 Add liblur, a library for logitech unifying receivers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-10 09:16:03 +10: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
dcf5e45797 hidpp20: fix resolution up/down
Looks like they where inverted

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-12-08 17:43:31 +01:00
Benjamin Tissoires
0e69c7050f hidraw: fix build for older kernels
When they do not declare KEY_SCREENSAVER and KEY_VOICECOMMAND.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-27 22:41:03 +01:00
Benjamin Tissoires
3889d129fd hidpp10 add 2 more special usages
The G500 uses only one bit in the usage code (thus the holes in the table).
So for the G500, RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_CYCLE_UP is
the same as RATBAG_BUTTON_ACTION_SPECIAL_RESOLUTION_DOWN for instance.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-27 22:37:49 +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
Benjamin Tissoires
4ebba2df74 hidpp10: add support for G700 over wireless
The G700 can use a wireless receiver too. It is close enough to the
normal Logitech Unifying receiver, but is truncated as it can not pair
multiple devices.
We currently don't treat it in the kernel as an Unifying device, and
so giving the device index of 0x00 fails as the device is actually on 0x01.

While there is no proper kernel solution (if there will ever be one),
allow to add a parameter in the hwdb to specify the device index.
We might need it for some other devices too, we will see.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-27 09:40:45 +01:00
Benjamin Tissoires
0557fc22be hidpp10drv: parse the button mapping
Still missing consumer controls and macros.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:57:00 +01:00
Benjamin Tissoires
cb4c34337a hidpp10: implement parsing of special keys
Create new RATBAG_BUTTON_ACTION_SPECIAL_BATTERY_LEVEL.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:57:00 +01:00
Benjamin Tissoires
fb2e543fb0 hidpp10: add support for Logitech G700
G700s should be the same

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:57:00 +01:00
Benjamin Tissoires
9db8d2875d hidpp10: read the profiles only once
Store them in a table in hidpp10_device.
When the dpi list is filled in, we need to invalidate
the profiles.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:56:31 +01:00
Benjamin Tissoires
0fa4d3d984 hidpp10: factor out hidpp10_fill_dpi_modes() and hidpp10_fill_buttons()
Preparation patch to add support for more than one profile type.

No functional changes

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
41d6bba4cd hidpp10: add mandatory udev prop RATBAG_HIDPP10_PROFILE
Allows to specify a type of profile and speed up the discovery of
hidpp10 devices when they are not actual gaming with a known profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
097add3df3 hidpp10: validate crc when reading profiles
if the crc is not valid, the device rejects the page and we should
not rely on it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
6a9980b707 hidpp10: store the profile directory once for all
This is an expensive operation, so better store it in hidpp10_device

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
0ab1c5c234 hidpp10: check crc when reading a page
If the crc is wrong, the device will ignore the page.
This technically multiply by 6 the time to access the device, but this is
because we do not cache anything currently in hidpp10.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
9cc323d80f hidpp: extract hidpp20_crc_ccitt into hidpp_generic
Looks like the hid++ 1.0 devices are also using the same crc computation,
so put it in the generic part.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Peter Hutterer
df4a12b233 driver-hidpp10: use the profile directory to get the number of profiles
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-26 17:43:34 +01:00
Peter Hutterer
ff44609bef hidpp10: use the directory profile count to get the device info
The G700 has 5 available profiles, bump HIDPP10_NUM_PROFILES.

On the other hand, hidpp10_get_device_info() doesn't fill anything...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-11-26 17:43:34 +01:00
Benjamin Tissoires
8d65710846 hidpp10: implement profile directory
The command get_profile can either return an index in the directory (in
the page 0x01 of the memory) or an absolute address. If the address is
returned, it is unclear whether the directory is updated.

This commit also includes changes from Peter:
hidpp10: if the profile index exceeds the number of directory index, use 0
hidpp10: factor out directory fetching
hidpp10: use the profile directory only in hidpp10_get_profile

Fixes #26

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-26 17:42:26 +01:00
bentiss
50e3ea61f4 Merge pull request #47 from bentiss/wip/hidpp10-udev-resolutions
hidpp10 udev resolutions
2015-11-25 14:21:18 +01:00
Benjamin Tissoires
e70760012e Todo: add profile disabled support
Etekcity, Roccat, Logitech support enabling/disabling of profiles, we
should too.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-11-25 14:18:02 +01:00
Benjamin Tissoires
3e8bf85c04 hidpp10: build a table of available dpi settings
Each hidpp10 device should have a udev property named either
RATBAG_HIDPP10_DPI or RATBAG_HIDPP10_DPI_LIST. These properties ensure
that we know the mapping between the raw value of the dpi reported by the
mouse and the actual value.

Older devices (using the scheme 1 or 2 of hidpp10_get_current_resolution)
have to use the DPI_LIST to be able to map 0x80+.
Newer devices (using scheme 3) use the DPI setting with min, max, step.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-11-25 11:21:51 +01:00
Benjamin Tissoires
ef96a8649e private: exports ratbag_device_get_udev_property
Add a convenient function to retrieve a udev property.
Returns NULL if the property is not found.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-11-25 11:19:14 +01:00
Peter Hutterer
d83f8a30e0 Merge pull request #52 from jengelh/master
build: kill -no-install for installed binaries
2015-11-13 06:10:53 +10:00
Jan Engelhardt
c52dbc64f7 build: kill -no-install for installed binaries
With -no-install present in ratbag_command_LDFLAGS, the program would
get directly copied from .libs/ratbag-command to /usr/bin, retaining
the undesired rpath tag in the ELF file.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
2015-11-12 19:20:51 +01:00
Benjamin Tissoires
0068ef2b06 hidpp20: use a struct definition for onboard profiles
Removes the magic constants here and there, though the description
of the struct is not very nice and clean.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-11-06 18:57:26 +01:00