Commit Graph

340 Commits

Author SHA1 Message Date
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
Benjamin Tissoires
a9b9540edb data: update the SVGs to put a proper anchor for the texts
If the anchor of the text is on the left but the leader on the right,
there will be artefacts when changing the name. Make sure all of the
labels are prooperly set.

This forced us to also relocate the labels on the G500s and the etekcity
scroll alpha.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-03 16:22:22 -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
7a5db3d995 Update TODO with a short explanation why we don't have event processing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 13:07:19 +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
Benjamin Tissoires
b9376bdc67 tools: split out some shared functions
Allows to reuse them in other tools

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-09-02 22:20:00 -04:00
Peter Hutterer
3afc1ffdd8 Merge pull request #3 from phomes/master
A few cleanups
2015-09-03 07:50:27 +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
8b1ebc4caa data: add an SVG for the G500s 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
Benjamin Tissoires
4b9eae11d9 tools: cmd_info: if there is no profile, it's a bug...
...but we should not go further


Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-01 18:10:09 -04:00
Benjamin Tissoires
3d752a6d9d etekcity: add a svg representing the mouse and buttons
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-01 18:10:09 -04:00
bentiss
c46c334697 Merge pull request #2 from phomes/master
misc cleanups
2015-09-01 18:09:31 -04: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
bentiss
ad0ac1b6ea Merge pull request #1 from phomes/master
fix indentation
2015-09-01 12:05:38 -04:00
Thomas Hindoe Paaboel Andersen
6e21d75b5c fix indentation 2015-09-01 17:39:06 +02:00
Benjamin Tissoires
adc6b44242 update TODO
separate x/y resolution -> check!
has_capability for resolution -> check!
sensitivity -> new item

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