Close

Setting up the environment

A project log for Logitech G13 kernel module

It can't be that hard right? Linux kernel has modules for G11/G510, it should fit in right?

stephengeorgeweststephengeorgewest 10/14/2021 at 11:521 Comment

If I just add the device here it might just work...

Ok so, my current linux device is a lousy netbook from 2009. I don't want to type on that mini screen. VS-code-remote doesn't work with x86, but WinSCP + ssh might just be good enough.

So many red squiggles... To add some linux header libraries, it says I need to open a folder. Ok, it added a .vscode folder... edit include path, copied the header files to a folder, and put them in the right order:

${default}
C:\Users\Stephen\source\src\linux-headers-5.14.0-2-common\include
C:/Users/Stephen/source/include/x86_64-linux-gnu
C:\Users\Stephen\source\src\linux-headers-5.14.0-2-common\arch\x86
C:\Users\Stephen\source\include
C:/Users/Stephen/source/src/linux-headers-5.14.0-2-common/arch/x86/include
C:/Users/Stephen/source/src/linux-headers-5.14.0-2-amd64/include
C:/Users/Stephen/source/src/linux-headers-5.14.0-2-amd64/arch/x86/include/generated
minimal red squiggles

I don't know if that is helpful... It says U8 isn't a type, and game_mode_enabled is a function? oh well. I'll just try putting in the VID/PID and treat it like a LG_G15 and compiling.

stephen@ao751h:~/Documents/projects/g13$ sudo insmod ./hid-lg-g15.ko
[141992.481805] usb 2-1: USB disconnect, device number 6
[141993.497565] usb 2-1: new full-speed USB device number 7 using uhci_hcd
[141993.688838] usb 2-1: New USB device found, idVendor=046d, idProduct=c21c, bcdDevice= 2.03
[141993.688879] usb 2-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[141993.688896] usb 2-1: Product: G13
[141993.713546] hid-generic 0003:046D:C21C.0130: hiddev2,hidraw4: USB HID v1.11 Device [G13] on usb-0000:00:1d.0-1/input0
[142482.986330] lg-g15 0003:046D:C21C.0130: hidraw4: USB HID v1.11 Device [G13] on usb-0000:00:1d.0-1/input0
[142483.055391] input: Logitech Gaming Keyboard Gaming Keys as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/0003:046D:C21C.0130/input/input47

root@ao751h:/home/stephen/Documents/projects/g13# echo 0 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 128 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 64 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 0 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# echo 64 > /sys/class/leds/g15\:\:lcd_backlight/brightness
root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:macro_record/brightness 
1
root@ao751h:/home/stephen/Documents/projects/g13# echo 0 >  /sys/class/leds/g15\:\:macro_record/brightness

The led's show up at /sys/class/leds/, dmesg shows it loaded, and echo 255 > /sys/class/leds/g15\:\:kbd_backlight/brightness changes it to green, setting the macro led's change backlight to full brightness. And finally evtest shows no input events.

It has an rgb color backlight, so maybe it should be treated like a LG_G510

Skip that line of code, recompile...

success, maybe
root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:kbd_backlight/max_brightness 
255
root@ao751h:/home/stephen/Documents/projects/g13# echo 255 > /sys/class/leds/g15\:\:kbd_backlight/brightness 
root@ao751h:/home/stephen/Documents/projects/g13# cat /sys/class/leds/g15\:\:kbd_backlight/color
#ffffff
root@ao751h:/home/stephen/Documents/projects/g13# echo "#ff0000" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#00ff00" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#0000ff" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#ff0000" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#010000" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#020000" > /sys/class/leds/g15\:\:kbd_backlight/color
root@ao751h:/home/stephen/Documents/projects/g13# echo "#030000" > /sys/class/leds/g15\:\:kbd_backlight/color

changing brightness did nothing, but setting the color changed the M1-3/R leds. evtest still shows no events, So maybe there is nothing really in common with the g15 driver... but hey, hello-world blinky leds.

Discussions

Arya wrote 10/15/2021 at 07:16 point

nice job, now you can start piecing a driver together from two drivers =D

  Are you sure? yes | no