Commit Graph

630 Commits

Author SHA1 Message Date
Benjamin Tissoires
44e7bc1c23 G-Skill: shut up compiler warnings
driver-gskill.c: In function ‘gskill_read_button’:
driver-gskill.c:791:3: warning: ‘event_data’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   ratbag_button_macro_set_event(macro, event_idx, type,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            event_data);
            ~~~~~~~~~~~
driver-gskill.c:791:3: warning: ‘type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   ratbag_button_macro_set_event(macro, event_idx, type,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            event_data);
            ~~~~~~~~~~~

Add a default case which should never get reached.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-03-22 11:05:22 +01:00
Benjamin Tissoires
0bcaeaeb33 doctext: fix various unresolved links
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-03-22 11:05:22 +01:00
Ilia guterman
da60f0748c driver-hidpp20: Add LED API (#113)
Read colors and effects from hidpp20 capable device
2017-03-22 02:25:00 +02:00
Wolf480pl
5418392143 Add more button scancodes to driver-logitech-g300
Apparently the mouse can be configured to send scancodes
for buttons 6-9.

Note: there's no meaning attached to scancode 0x118 in the kernel,
which is sent by button 9, but xev does detect it.
2017-03-21 09:15:43 +01:00
Ilya Guterman
0c0a6d39cb Add the ability to set LED effects 2017-02-22 10:10:03 +10:00
Ilya Guterman
3439058a54 fix indentation in documentation 2017-02-17 15:02:43 +10:00
Ilya Guterman
6414f7901f hidpp20: Implement feature 0x8070: LED effects 2017-02-13 10:24:26 +10:00
Ilya Guterman
3f83d5057d libratbag api support LEDs 2017-02-10 09:48:32 +10:00
Clément Vuchener
67f1c00181 hidpp10: Fix and add some special action codes
I fixed resolution cycle up actually being resultion cycle down and added the missing cycle actions for resolutions and profiles.

Signed-off-by: Clément Vuchener <clement.vuchener@gmail.com>
2017-01-24 07:41:22 +10:00
Clément Vuchener
c4013ca4b0 Add special actions for cycling down resolutions and profiles
Signed-off-by: Clément Vuchener <clement.vuchener@gmail.com>
2017-01-24 07:41:22 +10:00
Thomas Hindoe Paaboel Andersen
25294d9a63 Add driver for the Logitech G300/G300s
Supports the common functionality exposed by libratbag:
 - selecting profile 1-3 (profiles cannot be disabled)
 - selecting resolution 1-4 (can also not be disabled)
 - report frequency
 - default resolution per profile
 - button actions: mouse button numbers or key+modifier
   (modifiers are just a bit field and can easly be set
   in the driver, but not included as libratbag does not
   support it yet)
 - LEDs are not yet hooked up but are just a table of 7
   different predifined colors.
 - Seting active profile and resolution are both implemented
   but only profile activation is in use. The resolution
   activation code is commented until supported from libratbag
   itself.

The G300 has an unusual way of numbering buttons:
Left:1, Right:2, Middle: 3

The purpose of report type 0xF2 is not known.
2017-01-09 09:33:58 +01:00
Ilya Guterman
7d241642f9 hidpp20: first parsing of feature 0x8070 - onboard profiles 2017-01-04 10:50:21 +10:00
Stephen Kitt
d1e42ac56c Copy all three bytes from parameters
In hidpp10_get_hidpp_notifications(), we want all three bytes from
parameters[], not parameters[0] twice. This matches
hidpp10_set_hidpp_notifications().

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2017-01-04 07:29:13 +10:00
Ilya Guterman
45129b2bc8 hidpp20: define internal LED structure 2016-12-05 14:09:22 +10:00
Lyude
0568b4c39d libratbag-private.h: Fix space before brace
This was bugging me :(.

Signed-off-by: Lyude <lyude@redhat.com>
2016-11-22 20:54:18 -05:00
Lyude
5b152a6c3f gskill: Add some missing profile fields
Must have missed these somewhere down the line when I was reading the
specs for this…

Signed-off-by: Lyude <lyude@redhat.com>
2016-11-22 19:25:09 -05:00
Lyude
52d4e35192 Add the ability to enable or disable profiles
This is especially important for the mx780, so we can get rid of the
rude workaround we currently have in the driver for it.

Signed-off-by: Lyude <lyude@redhat.com>

Changes since v1:
- Just have profile enable/disable in ratbag-command
- Use bool instead of int
Changes since v2:
- Remove leftover function, whoops
- Fix leftover ints to bools
- Lots of style fixes
2016-11-16 09:45:01 +10:00
Lyude
a1a3750bc8 gskill: Add profile_to_pdata()
Saves me some typing :).

Changes since v1:
- Turn profile_to_pdata() into inline function
2016-11-16 09:45:01 +10:00
Thomas Hindoe Paaboel Andersen
3cfda944d0 Update report rate on all resolutions if needed
For drivers without the capability
RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE
we should update the report rate on all resolutions.
2016-10-28 09:30:52 +10:00
Thomas Hindoe Paaboel Andersen
adefb2921b unset previous default resolution
Make sure that there can only be one resolution marked
as default.

The previous code allowed to set multiple resolutions
as default. To clean up any bad state we allways loop
all other resolutions and unset the default if neccesary.
2016-10-27 11:05:50 +10:00
Thomas Hindoe Paaboel Andersen
27a141fd87 only set dirty when changed 2016-10-27 11:05:50 +10:00
Lyude
2b63ca4935 gskill: Check for ret < 0 in gskill_read_profile_name()
This was only working before because we weren't actually returning the
profile size correctly. Fix that up as well.
2016-10-27 10:05:57 +10:00
Lyude
107d7e652f gskill: Specify the correct encoding for profile names
Only managed to notice then while working on enabling/disabling
profiles. Somewhere down the line the encoding we pass to
ratbag_utf8_to_enc() managed to get typoed, causing it to actually fail
and not show anything because of the iconv helpers not returning
negative error codes.
2016-10-27 10:05:57 +10:00
Lyude
6c40b18229 libratbag-util: Return correct length from ratbag_utf8_from_enc 2016-10-27 10:05:57 +10:00
Lyude
9d51d70f70 libratbag-util: Return -errno, not errno
Whoops
2016-10-27 10:05:57 +10:00
Thomas Hindoe Paaboel Andersen
96a9a0f6a4 Move a comment to the appropriate function
The comment was effects of changing the resolution
but was added to the getter instead of setter function.
2016-10-24 08:03:27 +10:00
Thomas Hindoe Paaboel Andersen
31b513e6d7 Fix typos in documentation 2016-10-24 08:03:27 +10:00
Lyude
89de42ad8e gskill: Convert driver to new profile oriented API
Signed-off-by: Lyude <thatslyude@gmail.com>

Changes since v1:
- has_changed→dirty
Changes since v2:
- Change loop in gskill_commit_profiles(). Ended up being different then
  what we needed for enabling/disabling profiles. Anyway, we also needed to
  move around the call to gskill_reload_profile_data() so that we call it
  only once per commit, not once per profile write.
Changes since v3:
- commit_profiles->commit
2016-10-14 08:00:54 +10:00
Lyude
01fcef9b9d Introduce new profile-oriented API
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
2016-10-14 08:00:54 +10:00
Lyude
2bcacfc1ac libratbag: Check for CAP_BUTTON_MACROS in ratbag_button_set_macro() 2016-10-14 08:00:54 +10:00
Lyude
1e2edefd93 libratbag: Check for CAP_BUTTON_KEY instead of write_button()
This makes more sense then the former, and we're going to need it anyway
since write_button() is being deprecated.
2016-10-14 08:00:54 +10:00
Lyude
3aabba255d gskill: Update checksum *after* updating profile name
Noticed this while adding support for profile commits. This is definitely
a bug.

Signed-off-by: Lyude <thatslyude@gmail.com>
2016-10-11 21:11:39 +02:00
Lyude
e543723856 Add support for the gskill-mx780
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>
2016-10-06 14:12:10 +02:00
Lyude
eb8e4bbfa8 libratbag-util: Add ratbag_utf8_(to|from)_enc() helpers
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
2016-10-06 14:12:10 +02:00
bentiss
f75152f074 Merge pull request #95 from cvuchener/g502rgb
Added G502 support and small fix
2016-08-31 11:37:08 +02:00
Clément Vuchener
f72c96914b hidpp20: fix reading has_dpi_shift
The comparison was always false because of missing bit shift.

Signed-off-by: Clément Vuchener <clement.vuchener@gmail.com>
2016-08-30 16:50:18 +02:00
Peter Hutterer
01876023bb hidpp10: fix fetching of serial number
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>
2016-07-14 10:17:49 +10:00
Benjamin Tissoires
d54d77c395 hidpp20drv: ignore errors of PAGE_ADJUSTABLE_DPI
The G602 seems to fail here, but it is safe to continue.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-17 17:19:55 +02:00
Benjamin Tissoires
9aa2120c7d hidpp20: prevent segfault if hidpp20_adjustable_dpi_get_dpi() fails
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-14 09:43:35 +02:00
Benjamin Tissoires
aef7b3e9bb hidpp20drv: add support for the G900 over wireless
We need the same setting that we have on the hidpp10 side.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-11 14:01:15 +02:00
Benjamin Tissoires
21d0219809 hidpp20: add new special action in G900
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-11 14:01:15 +02:00
Benjamin Tissoires
28438e638b hidpp20-drv: actually retrieve the current resolution value
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>
2016-05-10 11:35:17 +02:00
Benjamin Tissoires
c1bf3be48e hidpp20: read/write the whole dictionary, not just the first 16 bytes
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>
2016-05-10 11:13:34 +02:00
Benjamin Tissoires
27293a22df hidpp20: enable G900 profile type
The profile is retro-compatible with the rest, so we can access it
in the same way.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-05-09 20:09:24 +02:00
Benjamin Tissoires
fc07672983 hidpp20: prevent invalid ROM access
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>
2016-05-09 20:08:18 +02:00
Benjamin Tissoires
c14a0ca2a1 hidpp20-drv: prevent an empty profile to try to read a null macro
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>
2016-05-09 19:52:56 +02:00
Benjamin Tissoires
64037febdc hidpp20: fix return path for hidpp20_onboard_profiles_read
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>
2016-05-09 19:51:46 +02:00
Peter Hutterer
91eefb9a3f Ignore devices that don't have ID_INPUT_MOUSE set
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-05 12:57:11 +10:00
Benjamin Tissoires
1da0180e0f hidraw: do not return success if match failed
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>
2016-04-29 12:10:41 +02:00
Peter Hutterer
e912f56c26 driver-hidpp20: don't log an error if we can't init a hidpp20 device
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>
2016-04-29 10:14:11 +10:00