1
0
forked from drath/libratbag
Commit Graph

258 Commits

Author SHA1 Message Date
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
Peter Hutterer
e182faa452 hidpp: add a couple of HID++ task_id mappings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 11:18:39 +10:00
Peter Hutterer
b4d6c3064a hidpp: add a couple of HID++ control_id mappings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 11:18:39 +10:00
Peter Hutterer
ef15072691 hidpp: replace the button mappings structs with a macro
No functional changes, this is in preparation for the future to make
replacing bits a bit easier - hopefully we only have to change the macro and
not every element then.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 11:18:39 +10:00
Peter Hutterer
5cb15524d4 hidpp: move the button lookup tables to the generic code
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-01 10:55:19 +10:00
Thomas Hindoe Paaboel Andersen
29c0220eb2 etekcity: fix check for Y sensitivity 2015-09-01 09:06:27 +10:00
Benjamin Tissoires
c288ab0cbf etekcity: do not unref the active profile while in probe()
Left over from 49d70577c ("Replace get_active_profile with
profile_is_active")


Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-31 16:56:47 -04:00
Peter Hutterer
63e0ddc550 Add a LOG_LEVEL_RAW log level
Lower than debug, for spitting out all the protocol codes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 15:08:51 +10:00
Peter Hutterer
499ba42b16 doc: more documentation comments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:27:46 +10:00
Peter Hutterer
36f92cf91e Always init at least one resolution mode
The one mode may be disabled and not configurable, but it's still more
predictable to have one that none.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:21:49 +10:00
Peter Hutterer
d620683e38 Add a helper function to init a resolution mode
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:21:49 +10:00
Peter Hutterer
ddfd408183 driver-hidpp10: return ENOTSUP for missing bits, not just -1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:06:17 +10:00
Peter Hutterer
aa27fbae8d Remove the get_active_profile driver hook
Long-term we should have probe() and read_profile(), the latter of which
should read each profile and fill in _all_ information.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 12:05:52 +10:00
Peter Hutterer
f5340d31e3 Remove the old resolution/report rate getters/setters
They already got removed from the library, only the declarations were left.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:57:58 +10:00
Peter Hutterer
57dffdcb26 Add documentation for the resolutions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:30:49 +10:00
Peter Hutterer
0d951724dc driver-hidpp10: hook up the active profile bits
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:16:48 +10:00
Peter Hutterer
49d70577c0 Replace get_active_profile with profile_is_active
And the same for set_active_profile -> set_active. This API is more reliable,
the previous incarnation required the client to compare pointer values.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 11:04:58 +10:00
Peter Hutterer
7410939f88 Rename "ratbag" to "device" for ratbag_device structs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 10:29:25 +10:00
Peter Hutterer
d32abed1e9 driver-hidpp10: return the currently active profile
Data is bogus, but let's implement it anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 10:22:02 +10:00
Peter Hutterer
e1836583a5 Add ratbag_resolution_set/get_default
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-28 09:49:03 +10:00
Benjamin Tissoires
84b0195688 hidpp20: initialize the profiles when the device has been enumerated
When we read the profiles, we need to know the capabilities of the device.
If the device has not been enumerated, then we are screwed.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 18:11:38 -04:00
Benjamin Tissoires
28280240cb read only once from the mouse
given that we create all the buttons and profiles during probe(), there
is no need to re-probe for it every time we access it.
Right now, this works because only ratbag-command uses the library and
is a one shot program.

In the future, we should also read the events to detect changes in the
configuration if the user can use physical buttons to change the profile,
dpi or something else.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 18:10:44 -04:00
Benjamin Tissoires
88a2aea3c2 etekcity: retrieve and dump the macros
Still not hooked up in the library, but re-assigning back a different
hard-coded macro works.

This also re-introduce the dependency on libevdev for the lib.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 17:49:16 -04:00
Benjamin Tissoires
2309228dbe drivers: make .write_resolution_dpi() takes the resolution, not the profile
This allows to set whichever resolution we want within the profile.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 15:27:08 -04:00
Benjamin Tissoires
4251042a0d etekcity: implement switch-dpi functionality
the current driver API is not good enough. We should be able to say
which DPI setting we want to change. Thus, the external API is not
correct either.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 15:15:36 -04:00
Benjamin Tissoires
17a384de82 etekcity: retrieve the dpi settings in the mouse
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 15:14:19 -04:00
Benjamin Tissoires
07e231d705 etekcity: reduce the latency between each profile retrieval
Looks like 10 ms is enough to not have the mouse getting lost.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 14:54:18 -04:00
Benjamin Tissoires
2f69a70acc hidpp20: restore the dpi functionality
We need to store the profile in each ratbag_resolution or we will not be
able to get back to the driver.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-27 14:30:50 -04:00
Peter Hutterer
7da10cc074 Add resolution modes
The devices we're dealing with all have multiple DPIs to configure. This API
will replace the current ratbag_profile_set_resolution_dpi() and friends.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 17:02:15 +10:00
Peter Hutterer
6a2b4afa7b Sort libratbag.sym
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 16:51:21 +10:00
Peter Hutterer
cf834018c5 Split the doxygen up into device, profile, button
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 13:06:24 +10:00
Peter Hutterer
e5f5cdca17 Add an API to check if an action type can be configured for a device
This is just a placeholder for now, not yet implemented.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 13:00:58 +10:00
Peter Hutterer
be58d91c63 Fix compiler warnings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 12:27:48 +10:00
Peter Hutterer
ba3330894f Add the various set/get_user_data() functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 12:17:58 +10:00
Peter Hutterer
87e17ff951 Fix a doxygen reference
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 12:11:02 +10:00
Peter Hutterer
2fbf156403 hidpp10: use 0x00 to talk to all devices, skip receiver handling
The kernel overwrites the device ID with the correct one for our device, so we
can just use 0x00 for all devices and skip the search for the unifying
receiver hidraw device.

Since we're not talking to the receiver anymore, we can/have to drop the
pairing information queries and the related info. Since we weren't using this
anyway it's not a big loss.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 11:42:48 +10:00
Peter Hutterer
25aeaa68d6 Add a 1s timeout to libratbag_hidraw_read_input_report
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 11:16:06 +10:00
Peter Hutterer
3bf35ce282 Drop an incorrrect FIXME comment
The mouse supports profiles and we can read them already, it's the mac
software that appears crippled here. And each profile has up to 5 dpi modes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-27 08:06:23 +10:00
Benjamin Tissoires
d82ee06bfd Call only once per button per profile .read_button
ratbag_profile_init_buttons() already loops over the given number of
buttons.
Remove the extra for loop and save some CPU (and possibly USB depending on
the driver) cycles.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 16:59:39 -04:00
Benjamin Tissoires
6bc44f4d5f Factor out ratbag_button_action_match
This will be used often in drivers, so let's have a helper for it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 16:55:29 -04:00
Benjamin Tissoires
08a568aed2 hidpp20: fix after button type revamp
the logical and physical bits were inverted:
- logical is the action of the button
- physical corresponds to the actual button on the mouse (so the 'type')
- there is a duplicate from driver-etekcity to match 2 actions, this should
  be factorized in a helper somewhere in a later commit

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 16:48:03 -04:00
Benjamin Tissoires
7ba2c7cee7 etekcity: check for return values before using them
If action is NULL, that's a problem.
If etekcity_button_action_to_raw() returns 0, we should not try to write
0x00 in the profile. The proper command for "none" is 0x06. 0x00 is thus
an error.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04:00
Benjamin Tissoires
1b5eb84ac4 Export a button_disable function
This sets a button to RATBAG_BUTTON_ACTION_TYPE_NONE when we want
to disable a button completely.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04:00