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>
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>
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>
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>
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>
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>
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>
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>
Preparation patch to add support for more than one profile type.
No functional changes
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Looks like the crc needs to be passed anyway, so have a common helper to
set the crc and write the whole page.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If the device has never been configured under Windows, the dictionary
of the profiles might be blank. When it is blank, any changes made to
the profiles are ignored by the mouse.
Update a new dictionary if the profile was previously not enabled.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
When initializing N profiles they are indexed 0 to N-1. However,
when setting the active profile to X the validation of X is a
check for X > N. Notice that N is invalid as the maximum index
is N-1.
Change the validation check of the new active profile to X >= N.
Signed-off-by: Palle Ravn <ravnzon@gmail.com>