Commit Graph

50 Commits

Author SHA1 Message Date
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
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
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
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
d444e2e1e8 hidpp10: use log_debug for HID++ errors
HID++ 1.0  doesn't have an index of functions available, so we pretty much
have to bang every request against the device, full of hope and optimism.
Reality demands that some of them fail and we handle that, but we don't need
to worry the user by screaming errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:57:43 +10:00
Peter Hutterer
66d4d33857 hidpp10: rename hidpp10_buttons to hidpp10_button
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 09:38:14 +10:00
Peter Hutterer
1d80ea4898 hidpp10: store the number of dpi_modes/buttons in the profile
Makes it easier to iterate through the profile without relying on global
variables.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:55:25 +10:00
Peter Hutterer
cab9169e6f hidpp10: actually return the profile when we're fetching it
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:52:49 +10:00
Peter Hutterer
a4356f21ba hidpp10: add more debugging information
To make it easier to find what failed in the wall of hexcodes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-26 08:11:59 +10:00
Peter Hutterer
98165fec0e hidpp10: add code to read the profile
Profiles are... interesting
https://github.com/cvuchener/g500/blob/master/doc/profile.md is pretty
detailed on the information, but there's some oddities.

The profile configured on my mouse is on page 5, not sure if that's the OS X
logitech tool though (which doesn't do profile configuration btw). Pages 3 and
3 are valid too, the rest looks to be garbage.

There's probably some magic string to detect a profile (cvuchener says maybe
FF 00 00 80), so more profiles may be lying around elsewhere in memory...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 16:58:00 +10:00
Peter Hutterer
e8b15ba7ee hidpp10: fix a comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:14:19 +10:00
Peter Hutterer
4fca750977 hidpp10: make the device init API slightly more sane
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 14:13:17 +10:00
Peter Hutterer
7d53adb3c3 hidpp10: revamp to only pass a hidpp10 device around
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:41:03 +10:00
Peter Hutterer
eba5a2b387 hidpp10: store the ratbag device ref in the struct
Saves us passing two args around everywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 12:28:48 +10:00
Peter Hutterer
f944f2410a hidpp10: convert the optical sensor bits into a function sensor
And it looks like the first byte is the surface quality

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
ad899506a7 hidpp10: convert get_usb_refresh_rate to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
24c23a3f13 hidpp10: convert get_hidpp_notifications to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
aadfefe752 hidpp10: convert enable_specific_feature into proper functions
This also changes from the "toggle" to a plain "set". If a caller needs to
toggle a specific function, it can run get + set instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
18f4e13b59 hidpp10: add set_led_status
Only enabled for 4 leds and I'm not even sure they're the same on all
devices. Still, works on the G500s so that's a good enough start.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
0891510d32 hidpp10: convert get_led_status to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
d1aec43c18 hidpp10: switch get current resolution to a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
40ea55729c hidpp10: split pairing information into a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
268fbbbf40 hidpp10: convert fw information fetching into a proper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-25 11:21:32 +10:00
Peter Hutterer
33455a3245 hidpp10: store the resolution/refresh rate in the hidpp device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 17:00:33 +10:00
Peter Hutterer
aa6ded5d03 hidpp10: fix device type table
looks like a copy/paste-o

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:22:07 +10:00
Peter Hutterer
f5e62bd80c hidpp10: use helper function to extract wpid/build information
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 16:21:11 +10:00
Peter Hutterer
1b696397c7 hidpp10: shuffle things around to tidy up a bit
Looks a bit more like the hidpp20 driver now, and easier to get a handle on
everything. Command-specific functions/defines are grouped together and sorted
by command index.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:22:08 +10:00
Peter Hutterer
61377554ef hidpp10: move the various defines into the c file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:04:30 +10:00
Peter Hutterer
872d522364 hidpp: move the shared defines into a generic header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:03:29 +10:00
Peter Hutterer
bbec568055 hidpp10: use quotes for local includes, not lt/gt
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 15:01:31 +10:00
Peter Hutterer
a0d882d2e5 hidpp10: implement refresh rate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
adf1b9a99d hidpp10: add Optical sensor settings command
From:
https://github.com/cvuchener/g500/blob/master/doc/report.md
but we don't know what the return value is...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
ed320bcdea hidpp10: add resolution and LED status
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
58585bfb19 hidpp10: switch the idx base to 1, not 0
Only two receiver-specific requests have a 0-based index, everything else
wants 1-indexed devices. This currently makes it impossible to address wired
devices with a device index of 0. Switch it around, so that we use a 1-based
index.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
f5df7f0ec9 hidpp10: split the commands into helper functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 14:41:46 +10:00
Peter Hutterer
ecca960bd9 hidpp10: __u8 -> uint8_t
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
1b799d2d84 hidpp10: only run the pairing information commands if the first one succeeds
Still try to run the other commands though, they're not receiver-related and
may work on a device that's not on a unifying receiver.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
e5df589c84 hidpp10: fix up coding style a bit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:14 +10:00
Peter Hutterer
1563efd988 hidpp10: request individual features
Not doing anything with it, this is just playing around.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:38:08 +10:00
Peter Hutterer
4c7fb6f803 hidpp10: Add support for the HID++1.0 Notifications request
They're off by default, but I have to start testing somewhere...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-24 13:37:43 +10:00
Peter Hutterer
35b5fa975e hidpp: Log the errno including strerror
Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:01:52 +10:00
Peter Hutterer
7f2d060ff9 Make libratbag-hidraw return negative errnos on error
Be consistent here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-21 10:01:52 +10:00
Benjamin Tissoires
1112a46d87 hidpp10: remove the hard dependency on struct hidpp10_device for hidpp10_toggle_individual_feature
Starting with kernel v3.19, the hidraw node associated to the input node
talks the the actual device, no matter which device index is given.

There is no need to really know which device has which index thus.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 13:08:39 -04:00
Benjamin Tissoires
9df3cd4128 hidpp10: various __u8 __u16 hunt
replaced by uint8_t and uint16_t

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 12:14:17 -04:00
Benjamin Tissoires
c32c1471cb hidpp10: switch to libratbag debug system
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 12:13:45 -04:00
Benjamin Tissoires
29b72c1a94 hidpp10: use ratbag_hidraw* commands, not plain access to the fd
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-08-20 10:46:21 -04:00
Peter Hutterer
279bceb2d7 Drop unifying src files, use hidpp10 instead
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Peter Hutterer
e9230aef5f Fix an unsigned vs signed compiler warning
In file included from hidpp10.c:43:0:
hidpp10.c: In function 'hidpp10_get_device_info':
./libratbag-util.h:76:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define min(a, b) (((a) < (b)) ? (a) : (b))
                         ^
hidpp10.c:251:12: note: in expansion of macro 'min'
  dev->name[min(name_size, sizeof(dev->name) - 1)] = '\0';

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Peter Hutterer
724d59ba57 Fix a compiler warning
hidpp10.c:71:11: warning: initialized field overwritten [-Woverride-init]
  [0x06] = "ERR_ALREADY_EXISTS",

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00
Peter Hutterer
f36f4d22a7 Start moving uLogitech files into libratbag proper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20 14:59:46 +10:00