Commit Graph

240 Commits

Author SHA1 Message Date
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
Benjamin Tissoires
cc5c539fdb etekcity: fix the retrieval of the raw code given the action
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:13:11 -04:00
Benjamin Tissoires
11d1a111a0 tools: dump the action mapped to the buttons
The buttons are given as plain numbers, not sure if we should
use BTN_LEFT, BTN_RIGHT, etc instead.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 13:12:27 -04:00
Benjamin Tissoires
52683a866c Fix copy/paste-o in ratbag_button_get_special
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 12:15:14 -04:00
Benjamin Tissoires
34d1550676 etekcity: register that 0x10 is a macro
Still not able to express this to user space

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:59:44 -04:00
Benjamin Tissoires
3ad0cacd0d Cleanup the profiles and buttons on exit
Now that the profiles and buttons have to be created once by the probe()
function, we need to clean them up when the device is unref-ed.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:54:56 -04:00
Benjamin Tissoires
d58ef45cfb etekcity: fill the type field of the buttons
This adds two button types: pinkie and pinkie2 when there are buttons
on the right side of the mouse.

OK, I could have called them left-handed-thumb.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:40:24 -04:00
Benjamin Tissoires
b11c1f30f3 etekcity: rename local variable index into raw_index
this index is the position of the button in the report, so it's misleading
to keep it as "index". The actual index is the button->index.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:32:43 -04:00
Benjamin Tissoires
701c1b7d36 etekcity: the mouse has ten buttons, not nine
the button index starts at 0, so we need to add 1 to the max button number.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:31:41 -04:00
Benjamin Tissoires
c28edd2411 Add the ratchet mode switch button type and action type
Found on the Logitech MX Master. Most of other Logitech device with
physical ratchet disable capability do not show this button to the host
however.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-26 11:01:25 -04:00
Peter Hutterer
7db22756b7 Revamp button action handling
One giant commit, but I didn't know how to split this up easier. The problem
is a misunderstanding in what the button type is and the code that built on
that misunderstanding, requiring a lot of interdependent parts to be updated
at once.

The button _type_ is the physical description of the button.
The button _action type_ is what will happen when you hit the buttons.

The type is read-only, since we're not dealing with mr potato head here.
The action is adjustible and we now support buttons, keys and special
in-hardware actions (e.g. dpi changes). A few FIXMEs still in place, e.g. we
don't handle modifiers with keys.

For buttons we just take numerical button numbers. i.e. we can map a button to
button 4, which will result in BTN_SIDE, and eventually logical button 8 in X.
For keys we take KEY_FOO, since eventually we want this to come out as that
(could do this for button as well I guess). Modifiers are currently ignored.
For special actions we have a enum of actions we support.

The button type enum is thus reduced a lot, and everything needs to be
switched.

This breaks ratbag-command change-button, will be fixed later since it's
misdesigned as it is anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 16:46:01 +10:00
Peter Hutterer
ec9456c940 Make a note that button_get_type is the physical type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:52:00 +10:00
Peter Hutterer
91a033f157 Don't create a button when requesting one
The drivers are responsible for initializing the buttons during probe(), then
we just return the one we found

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:52:00 +10:00
Peter Hutterer
5a6c687c96 Create buttons during profile init
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:59 +10:00
Peter Hutterer
40a08f2a55 Add ratbag_profile_init_buttons
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:31 +10:00
Peter Hutterer
abe3244f6b ratbag_create_button doesn't need a device argument
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:31 +10:00
Peter Hutterer
442eb6391c Initialize the profiles during driver startup
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:51:30 +10:00
Peter Hutterer
73c2966d5c Don't create profiles when trying to read it from the client
Make the driver responsible for creating them on startup, then just return the
one we already have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:48:15 +10:00
Peter Hutterer
6abf0733c4 Drop ratbag_button_get_identifier
This is something better handled by mapping the various button types into a
specific string on the client-side.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 14:48:15 +10:00