1
0
forked from drath/libratbag
Commit Graph

74 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
3f6e94dfc6 Move driver checks into ratbag_register_driver
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:10:40 +10:00
Peter Hutterer
1923ff6035 driver-hidpp10: set the report rate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 17:10:23 +10:00
Peter Hutterer
0d97c99306 driver-hidpp10: override the hidraw device for unifying receivers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:37:41 +10:00
Peter Hutterer
3782b37853 Drop the 'device' argument from libratbag_device_set_active_profile
The profile is bound to a device anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Peter Hutterer
cea9bc6290 Drop some unneeded parameters where we have a way to get it anyway
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Peter Hutterer
82338aadcd Use strneq instead of strncmp
Less error-prone

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Peter Hutterer
d73d9f6023 Rename ratbag_device structs to "device"
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 11:55:35 +10:00
Peter Hutterer
25580e1060 Drop device handle from the button, the profile has it
...and buttons must be part of a profile.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-22 16:15:21 +10:00
Benjamin Tissoires
88154c2438 hidpp20drv: implement button remapping
Problem: when a button is diverted, it stops sending its original button,
which is good, but then reports only on the HID++ long report collection.

That is a little bit embarrassing.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 15:50:01 -04:00
Benjamin Tissoires
cf4a932d34 Implement set profile resolution dpi
Works only in Logitech with adjustable DPI for now (MX Master).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 13:26:43 -04:00
Benjamin Tissoires
64cfad665d Implement reading the resolution of the sensor
Should work with adjustable DPI and fixed DPI for Logitech devices.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-21 13:26:43 -04:00
Peter Hutterer
529a69e120 Split HID++ 1.0 into a separate driver
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 15:11:57 +10:00
Peter Hutterer
b15923d620 Rename the unifying driver to hidpp20
This driver is really a driver for HID++ 2.0 devices, not just for devices on
the unifying receiver.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 11:11:47 +10:00
Benjamin Tissoires
06e17daff6 Revert "Add a hack to find the hidraw device for the logitech recievers"
This reverts commit 589f249c95.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 12:17:41 -04:00
Benjamin Tissoires
f2bec4d8f7 add log buffer functionality
Useful to debug the incoming and outgoing data.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 11:40:11 -04:00
Benjamin Tissoires
01738398a5 Fix F23 compilation
add missing headers for fstat and struct stat

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2015-08-20 09:47:57 -04:00
Peter Hutterer
95c8baa043 Move the m705 driver to libratbag proper
Note that this doesn't do anything yet, it's stubbed out everywhere except for
the button mapping bit where we already had some testing code from uLogitech.

This also adds the ID for the m570 trackball - a device I have available here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 16:08:57 +10:00
Peter Hutterer
589f249c95 Add a hack to find the hidraw device for the logitech recievers
Their device is two parents up from the event node.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Peter Hutterer
2cbba23010 Skip over devices that don't have a hid-subsystem parent
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Peter Hutterer
9f518bed0c Drop device/profile arguments from driver read_button/write_button
The button struct contains references to both.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Benjamin Tissoires
d7cd776faf Add a ratbag_button_set_type
This might not be part of the final API, but it is rather convenient
to use right now.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 14:14:01 -04:00
Benjamin Tissoires
52e477dd07 Make INFO as the default log level
Now that we are actually using a verbose option, it does not make sense
to output the debug messages by default.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 11:34:09 -04:00
Benjamin Tissoires
70df100e49 Fix ratbag_button_get_type
we should return the actual type.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-19 10:52:16 -04:00
Peter Hutterer
2c2ac08a3b Improve a couple of log messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 14:10:51 +10:00
Peter Hutterer
34dcd2aec1 Add some more function stubs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 13:59:36 +10:00
Peter Hutterer
d48fecf550 Add ratbag_device_ref
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:15:20 +10:00
Peter Hutterer
44a675534e Rename "libratbag" to just "ratbag"
Naming scheme is now:
* ratbag - the context
* ratbag_device - the device
* ratbag_profile
* ratbag_button
...

Only leftovers of "libratbag" are the header file name, #defines that are
exported through that header file and anything that has to do with the actual
library iself (e.g. the symbol export file).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:15:20 +10:00
Peter Hutterer
b8be026032 Rename "struct ratbag" to "struct ratbag_device"
Less ambiguous naming this way

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 12:15:20 +10:00
Peter Hutterer
e6788c4905 Rename some 'device' args to 'udev_device'
For better namespacing

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-19 11:50:32 +10:00