Commit Graph

300 Commits

Author SHA1 Message Date
Benjamin Tissoires
a7a1f1a2a4 etekcity: retrieve the macros while reading the button
Avoids one for loop and will allow to store the macro in the button.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-08 11:34:56 -04:00
Benjamin Tissoires
7a679c9f97 hidraw: return -ETIMEDOUT when a timeout occured
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-07 16:12:00 -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
Thomas Hindoe Paaboel Andersen
f018a67252 use info if given an invalid priority
Actually do what the log message says
2015-09-07 20:00:13 +02:00
Thomas Hindoe Paaboel Andersen
ea87c8b200 Remove unused include 2015-09-07 19:56:58 +02:00
Benjamin Tissoires
54aea717a5 fix typo in ratbag_button_action_match
We want the action to be matched, not be different.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-07 10:13:10 -04:00
Benjamin Tissoires
4017df40f3 etekcity: fix profiles raw mapping
Looks like they were offset by one.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-07 10:13:05 -04:00
Benjamin Tissoires
f8cb6e0f39 etekcity-drv: fix compiler warning
we should not access resolution before it gets initialized...

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-07 08:44:05 -04:00
Peter Hutterer
cb50b53467 Don't allow for more than INT_MAX refs on each struct
"2^31 are enough for anyone"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:44:25 +10:00
Benjamin Tissoires
5aa1c0b65d test: Add a test to use profile after unref-ing the device
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-07 10:44:18 +10:00
Peter Hutterer
dc24ae3aaa Fix the ref/unref dependency
The current code has the profile ref the device, but the device has no back-ref to
the profile. The following code will free the profile from underneath the
client, despite the caller still having a valid ref:

p = ratbag_device_get_profile_by_index(device, 0);
ratbag_profile_ref(p);
ratbag_device_unref(device);

Fix this by not using refs internally. After probe, the device is static
anyway, so the various refs internally aren't needed. Instead, we also ref/unref
the parent struct whenever we ref/unref a struct. Thus, whenevever the device
refcount reaches zero, we know the caller has no ref active.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:16:19 +10:00
Peter Hutterer
409fd9abca Add ratbag_profile_destroy() and ratbag_button_destroy() helper functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:07:33 +10:00
Peter Hutterer
9f6a12fc48 Add a comment noting the initial refcount of the device and the context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:07:33 +10:00
Benjamin Tissoires
7b2a43f17c testdrv: make sure .remove() is called only once
And be sure to not call it twice if the sanity check fails.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-04 11:59:04 -04:00
Benjamin Tissoires
97bfc86165 prevent a segfault in sanity_check_device
If a device has missing profiles, profile will be null and we will
have a segfault.
Better say that the device failed the sanity check.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-04 11:50:49 -04:00
Peter Hutterer
28a94d0974 Add a test suite
Two components are added here: a test driver that takes a struct
ratbag_test_device and sets that device up as a ratbag device.
That device is returned to the tests and then checked for sanity.

The ratbag_device_new_test_device() requires the environment variable
RATBAG_TEST set, otherwise we abort. It's also 'hidden' in a separate source
file, so it won't show up in doxygen. And if the test are disabled, this
function does nothing and the test driver never gets registered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 16:28:43 -04:00
Peter Hutterer
967fd3fd33 Make ratbag_find_driver/ratbag_device_new non-static
For future use in the test suite

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 16:28:43 -04:00
Peter Hutterer
04fa488a22 Allow a NULL udev device for ratbag_device_new
The client-exposed API requires a valid device, but internally we can handle
NULL - this way we can hook up the test suite easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 16:28:43 -04:00
Peter Hutterer
9deaedbfc5 Add some device sanity checking
Don't allow devices with zero profiles, zero resolutions, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 16:28:43 -04:00
Peter Hutterer
2a5dca5084 Add a FIXME note to ratbag_profile_set_default/is_default
The etekcity seems to use the last profile as default. The G500s apparently
always comes up with the same profile but it's unclear if it's changeable.
This function may need to be removed later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 13:09:50 +10: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
Peter Hutterer
667b95e4c7 Change ratbag_device_init_udev to ratbag_device_init_hidraw
The udev-related bits are just a ref, the real logic is in the hidraw bits

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Peter Hutterer
c2da21a342 Add ratbag_device_destroy()
And use it for the error case instead of the current manual releasing of each
item.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Peter Hutterer
05e65b1310 Change ratbag_device_init into ratbag_device_new()
Same functionality

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Peter Hutterer
491fffad16 Drop ratbag_device_set_hidraw_device()
Unused as of 2fbf156403

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Peter Hutterer
2bcfb825c0 Misc code cleanups
Simplifying things, adding a bit of error checking, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Peter Hutterer
a1935a76ac Fix the log_bug_client macro
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 12:51:09 +10:00
Thomas Hindoe Paaboel Andersen
9011876d1b drop inconsistent null check
We do not check dev for null in any of the other functions. If it
was actually null then we would also already have got a null pointer
dereference earlier in the function.
2015-09-02 22:03:05 +02:00
Thomas Hindoe Paaboel Andersen
5f2d538e10 Avoid overflow when reading dpi list
LONG_MESSAGE_LENGTH is the length of the full message so we should
take the first parts of the union into account.
2015-09-02 21:59:06 +02:00
Thomas Hindoe Paaboel Andersen
f30ea0dc4d RATBAG_BUTTON_TYPE_UNKNOWN is not a ratbag_button_action
Just return a NULL. RATBAG_BUTTON_TYPE_UNKNOWN is 0 so no functional
change intendend here.
2015-09-02 21:40:05 +02: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
1e1dfd02fd Add a ratbag_device_get_svg_name() function
To retrieve which SVG file is associated to which device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 11:02:03 -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
77035a08ae etekcity: make sure action is valid before dereferencing it
This should never happen on the Etekcity Scroll Alpha, but we might end
up in a situation where this is required.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 10:36:40 -04:00
Benjamin Tissoires
9ccaaa9ea9 etekcity: retrieve the "on-to-go" setting
Still a mystery of what it is. Though I know how to get/set it, so let's
make it public until somebody claims what it is.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-02 10:35:33 -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
531651088c Expand the get/set_user_data functions
Otherwise the symbol leak test won't recognize it and fails. It's not worth
hacking up that test to avoid implementing those few, so just write them out
instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 17:03:34 +10: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
fe775e2b76 Fix doxygen for the driver interface
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
Peter Hutterer
0d4a7486de Add some more documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 09:05:53 +10:00
Peter Hutterer
2bc1ca0dce Remove a documentation FIXME, a wheel click is different to a middle click
This is the physical description of the button, so there's a distinct
difference between the two, even when the logical action is the same.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 09:05:53 +10:00
Peter Hutterer
0a6dd96185 Shuffle things around in the public header
Move the struct declarations together (and move ratbag_device to the ratbag
device page), have the defgroup tags at the top of the file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-02 09:05:53 +10:00
Thomas Hindoe Paaboel Andersen
1439ba0f66 remove needless null check
profile was already dereferenced earlier in the function and cannot
be null anyway from the current callers of the function.

Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
2015-09-01 22:36:19 +02:00
Thomas Hindoe Paaboel Andersen
89559b3720 fix error path in hidpp10drv_probe
If we goto err early then both dev and drv_data will contain
garbage values. We free one and dereference the other. Let's
null them and add proper checks.

Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
2015-09-01 22:34:34 +02: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
Benjamin Tissoires
051f92f980 etekcity: fix support of per axis resolution
In the end, we just ignore the sensitivity setting.
On the Etekcity, it looks like it is ignored by the mouse, or
maybe the Windows software just messes things up and should
not update the per-axis dpi when playing with sensitivity.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-01 09:48:11 -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