cvuchener / hidpp

Collection of HID++ tools
GNU General Public License v3.0
90 stars 23 forks source link

Add Illumination Light control interface for HID++ 2.0 #34

Open hadess opened 1 month ago

hadess commented 1 month ago

Just the power on/off is implemented for now.

Documented in x1990_illumination_v1.pdf in: https://drive.google.com/drive/folders/0BxbRzx7vEV7eWmgwazJ3NUFfQ28

hadess commented 1 month ago

Tested through USB and Bluetooth

cc @GeorgesStavracas

hadess commented 1 month ago

USB:

/dev/hidraw5: Logitech Litra Beam (046d:c901) HID++ 4.2

Bluetooth:

/dev/hidraw4: Litra Beam (046d:b901) HID++ 4.2
hadess commented 1 month ago

The monitor function isn't quite finished, as I can't get it to compile. That's the error:

FAILED: src/tools/CMakeFiles/hidpp20-illumination-light-control.dir/hidpp20-illumination-light-control.cpp.o 
/usr/lib64/ccache/g++  -I/home/hadess/Projects/jhbuild/hidpp/src/libhidpp -std=gnu++17 -MD -MT src/tools/CMakeFiles/hidpp20-illumination-light-control.dir/hidpp20-illumination-light-control.cpp.o -MF src/tools/CMakeFiles/hidpp20-illumination-light-control.dir/hidpp20-illumination-light-control.cpp.o.d -o src/tools/CMakeFiles/hidpp20-illumination-light-control.dir/hidpp20-illumination-light-control.cpp.o -c /home/hadess/Projects/jhbuild/hidpp/src/tools/hidpp20-illumination-light-control.cpp
/home/hadess/Projects/jhbuild/hidpp/src/tools/hidpp20-illumination-light-control.cpp: In function ‘int main(int, char**)’:
/home/hadess/Projects/jhbuild/hidpp/src/tools/hidpp20-illumination-light-control.cpp:263:108: error: ‘class HIDPP20::Device’ has no member named ‘get’
  263 |                                 listener->addEventHandler (std::make_unique<IlluminationEventHandler> (dev.get ()));
      |                                                                                                            ^~~

Once it compiles, I'll extend that code to handle other events.

hadess commented 1 month ago

It compiles and works on my system, yay.

GeorgesStavracas commented 1 week ago

With Logitech Litra Glow:

$ src/tools/hidpp-list-devices 
/dev/hidraw12: Logi Litra Glow (046d:c900) HID++ 4.2

$ src/tools/hidpp-list-features  -v /dev/hidraw12
Logi Litra Glow (046d:c900) is a HID++ 4.2 device
Feature 0x01: [0x0001] Feature set
Feature 0x02: [0x0003] Device FW version
Feature 0x03: [0x0005] Device name
Feature 0x04: [0x1990] Illumination Light control
Feature 0x05: [0x1eb0] ? (hidden)
Feature 0x06: [0x00c2] DFUcontrol 3 (hidden)

[ Manually turned on the light ]
$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 state
    state: 1

[ Manually turned off the light ]
$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 state
    state: 0

$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 toggle
[ Light turned on properly ]

$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 toggle
[ Light turned off properly ]

[ Manually turned on the light ]
$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 brightness
    brightness: 84
    min: 20
    max: 250
    res: 1
Error code : Invalid function ID

So all seems fine with this model. The last call had an invalid function id but this seems expected given the PR description.

Will do a similar test with the Litra Beam later.

hadess commented 1 week ago

Looks like the Litra Glow doesn't have a "max effective" brightness. I think the commit I added should let the brightness command run through without any errors.

Have you tried the temp command? I don't know if that light has support for it.

GeorgesStavracas commented 1 week ago

Looks like the Litra Glow doesn't have a "max effective" brightness. I think the commit I added should let the brightness command run through without any errors.

Okay I'll try it soon.

Have you tried the temp command? I don't know if that light has support for it.

I didn't test it, but this is what it outputs:

$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 temp
    temperature: 5000
    min: 2700
    max: 6500
    res: 100

This is without the latest commit. So I think it's working fine.

GeorgesStavracas commented 1 week ago

With the latest commit:

$ src/tools/hidpp20-illumination-light-control -v /dev/hidraw12 brightness
    brightness: 84
    min: 20
    max: 250
    res: 1
    effective max: 250

I think it fixed it!