Almost all of the devices we've worked with here are the same: they have
some sort of profile on them, and if they don't (which is quite rare)
it's rather easy to simulate one in the driver. In fact basically all of
the device drivers in ratbag just update the profile and rewrite it on
calls to the write_resolution_dpi() and write_button() calls. This is
annoying since profile writes can take a good bit of time, and we're
wasting a lot of time with redundant profile writes that way.
During XDC this year, we came up with an idea that makes more sense: a
profile oriented API. Instead of having multiple entrypoints in the API
to writing and updating the profile we just cache all of the profile
changes until ratbag_device_commit_profiles() is called, at which point
we do a single set of writes for each profile and button that changed.
This has a lot of advantages:
- Where the profile is and is not written out to the device is now
explicit.
- Changing attributes of each profile won't result in any sort of delay
up until the library user commits the profiles, allowing us to avoid
hanging the application every time a simple attribute is changed.
- We can cut down on workarounds in drivers to cater to the previous
API.
Since this commit doesn't handle converting all of the device drivers
over to the new API, we also add a temporary wrapper for devices that
haven't yet been converted to this new API so that they're still usable.
Once all of the drivers have been converted to the new API, the wrapper
will be removed along with the internal driver API calls.
Signed-off-by: Lyude <thatslyude@gmail.com>
Changes since v1:
- has_changed→dirty
- Change namespace to LIBRATBAG_0.5.0
Changes since v2:
- Remove unneeded note about not setting dirty bit
- commit_profiles->commit
- Make FIXMEs more obvious
- Minor styling nitpicks
- Split up capability check fixes into seperate patch
This commit adds complete (with the exception of LEDs and a few other
small things) support for configuring the G.Skill Ripjaws MX780. So far
this has been tested on firmware versions 19 and 21, and both of them
seem to work perfectly with this.
Changes since v1:
- Lots of style fixes
- Remove reset hook, comment out with #if 0 in case of usage in the
future
- Add ret = -EAGAIN check in the loop in gskill_general_cmd()
- Explain why we wait longer then the spec says to in
gskill_general_cmd()
- Check that buf[0] is set to GSKILL_GENERAL_CMD in gskill_general_cmd()
- Add some notes as to why we don't use gskill_general_cmd() in
gskill_select_profile()
- Cleanup return codes, change gskill_general_cmd() so it only returns
valid error codes. In places not using gskill_general_cmd(), do
return rc < 0 ? rc : -EPROTO;
- Split command for selecting the macro to read/write from into it's own
function, just like we do with the profile
- Move profile count workaround into it's own function, make explicit
note of why it's needed
- Add proper support for reading/writing profile/macro names, ensure
they aren't left blank so as to not confuse G.Skill's software
- Use HID kbd modifier codes for translating macro kbd modifier codes
- Use AS_MASK instead of (1 << foo) (apparently we already had this :)
Signed-off-by: Lyude <cpaul@redhat.com>
Some simple helpers to make converting strings to/from UTF-8 easier.
Required for the G.Skill driver since the profile/macro names are stored
in UTF16-LE on the mouse, and must be non-empty in order to prevent
confusing the default G.Skill config software.
Changes since v1:
- Fix potential erroneous free() if we fail to decide the target string
The new version is called "G502 Proteus Spectrum", so the older version comment is changed to "G502 Proteus Core" (its complete name) to avoid confusion.
Signed-off-by: Clément Vuchener <clement.vuchener@gmail.com>
Was off by one, the message content only includes one byte of extra information
before the serial number. And add a BE 32-bit helper while we're at it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The onboard profile do not store the current value but the default.
To retrieve the current value, we need to access the switchable resolution
feature.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The G900 advertises 5 profiles, which do not fit in only 16 bytes.
We need to read at least 32 bytes, so be it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The device can report how much rom it has through profile_count_oob.
Make sure we have something in ROM before accessing it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If the macro has not been retrieved, it's more likely that the button
is not bound to anything.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
A negative error means a communication error, while a positive one means
a HID++ one. Make sure we abort early enough.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
rc is set to 0 by ratbag_open_hidraw_node(), and if matched failed, we
close the hidraw node and end the loop.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Once we start probing devices for multiple drivers we shouldn't just print
error messages for every failed driver. In the hidpp20 case an error would be
printed for any hidpp10 logitech device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If a device is not specifically assigned a driver, try hidpp20 and then
hidpp10 hoping that one of them will work.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Prep work for being able to probe multiple drivers on a device. The function
that tests the actual driver simply takes a const char * with the driver name,
so in the future we can loop through multiple driver names easily.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
No need for two separate cleanup blocks, they're doing the same thing anyway.
Just make the function more robust to uninitalized fields and we're good to
go.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
hidpp10 devices have their own driver, let's not initialize them here and just
fail. If a hidpp10 device is assigned the hidpp20 driver this is a bug.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
No reason for the drivers to have their own printf each, just return the
negative errno and let the common code print it.
This now also means that we only return -ENODEV on something that's not really
an error, for anything else we print the strerror.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We now get an error message for all devices that have duplicate event nodes
because we use -ENODEV for 'device not found', 'device is a duplicates' and
'device doesn't have the hidraw report'.
The original commit was triggered by a misunderstanding of the error message,
will be fixed in a follow-up.
This reverts commit 855a6bd831.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>