Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for G915 #198

Open
lukaszuznanski opened this issue Nov 15, 2019 · 89 comments
Open

Support for G915 #198

lukaszuznanski opened this issue Nov 15, 2019 · 89 comments

Comments

@lukaszuznanski
Copy link

lukaszuznanski commented Nov 15, 2019

Is there any way to run led controller for g915? "Matching or compatible device not found !"

lukasz@lukasz:~$ lsusb
Bus 001 Device 003: ID 046d:c541 Logitech, Inc. 
lukasz@lukasz:~/g810-led$ g810-led -dv 046d -dp c541 -tuk 1 -a 000000
Matching or compatible device not found !
lukasz@lukasz:~/g810-led$ g810-led -dv 046d -dp c541 -tuk 2 -a 000000
Matching or compatible device not found !
lukasz@lukasz:~/g810-led$ g810-led -dv 046d -dp c541 -tuk 3 -a 000000
Matching or compatible device not found !
@MatMoul
Copy link
Owner

MatMoul commented Nov 18, 2019

Hi, g915 aren't supported now, take a look at #188
Try your previous g810-led commands with sudo.

@0xh007
Copy link

0xh007 commented Feb 17, 2020

@lukaszuznanski Did you ever get this working? I tried running your commands as sudo with no luck

@yawor
Copy link

yawor commented Mar 10, 2020

I'm also trying to make this work on my G915. First I've built it normally and when I run:
sudo g810-led -dv 046d -dp c541 -tuk 1 -a 000000
I got Error: Can not write to hidraw, try with the libusb version

So I've recompiled it with libusb option and now when I run it in the same way as above, I don't get any message, but the return code is 1 and nothing changes on the keyboard. I've also tried with --tuk values 2 and 3.

@yawor
Copy link

yawor commented Mar 13, 2020

After doing some captures I've found out few things. The G915 (or the wireless dongle actually, identified by vid/pid 046d:c541) has three interfaces in USB descriptor, each containing one HID endpoint:
Interface 0 - Endpoint 0x81 - keyboard input
Interface 1 - Endpoint 0x82 - mouse input (used for multimedia keys)
Interface 2 - Endpoint 0x83 - used for all the G-features (LEDs, configuration etc).

The g810-leds has two modes of operation: hid and libusb.
In libusb case, the problem is visible right away: it assumes the keyboard uses interface 1 and endpoint 0x82 for communication, which is going to fail right away for G915, as it uses interface 2 and endpoint 0x83.
In hid mode, the code opens first hidraw interface it finds with given VID/PID and optional serial number (that's how hid_open function works; in case of G915, the serial number is unusable, because the dongle doesn't provide one). This fails because it tries to open interface 0 (I'm wondering how this works with other keyboards). For G915, the LedKeyboad::open should find all matching hid devices and filter by interface number (must be equal to 2), get the device path and use it with hid_open_path function instead.

LED control

There are at least 2 different commands to set LED colours

  1. Set up to 4 LEDs, each with its own color:
11 01 0b 1d [AA] [RR] [GG] [BB] [AA] [RR] [GG] [BB] [AA] [RR] [GG] [BB] [AA] [RR] [GG] [BB]

where AA is a led address and following it is the RGB value for that LED.
If less than 4 LEDs are being set, then first non-used AA value is set to 0xFF and the rest of the data is filled with 0x00. For example:

  • set 4 multimedia keys to color 1400ff:
    11 01 0b 1d 9d 14 00 ff 9e 14 00 ff 9b 14 00 ff 9c 14 00 ff
  • set backlight level button to color 707070:
    11 01 0b 1d 99 70 70 70 ff 00 00 00 00 00 00 00 00 00 00 00

Keyboard responds with

11 01 0b 1d [AA] [AA] [AA] [AA] 00 00 00 00 00 00 00 00 00 00 00 00

where AA are addresses of LEDs being set (positions not used are set to 0xFF).

  1. Set up to 13 LEDs to the same color:
11 01 0b 6d [RR] [GG] [BB] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA] [AA]

where first 3 bytes are RGB value, followed by 13 LED addresses (if less, then unused positions are set to 0x00).

Keyboard responds with:

11 01 0b 6d [RR] [GG] [BB] [AA] 00 00 00 00 00 00 00 00 00 00 00 00

where RGB is the same value as set in the command and AA is an address of the first LED in the command (I wonder if this is some bug - my keyboard is running on newest firmware).

  1. Commit color change:
11 01 0b 7d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Keyboard responds with the same data

@LindaLawton
Copy link

@yawor did you get this working? The issue is g915 but it closes g815 im confused.

Im still having no luck getting this to work with my G915 Im really tired of the random light show or no lights at all.

@yawor
Copy link

yawor commented May 1, 2020

@LindaLawton the G915 is identical to G815 regarding the protocol, except for the second byte in the request. This library (and keyleds too) sets this byte to 0xFF, which is fine for wired keyboards, as wired keyboards ignore this value. You can test this by unplugging the wireless receiver for G915 and plugging it with a USB cable to your PC. It'll work exactly like G815.

The problem with wireless keyboard like G915 is that, the second byte is not ignored anymore. It's used to select a device the software is talking to - this is because both the keyboard and the dongle are using Logitech's HID++ protocol. If the second byte is equal to 0xFF, then the software is not talking to the keyboard, but to the dongle - and obviously it doesn't work. The software needs to talk to the keyboard over the wireless link. To do that, the second byte needs to be equal to 0x01 in case of G915 and LightSpeed link.

The LightSpeed dongle is very similar to a Unifying one regarding the HID++ protocol usage. In case of Unifying the second byte does the same exact thing as LightSpeed, but values can be from 0x01 to 0x06 for up to 6 paired devices and 0xFF for the dongle itself. LightSpeed doesn't have pairing ability, so it only supports two values (0x01 for the keyboard and 0xFF for the dongle).

@yawor
Copy link

yawor commented May 1, 2020

If you look anywhere in the code where the request packet is created, you'll see something like:
https://github.com/MatMoul/g810-led/blob/master/src/classes/Keyboard.cpp#L383

data = { 0x11, 0xff, 0x0c, 0x5a };

What I mean is the second value, which is 0xff here and everywhere else.

@LindaLawton
Copy link

LindaLawton commented May 1, 2020

unplugging the wireless receiver for G915 and plugging it with a USB cable to your PC.

I have it plugged into a dock could this be the issue. Should i try pluging the wire directly into the laptop?

Interesting pulging it directly into the laptop its able to detect the actual name of it now

Bus 001 Device 008: ID 046d:c33e Logitech, Inc. G915 WIRELESS RGB MECHANICAL GAMING KEYBOARD

number is still the same as the number it was pulling off from the dock though

No change still cant access it.

linda@linda-ThinkPad-X1-Extreme-2nd:$ g815-led -dv 046d -dp c33e -tuk 1 -a 000000
Matching or compatible device not found !
linda@linda-ThinkPad-X1-Extreme-2nd:
$ g815-led -dv 046d -dp c33e -tuk 2 -a 000000
Matching or compatible device not found !
linda@linda-ThinkPad-X1-Extreme-2nd:~$ g815-led -dv 046d -dp c33e -tuk 3 -a 000000
Matching or compatible device not found !

I did try with the g815 commands and they failed. #233

@yawor
Copy link

yawor commented May 1, 2020

Try changing the USB PID from c33f to c33e everywhere in the code and udev rules to test it as wired.

@LindaLawton
Copy link

LindaLawton commented May 1, 2020

I only found two places in the code with c33f i changed them as you mentioned.

ran the following again.

linda@linda-ThinkPad-X1-Extreme-2nd:/g915/g810-led$ make lib LIB=libusb
g++ -Dlibusb -Wall -O2 -std=gnu++11 -DVERSION="0.4.0" -fPIC -shared -Wl,-soname,libg810-led.so -o lib/libg810-led.so.0.4.0 src/classes/Keyboard.cpp -lusb-1.0
linda@linda-ThinkPad-X1-Extreme-2nd:
/g915/g810-led$ sudo make install-lib
linda@linda-ThinkPad-X1-Extreme-2nd:~/g915/g810-led$ sudo make install-dev

No change.

linda@linda-ThinkPad-X1-Extreme-2nd:/g915/g810-led$ g815-led -dv 046d -dp c33e -tuk 1 -a 000000
Matching or compatible device not found !
linda@linda-ThinkPad-X1-Extreme-2nd:
/g915/g810-led$ g815-led -dv 046d -dp c33e -tuk 2 -a 000000
Matching or compatible device not found !
linda@linda-ThinkPad-X1-Extreme-2nd:/g915/g810-led$ g815-led -dv 046d -dp c33e -tuk 3 -a 000000
Matching or compatible device not found !
linda@linda-ThinkPad-X1-Extreme-2nd:
/g915/g810-led$ g815-led -an 000000

question

What is the exact format of the packets we are sending here. Is there any way i can test one of those manually without the library just to test that it even works.

@yawor
Copy link

yawor commented May 3, 2020

@LindaLawton actually I'm also having issues trying this library to get to work, even though it should with the changes I've described above. It doesn't work with either hidapi or libusb. You can check G915 branch in my fork (https://github.com/yawor/g810-led/tree/g915) to see if it works for you. I had a strange behaviour where the keyboard stopped working at all and I had to turn it off and on using power switch and even use a different keyboard to disable g810-leds to get it working again (this was on libusb).

I've also been playing around with keyleds library and there I was able to get the communication with the keyboard going (over hidapi), but the current version and structure of the library doesn't allow easy implementation of led control with G815/G915. I've been discussing this with the author of keyleds and he has some plans how to make it more flexible, but I think the main issue is the lack of time.

I've also been writing my own tests using hidapi in Python and I've been able to control LEDs on my G915. If I have some time I could post it somewhere for you to play around, but these are just scraps of code put together quickly to test if it works. I've actually started planning my own application in Python for these new keyboards, but it's not on my priority list right now.

Regarding the protocol itself, it's a proprietary Logitech HID++ protocol (version 4.0 or 5.0, I don't remember). There's some documentation laying around the Internet, but most of it is outdated. The protocol is modular - on the hardware (like keyboard, mouse or game controller) there can be multiple services and the device can return IDs of these services and a value which is then used to access their APIs. G815/G915 keyboards actually share most of the services with older keyboards, but LED and effect controls are newer ones.

@LindaLawton
Copy link

LindaLawton commented May 3, 2020

I have been trying to use the Hub from windows and saving this to the board and thats not working either i keep getting this random cycling though the different color presets.

Its a great board for programming but i really cant take this color changing. My G11 worked fine.

Im not going to be much help with rewriting it in c++ i haven't coded that in fifteen years.

@yawor
Copy link

yawor commented May 3, 2020

@LindaLawton on the keyboard itself, you can access multiple build-in color presets by pressing backlight button + a number key from the main area (not numpad). The build-ins are under 1-7 and 0 (1-7 are different animations, 0 sets everything to Logitech blue). You can also use backlight button + "+" or "-" keys to increase and decrease animation speeds.
There are also two slots (under keys 8 and 9) for user defined color presets. You can store them from the Logitech Hub software. You define it first in the Hub software and then assign the preset to keys 8 or 9 in keyboard settings in the Hub software.
Unfortunately the keyboard doesn't remember the last used stored preset, so if you press BL button + 8 for example and then power cycle the keyboard, it'll switch to default one. But there's also a solution for that. You can change build-in settings for M keys. You can do that also from keyboard settings in the Hub software. If I remember correctly, to change them, you need to switch mode of the keyboard by disabling software management in the settings. After that the Hub software gives you the ability to actually store settings on the keyboard itself. When you do that, you can for example assign your stored color preset (for example BL+8) to be a default preset for M1.

@LindaLawton
Copy link

LindaLawton commented May 4, 2020

backlight button + a number key from the main area (not numpad). The build-ins are under 1-7 and 0 (1-7 are different animations, 0 sets everything to Logitech blue). You can also use backlight button + "+" or "-" keys to increase and decrease animation speeds.

Yes i have that. But the issue is after about 30 seconds - 2 minutes it changes which color setting its using and I get another random one wither it be rainbow effect or water splash effect you never know its totally random.

I am trying to use this as my daily driver for coding the effects are distracting. Its a keyboard i just want one static color. I think we will be bringing this back tonight its to expensive of a keyboard to not be working properly.

My husband says its my fault for not checking if Linux was supported. Its a keyboard why would it need software. You plug them in the turn on and they work. There used to be a standard for peripheral devices.

@yawor
Copy link

yawor commented May 4, 2020

Well, it's a "gaming" thing 😏.
Anyway, this is strange. I don't experience any randomness at all. I've set it up once using Logitech Hub software and I'm using it with my own static backlight preset with my Linux laptop (which is my main machine). I don't have any special software installed, it's just what's set in the HW.
Btw did you upgrade the keyboard's firmware? I upgraded mine in Hub when I connected it to a Windows machine for the first time.

@LindaLawton
Copy link

Well, it's a "gaming" thing 😉.

I play games to but dont need a light show. Think its an age thing. 😉

Yeah it updated on windows. I over wrote all the M1 -M3 as well as brightness 0 and 9. When it goes into sleep mode now it comes with a light show. Once i touch it it seams to remain static until i stop typing again.

So what your saying is that i should be able to configure it from windows to stop the light show? and it will remain static in Linux?

I was starting to wonder if it was something in Rider or Webstorm that was setting off that extra bit.

@yawor
Copy link

yawor commented May 4, 2020

I only get the light show when I explicitly select it with backlight button + one of the number keys. Other than that it's always static. It's static when I power it on and when it goes to sleep and wakes up.

Here are my settings:
FW: 9.1.35

First I've configured everything with ON-BOARD MEMORY MODE: Off

In my Default profile I've changed only G keys to be empty (I'll maybe change them in the future).
My lighting preset is set to Freestyle with my own colors applied to different sections.

Low Battery Mode (Auto):
Breathing Red (Logo Only)

Inactivity Lighting:
Dim Brightness 50%
Start after: 1 minute
All lights off after: 5 minutes

Stored Custom Lighting:
KEY 8: my preset
KEY 9: not set

ON-BOARD MEMORY MODE: On
All M slots are set to Default profile with Lighting set to lighting preset stored on KEY 8.

@MatMoul MatMoul mentioned this issue May 8, 2020
@mienkofax
Copy link

mienkofax commented May 15, 2020

Hello, I tried @yawor branch with G915 support but i have problem with set keys, not working, only all leds are disabled. Have you a small example, that set led of key? For example Python or C++

open usb
write, sets led of key 
close

Wireshark usb dump, set logo
https://github.com/mienkofax/keyboard/blob/master/g915_logo_set.pcapng

@yawor
Copy link

yawor commented May 15, 2020

@mienkofax I've tried porting this quickly. It doesn't work for me either. Maybe I've missed some parts of code that also need to be changed. It needs debugging. My fork can be used as a base to work further on this.
I don't have access to the keyboard until Tuesday.

@MatMoul
Copy link
Owner

MatMoul commented May 15, 2020

For info, I've made a small tool named rawwrite in led-g810-resources (hidapi only) :
https://github.com/MatMoul/g810-led-resources/tree/master/tools/rawwrite
The tool help a lot for testing :
sudo ./rawwrite vendorID productID rawdata
as ex :
sudo ./rawwrite 046d c541 11ff107c00000000000000000000000000000000

@mienkofax
Copy link

mienkofax commented May 15, 2020

Thank you for info @yawor. @MatMoul this tool is very very helpful. I tried it, but I have a problem writing to the hid hid_write() -> Error: Can not write to hidraw

I captured communication (https://github.com/mienkofax/keyboard):

  • disable all leds
  • disable leds on the arrows
  • enable leds on the arrows
  • enable led for key w

And I tried run tool with:

./bin/rawwrite 046d c33e 10ff0e3c000000
sleep 0.001
./bin/rawwrite 046d c33e 10ff0e1c000000
sleep 0.001
./bin/rawwrite 046d c33e 10ff142c000000
sleep 0.001
./bin/rawwrite 046d c33e 10ff131c000000
sleep 0.001
./bin/rawwrite 046d c33e 10ff131c000000

But after all commads: Error: Can not write to hidraw

Example: disable all leds
First command from Logitech Ghub, wireshark:
image

I send: ./bin/rawwrite 046d c33e 10ff0e3c000000

My submitted data, captured request using wireshark
image

And response:
image

I'm a beginner in this domain, sorry, but I want to help. I think it will be just a trifle, e.g. padding or maybe typo.

Thank you very much for any help.

Edit: All commands were sent under sudo user.

@MatMoul
Copy link
Owner

MatMoul commented May 15, 2020

@mienkofax sudo ?
Or run rawwrite as root...
And productID seem to be c541 for the G915

@mienkofax
Copy link

@MatMoul, yes I run with sudo and I tried run under sudo user, nothing helped. Data was probably sent, wireshark capture, but maybe message format is not correct.

G915 supports two types of connection:

  • usb cabel: Bus 001 Device 023: ID 046d:c33e Logitech, Inc. G915 WIRELESS RGB MECHANICAL GAMING KEYBOARD
  • wireless - Lightspeed: Bus 001 Device 024: ID 046d:c541 Logitech, Inc. USB Receiver

@MatMoul
Copy link
Owner

MatMoul commented May 24, 2020

@mienkofax Thanks for the infos...
It seem that the g915 need to be adressed with these 2 differents product ID...

@GitJamz
Copy link

GitJamz commented May 30, 2020

Hi all.
Im no coder whatsoever. Im just a linux user (beginner in linux) that want to use this keyboard with my manual colors.
The only way is the way described above right? To set it up in windows according to @yawor instruction couple posts up. Did anyone else try this yet?
I have the G915 right now but Ive pro-ordered the 915 TKL keyboard that will arrive in a week.. I will try this out then.
Right now I have the exact same issue as @LindaLawton . I can press lightkey + 0 and it becomes static for a little while. Then it begins its lightshow again..

@GitJamz
Copy link

GitJamz commented Jan 10, 2021

@yawor just to be clear, whenever your keyboard "sleeps" it still goes to rainbow effect right? Until you wake it up. Or have you managed to fix that somehow?

My keyboard has my profile as long as it is active, but as soon as Im inactive for a few minutes it goes in to rainbow. But when I wake it up it works again.

@yawor
Copy link

yawor commented Jan 10, 2021

@GitJamz no, my keyboard dims when goes to low power mode. The dimming actually switched all keys to dim orange. It goes back to my profile on any activity.

@GitJamz
Copy link

GitJamz commented Jan 10, 2021

@GitJamz no, my keyboard dims when goes to low power mode. The dimming actually switched all keys to dim orange. It goes back to my profile on any activity.

Weird.. I have tried to set it to dim also in the software but it goes in to rainbow anyways,,
Do you mind posting a screenshot of your logitech gaming software setup so one can see exactly how you set it up.. ?

@yawor
Copy link

yawor commented Jan 10, 2021

@GitJamz I've already posted them some time ago. Take a look here: #198 (comment)

@behrangsa
Copy link

Hi all,

I have installed g810-led using apt., but I too can't configure my G915 keyboard in Linux:

lsusb

$ lsusb  | grep Log
Bus 007 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 007 Device 002: ID 046d:c541 Logitech, Inc. USB Receiver
Bus 007 Device 006: ID 046d:c33e Logitech, Inc. G915 WIRELESS RGB MECHANICAL GAMING KEYBOARD

g910-led

$ g910-led --list-keyboards
Matching or compatible device not found 

Is there anyway I can help with finding the culprit?

@changemenemo
Copy link

+1 for the g915 TKL and I would love to be able to use the echo press profile which can't be sync with any profile on the keyboard or maybe I missed something

@yawor
Copy link

yawor commented Aug 23, 2021

I've just created PR #267 which adds support for G915. You need to build it using libusb, it won't work with hidraw. Also right now only wireless mode is supported.

Wired mode requires extra work, but it is also possible. Main problem with support for both wireless and wired modes is that wired mode has higher priority on the keyboard and actually disables wireless connection, but the keyboard is also still visible as wireless in the system (so it shows as two keyboards, but only wired works in that case).

If anyone is interested, I've also created a PR adding G915 support in OpenRGB project.

@GitJamz
Copy link

GitJamz commented Aug 23, 2021

I've just created PR #267 which adds support for G915. You need to build it using libusb, it won't work with hidraw. Also right now only wireless mode is supported.

Wired mode requires extra work, but it is also possible. Main problem with support for both wireless and wired modes is that wired mode has higher priority on the keyboard and actually disables wireless connection, but the keyboard is also still visible as wireless in the system (so it shows as two keyboards, but only wired works in that case).

If anyone is interested, I've also created a PR adding G915 support in OpenRGB project.

Hey buddy,

Nice work! Will this also support G915 TKL ? Or maybe that is the same...
For a beginner is there a specific tutorial on how to build it yourself with what you described?

Also what is OpenRGB ?

@yawor
Copy link

yawor commented Aug 24, 2021

It may or may not work with G915 TKL. The APIs are compatible for sure, but the feature indexes may be different.
To build it, you need to checkout the code from the pull request (until it's merged into this repository). Go to a directory where you'd like to clone the code (for example a src directory in your home dir) and do:

git clone https://github.com/MatMoul/g810-led.git
cd g810-led
git fetch --set-upstream origin pull/267/head:g915
git checkout g915

You'll also need some dev tools and libraries in your system. This depends on what distribution you're on. If it's Debian based (like Ubuntu), then do

apt-get install build-essential libusb-1.0-0-dev

Then you can build the program:

make LIB=libusb

OpenRGB is a quite large project which implements RGB controls for a lot of different hardware (motherboards, graphic cards, keyboards etc).

@spannerman79
Copy link

Wired mode requires extra work, but it is also possible. Main problem with support for both wireless and wired modes is that wired mode has higher priority on the keyboard and actually disables wireless connection, but the keyboard is also still visible as wireless in the system (so it shows as two keyboards, but only wired works in that case).

@yawor is it possible to detect the battery status of the G915? If so it might be possible to determine the difference between the two.

As you know the only time that the keyboard will charge is when connected via USB. Wireless implies running off battery alone.

@yawor
Copy link

yawor commented Aug 24, 2021

It is possible. There's a feature for that and it should be possible to implement reading this in g810-led.

There are two ways to charge the keyboard. You can connect it either to PC or an USB charger/power supply. The difference is that if connected to PC, the keyboard actually switches to wired mode (the lightspeed button turns light blue). In this mode the keyboard doesn't react to wireless connection at all (it's probably disabled so it doesn't duplicate every key press).
By connecting an USB charger or USB power supply the keyboard still uses wireless mode.
A good solution is to have a multi-port USB power supply. I happy with BlitzWolf BW-S16, which has USB type A and C ports and supports power delivery and quick charge. I have both USB type C and micro A cables on my desk commit from it so I can charge my keyboard, mouse, phone and other things if needed.

@Elijas
Copy link

Elijas commented Aug 24, 2021

Wait, there is no wired mode for g915, is it? It can only connect wirelessly as far as I know

@mcdope
Copy link

mcdope commented Aug 24, 2021

Wait, there is no wired mode for g915, is it? It can only connect wirelessly as far as I know

Not correct, you can use it wired exactly like he explained. I'm doing that in office.

@spannerman79
Copy link

Wait, there is no wired mode for g915

There is, it can be operated both wired (when charging) and Wireless/Lightspeed. Typical OOTB setup for Lightspeed/Bluetooth is that you don't actually have any cables attached (required for charging). Otherwise why use it via Lightspeed/Bluetooth and also charge at the same time - kind of pointless IMHO.

@yawor
Copy link

yawor commented Aug 25, 2021

Like @mcdope and @spannerman79 already said, G915 supports both modes of operation. When connected via USB cable to computer, you can even unplug the receiver and still use the keyboard.
This may be useful in some situations:

  • you take the keyboard with you somewhere (LAN party? :)) but you leave the receiver at home
  • you somehow lost the receiver (lightspeed receiver doesn't support pairing by user - the keyboard and receiver are paired at the factory)

I don't see any other benefits. It doesn't make the keyboard faster, as lightspeed is really fast and doesn't add any latency. It has been tested by LTT team with G Pro Lightspeed mouse (they've compared it with wired G Pro).
I charge my keyboard with USB charger instead of connecting it to PC. Charger is able to provide much higher current than USB data port so if the keyboard circuitry is capable of using that it'll charge faster (I don't know if it does actually).

By connecting G915 via cable you basically get G815, but there's risk of faster battery degradation if it's kept always at 100% (depends on what type of battery is inside the keyboard and how charging logic is implemented).

@TheOneTrueSahil
Copy link

TheOneTrueSahil commented Aug 27, 2021

It may or may not work with G915 TKL. The APIs are compatible for sure, but the feature indexes may be different.
To build it, you need to checkout the code from the pull request (until it's merged into this repository). Go to a directory where you'd like to clone the code (for example a src directory in your home dir) and do:

git clone https://github.com/MatMoul/g810-led.git
cd g810-led
git fetch --set-upstream origin pull/267/head:g915
git checkout g915

You'll also need some dev tools and libraries in your system. This depends on what distribution you're on. If it's Debian based (like Ubuntu), then do

apt-get install build-essential libusb-1.0-0-dev

Then you can build the program:

make LIB=libusb

OpenRGB is a quite large project which implements RGB controls for a lot of different hardware (motherboards, graphic cards, keyboards etc).

Tried these instructions with g915 TKL and it seems the device cannot be detected. Using this command:

g810-led -dv 046d -dp c541 -tuk 5 -a 000000 

@yawor
Copy link

yawor commented Aug 31, 2021

@TheOneTrueSahil I see a potential issue here. Looking at arguments you've used I assume that receiver for G915 TKL has the same USB PID as the one for full G915 (c541). This means that it should get detected as G915 right away (you don't need to use the -tuk argument, as this PID is already detected by the program in my PR), but the keyboard itself may differ in availability of some protocol features, causing the numbering of the features to differ.

I've created a script which retrieves features from the keyboard and prints them out. You can find it here:
https://gist.github.com/yawor/ee0f00b3d20d41d6c7f6e892ad86be25

It requires at least Python 3.7 (maybe it'll work on 3.6 too) and this library to be installed:
https://pypi.org/project/hid/

If you're using Arch Linux, there's a python-hid package in the repository. If you're using Debian/Ubuntu (probably other distros too), then there's no package for apt and you need to install it from pypi. Simply run as a user:
pip install hid
It will install the package into ~/.local/lib/python3.x/site-packages (exact path depends on the python version you have).

Then just run
python3 get_features.py

@TheOneTrueSahil
Copy link

TheOneTrueSahil commented Aug 31, 2021

@yawor Yes USB PID is the same. This is my output:

01, 0001
02, 0003
03, 0005
04, 1d4b
05, 0020
06, 0007
07, 1001
08, 1814
09, 1815
0a, 8071
0b, 8081
0c, 1b04
0d, 1bc0
0e, 4100
0f, 4522
10, 4540
11, 8010
12, 8020
13, 8030
14, 8040
15, 8100
16, 8060
17, 00c2
18, 00d0
19, 1802
1a, 1803
1b, 1806
1c, 1813
1d, 1805
1e, 1830
1f, 1890
20, 1891
21, 18a1
22, 1df3
23, 1e00
24, 1eb0
25, 1861

I'm confused as to how these feature IDs should be added. I guess it should be setup in help.h but it seems the IDs there don't relate?

@yawor
Copy link

yawor commented Aug 31, 2021

@TheOneTrueSahil from what I see the G915 TKL should be 100% compatible with full G915. The feature count and order is the same. According to that the G915 TKL should work without any further changes to the code.
Regarding your question about feature IDs, the problem is that g810-led doesn't use them. Instead it just hardcodes the packet header content depending on the keyboard model.
The Logitech HID++ 2.0+ protocol (also called Feature Access Protocol - FAP) allows full discovery of available features (or APIs) on the device. Each feature has a constant ID. For example 8081 is a feature to control individual RGB LEDs on newer keyboards (G815, G915 and TKL at least). On older ones there was 8080, which had different API. Feature 1001 on G915/TKL is for retrieving battery level, etc.
But the protocol doesn't use this ID directly. Instead it uses feature index (the first column from the script), which is numbered from 0 to the number of the features present on the device - 1 (as it's starts from 0). Even though the feature IDs are constant from device to device, the indexes are not as they depend on the number of available features and their order in the firmware.
Feature 0001 (always at index 1) is important in that regard. Function 0 in that feature returns number of features on the device and function 1 returns the feature ID for a given index (the index is sent as an argument). Also there's a function 0 in feature 0000 (always at index 0) which takes feature ID as an argument and returns its index.
If the g810-led was programmed to use this feature API, the code would be a lot cleaner. Unfortunately I don't have enough resolve to try rewriting this project to use it. Also I don't know if the author is even interested in such changes.

@TheOneTrueSahil
Copy link

Ok great, I probably just need to sit down and troubleshoot my setup. Very interesting, thanks for the detailed explanation

@abrioy
Copy link

abrioy commented Sep 2, 2021

#198

I managed to make it work with a g915 TKL using the same instructions and the following command:

$ sudo g810-led -dv 046d -dp c545 -tuk 5 -a 000000

For it to work I have to plug in the wireless receiver and plug out the keyboard.

When the keyboard itself is plugged in, both commands show no output and no error code, with no visible effect on the keyboard.

$ lsusb
Bus 001 Device 077: ID 046d:c343 Logitech, Inc. G915 TKL LIGHTSPEED Wireless RGB Mechanical Gaming Keyboard
Bus 001 Device 079: ID 046d:c545 Logitech, Inc. USB Receiver
$ sudo g810-led -dv 046d -dp c343 -tuk 5 -a 000000
$ sudo g810-led -dv 046d -dp c545 -tuk 5 -a 000000

@womanonrails
Copy link

Command:

$ sudo g810-led -dv 046d -dp c545 -tuk 5 -a 000000

works for my g915 TKL too! Thanks a lot!

@womanonrails
Copy link

I wrote article to summarize what I learned from this thread and from other tools regards to setups g915 TKL.

I hope it will help: How to configure Logitech G915 TKL with Ubuntu?

@yawor
Copy link

yawor commented Sep 29, 2021

@womanonrails great article, but I have some remarks. You don't have a comments section so I'll post it here:

You should be careful with ratbag. When you set LED from ratbagctl, it writes that configuration to onboard flash. Basically, it overwrites the stored profile (you can even select which of the 3 profiles you want to write to). I've had some issues when I tried to set some colours. I've also noticed that it messed up power saving settings and the keyboard backlight doesn't timeout at all (only G logo blinks for a moment after ~ 30 seconds of inactivity).

All other mentioned applications don't mess with the onboard flash. They only change a runtime configuration. That's why there's an issue that the LED configuration is reset after the keyboard wakes up from power save function. Unfortunately non of the current software implements detecting the wake up to reapply the configuration. But there's a workaround for this. You can switch the keyboard into software mode, which disables onboard features like power saving, backlight control etc and then control everything from software. You can do this with g810-led:

g810-led  --on-board-mode software

After that the keyboard immediately will go dark (but it's still working - only backlight turns off). Then you can set whatever colours you like using g810-led. But remember that the power saving is disabled in this mode. It is the software that should control dimming the keyboard, but there's no software for Linux right now that does that. Also the mode is back to "board" mode after you power cycle the keyboard.

Also regarding this sentence:

Even I use the -c parameter, which should allow me to commit the setups for longer.

You've misunderstood what the commit does. In Logitech's HID API, setting LED colors is a two step process. You first send colours for each individual key - but this step has no effect at all. It only stores what you want in the keyboard's RAM. The second step is to send a commit command, which actually outputs colours stored in RAM on to physical LEDs.

For g810-leds, switches -a, -g and -k always send commit automatically. There are -an, -gn and -kn variants of these switches, which don't send commit. If you use them, you won't see any difference on the keyboard unless you call g810-leds -c after that.

@womanonrails
Copy link

@yawor Thanks a lot for your feedback! If you don't mind I will update my article with your comments.

@yawor
Copy link

yawor commented Oct 1, 2021

@womanonrails sure, no problem.

@Elijas
Copy link

Elijas commented Oct 11, 2021

@womanonrails Would you consider posting your answer to this Stack Overflow question? Could be a great way to attract traffic to your site

https://askubuntu.com/questions/1300455/how-to-control-logitech-g915-tkl-keyboard-lightning-in-linux-ubuntu/1329467

@bkw777
Copy link

bkw777 commented Oct 12, 2021

#267 is working for me, with the exceptions that I had to remove the RUN directives from the udev rule, and my dongle's ID is c545 like @abrioy & @womanonrails .

I edited Keyboard.h, but you could get away with only editing the udev rule (or just inserting a new one), and use "-dv 046d -dp c545 -tuk 5" on all command lines.

The udev RUN problem isn't actually just in #267, other people have reported it in the main branch.

@tidalvirus
Copy link

I case someone land on this page, I found a way to load a custom lighting and inactivity setup as the default onboard …

Instructions for this already in this actual issue earlier: #198 (comment)

No need for an external link.

@yawor
Copy link

yawor commented Nov 1, 2021

It seems my instructions are outdated now. There were some recent changes in the GHub software, which makes setting custom lighting effect as a default in the onboard mode a little more complicated (but it's still possible). I've checked the link from the comment @tidalvirus replied to above (already deleted) and it wasn't correct either. It missed some key elements to be able to set default lighting effect properly.
It goes now like this (writing from memory on my phone):

  • Create and name your lighting effect in Freestyle mode.
  • Go to keyboard settings (a cog icon in the upper left corner)
  • In the lower right corner of the settings add your named effect to the keyboard memory, but DO NOT switch to the onboard mode yet.
  • Exit the settings and go back to lighting editor.
  • In the editor, change effect type to preset instead of freestyle. Open the drop-down with presets and you'll see your own custom lighting at the bottom of the list. Select it. Only presets from this list can be stored as default in onboard mode.
  • Now go back to settings, turn on the onboard mode and select your default profile, for which you've set your custom effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests