cemkaya-mpi / Dell-G15-Controller

GNU General Public License v3.0
34 stars 12 forks source link

Update the Readme #13

Closed LAfricain closed 4 months ago

LAfricain commented 8 months ago

Please add the dep needed for the tool: sudo apt install libxcb-cursor0 and: pip3 install pyside6

I would like to try it on an M17R3 with the same spec. But I have no idea how to use it I would like to turn off the light when not typing.

cemkaya-mpi commented 8 months ago

Hello, keyboard lights can be toggled from the system tray by clicking the icon. IIRC you can set a timeout on AC and on battery for keyboard lights in BIOS.

Power modes and fan control are a bit more involved, but we can try to make it work if you can share your dsdt.

cemkaya-mpi commented 8 months ago

By the way, pyside6 depends on qt6-base, which depends on libxcb on Arch. Is it different on Debian?

LAfricain commented 8 months ago

I install libxcb-cursor0 with apt and pyside6 with pip3. the windows is opening, but I can't change nothing. Fan an power it's okay, I have no need to control it. I want just to switch off the keyboard when it's not useful.

cemkaya-mpi commented 8 months ago

Could you please post the output of lsusb ?

LAfricain commented 7 months ago
Bus 002 Device 002: ID 0bda:0328 Realtek Semiconductor Corp. USB3.0-CRW
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0bda:565a Realtek Semiconductor Corp. Integrated_Webcam_HD
Bus 001 Device 003: ID 187c:0550 Alienware Corporation LED controller
Bus 001 Device 002: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus 001 Device 006: ID 8087:0029 Intel Corp. AX200 Bluetooth
Bus 001 Device 005: ID 0d62:3740 Darfon Electronics Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
cemkaya-mpi commented 7 months ago

Hi, this is the same keyboard as G15 5525, so the app should work. Have you added the udev rule, and are you a member of the plugdev group?

LAfricain commented 7 months ago

Have you added the udev rule

Yes.

are you a member of the plugdev group

Yes.

But when I try sudo modprobe acpi_call I have this error:

modprobe: FATAL: Module acpi_call not found in directory /lib/modules/5.19.0-35-generic

I have this error when I run main.py:

Laptop model is NOT supported. Try ACPI methods for G15 5525 anyway? You might damage your hardware. Please do not do this if you don't know what you are doing!

When I chose Color and morph, I have this error:

>Have you added the udev rule

Yes.

> are you a member of the plugdev group

Yes.

But when I try `sudo modprobe acpi_call`
I have this error:

modprobe: FATAL: Module acpi_call not found in directory /lib/modules/5.19.0-35-generic


I have this error when I run main.py:

Laptop model is NOT supported. Try ACPI methods for G15 5525 anyway? You might damage your hardware. Please do not do this if you don't know what you are doing!


Cannot apply LED settings:

Exception: no such device was found. Do you have a RGB keyboard 187c:0550?

Edit: I don't know what happened but now the light are of!! How to switch it on? Edit2: Now the power button is also off!! How to switch it on? I just tried OpenRGB, and I succeed to swith on the power button and the left of the keyboard! But not all the keyboard. It's strange.

cemkaya-mpi commented 7 months ago

Hi,

modprobe: FATAL: Module acpi_call not found in directory /lib/modules/5.19.0-35-generic

You probably do not have the acpi_call module, so you get the error. It is used for power and fan controls and should not affect keyboard lights.

Exception: no such device was found. Do you have a RGB keyboard 187c:0550?

Looks like the app is not able to access the usb device. I suggest you first try this from python

import usb
device = usb.core.find(idVendor=0x187c, idProduct=0x0550)
print(device)

This should print a bunch of information about the device. If device is none, your user does not have access to the usb device. Please check your udev rules. If the app works, there are 3 modes you can choose: Static Color, Morph and Both. The color sliders are self-explanatory.

About the power button: Since G15 5525 does not have one, it is entirely possible that I am turning it on/off with the current zone defintions. But, for this to happen, you need to have access to the usb device as your user, which does not seem to be the case according to the error message

LAfricain commented 7 months ago

I suggest you first try this from python the answer:


python3 test.py 
DEVICE ID 187c:0550 on Bus 001 Address 003 =================
bLength                :   0x12 (18 bytes)
bDescriptorType        :    0x1 Device
bcdUSB                 :  0x210 USB 2.1
bDeviceClass           :    0x0 Specified at interface
bDeviceSubClass        :    0x0
bDeviceProtocol        :    0x0
bMaxPacketSize0        :   0x40 (64 bytes)
idVendor               : 0x187c
idProduct              : 0x0550
bcdDevice              :  0x200 Device 2.0
iManufacturer          :    0x1 Alienware
iProduct               :    0x2 AW-ELC
iSerialNumber          :    0x3 00.01
bNumConfigurations     :    0x1
CONFIGURATION 1: 0 mA ====================================
bLength              :    0x9 (9 bytes)
bDescriptorType      :    0x2 Configuration
wTotalLength         :   0x29 (41 bytes)
bNumInterfaces       :    0x1
bConfigurationValue  :    0x1
iConfiguration       :    0x0 
bmAttributes         :   0xe0 Self Powered, Remote Wakeup
bMaxPower            :    0x0 (0 mA)
INTERFACE 0: Human Interface Device ====================
bLength            :    0x9 (9 bytes)
bDescriptorType    :    0x4 Interface
bInterfaceNumber   :    0x0
bAlternateSetting  :    0x0
bNumEndpoints      :    0x2
bInterfaceClass    :    0x3 Human Interface Device
bInterfaceSubClass :    0x0
bInterfaceProtocol :    0x0
iInterface         :    0x0 
ENDPOINT 0x81: Interrupt IN ==========================
bLength          :    0x7 (7 bytes)
bDescriptorType  :    0x5 Endpoint
bEndpointAddress :   0x81 IN
bmAttributes     :    0x3 Interrupt
wMaxPacketSize   :   0x21 (33 bytes)
bInterval        :    0xa
ENDPOINT 0x1: Interrupt OUT ==========================
bLength          :    0x7 (7 bytes)
bDescriptorType  :    0x5 Endpoint
bEndpointAddress :    0x1 OUT
bmAttributes     :    0x3 Interrupt
wMaxPacketSize   :   0x21 (33 bytes)
bInterval        :   0x64

>Please check your udev rules.

sudo usermod -a -G plugdev cyrille


But when I run the `python3 main.py`, it asks me my password, which means it's running as root no?
cemkaya-mpi commented 7 months ago

Alright, the device is found and accessible. The keyboard part should work. Since you are not interested in the power/fan controls, you can just skip entering your root password, and power/fan controls should not be shown.

You can choose Off/Static/Morph/Both, adjust the sliders, and apply.

However, since you have a different device, it is possible that the zone definitions are different from G15 5525. If this is the case, we should be able to try some zones first to understand which zone is connected to which LED for your device, and create a patch.

LAfricain commented 7 months ago

You can choose Off/Static/Morph/Both, adjust the sliders, and apply.

Yes I tried this but it's not working I could switch the keyboard off, buth impossible to switcht it on. Do you need some info for the patch?

cemkaya-mpi commented 7 months ago

This might have to do with different zone definitions for the Alienware M17R3 than the G15 5525. For the G15, there are 4 keyboard zones 0,1,2,3, and no extra leds. This is probably different for your Alienware laptop. Do you have a power led, or extra leds on your laptop? If so, the zones might be defined as 1,2,3,4, 2,3,4,5 etc. for your laptop. There are several ways to figure this out:

  1. The easiest way to try this out would be changing ZONES, ZONES_KB and ZONES_NP in awelc.py, and running the app. If it is a simple fix, we can create a patch for your laptop model.
  2. We can try to find the zones from windows using alienfx tools.
  3. We can capture the USB communication from AWCC to figure out the zones for your device.

I would suggest starting from 1, and if it does not work, we can try the other approaches.

LAfricain commented 7 months ago

First of all, thank you for helping me.

Do you have a power led, or extra leds on your laptop?

I guess I have 6 zones, because in openRGB I can see 6 times unknown LED. And probably one of it is the power LED I have power led with the alien face).

The easiest way to try this out would be changing ZONES, ZONES_KB and ZONES_NP in awelc.py

OK I tried like this:

ZONES = [0, 1, 2, 3, 4, 5]
ZONES_KB = [0, 1, 2, 3, 4]
ZONES_NP = [5]

Good news, the left part of the keyboard just switch on. When I switcht it off I had this windows: Cannot applay LED settings, USBtimeoutError [Error 110] Operation time out

And after that impossible to run again the Controller I had this error:



Exception: no such device was found. Do you have a RGB keyboard 187c:0550?```

And now all is switch off even the power button.
LAfricain commented 7 months ago

Oups, My keyboard lights just disappear from the lsusb:

lsusb
Bus 002 Device 003: ID 1058:2621 Western Digital Technologies, Inc. Elements 2621
Bus 002 Device 002: ID 0bda:0328 Realtek Semiconductor Corp. USB3.0-CRW
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 0bda:565a Realtek Semiconductor Corp. Integrated_Webcam_HD
Bus 001 Device 002: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus 001 Device 009: ID 8087:0029 Intel Corp. AX200 Bluetooth
Bus 001 Device 008: ID 0d62:3740 Darfon Electronics Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

After second reboot it came again.

LAfricain commented 7 months ago

We can try to find the zones from windows using alienfx tools.

I don't have windows. Do you have some advise about awelc.py?

cemkaya-mpi commented 7 months ago

Besides trying the zones manually one by one, not really. But you could try switching one zone at a time to find the zones for your keyboard using the functions apply_static with a single zone. Remember to call init_device first.

If this does not work, you can redirect your usb device to a Windows VM and figure out the zones from alienfx tools also.

LAfricain commented 7 months ago

But you could try switching one zone at a time to find the zones for your keyboard using the functions apply_static with a single zone. Remember to call init_device first.

Can you give me a example please?

If this does not work, you can redirect your usb device to a Windows VM and figure out the zones from alienfx tools also.

This is a good idea!

cemkaya-mpi commented 7 months ago

Can you give me a example please?

Look at the following function for an example, but remember to enter your zones as well.

https://github.com/cemkaya-mpi/Dell-G15-Controller/blob/99afb4971a6fcd8b59a59da7d57457510a49c495/awelc.py#L84

LAfricain commented 7 months ago

I'm sorry but I don't understand how it's work...

Edit: Ok I think I understand, I need to enter my computer name, and the zone... How to know the computer name? In the example the zone is 0?

First result, change:

def set_static(red, green, blue):
    set_dim(0)
    elc, device = init_device()
    apply_action(elc, 3, 3, 3, DURATION_MAX, TEMPO_MIN,
                 AC_SLEEP, COLOR)       # Off on AC Sleep
    apply_action(elc, red, green, blue, DURATION_MAX, TEMPO_MIN,
                 AC_CHARGED, COLOR)     # Full brightness on AC, charged
    apply_action(elc, red, green, blue, DURATION_MAX, TEMPO_MIN,
                 AC_CHARGING, COLOR)    # Full brightness on AC, charging
    apply_action(elc, 3, 3, 3, DURATION_MAX, TEMPO_MIN,
                 DC_SLEEP, COLOR)       # Off on DC Sleep
    apply_action(elc, int(red/2), int(green/2), int(blue/2),

And the power button switch off/on.

LAfricain commented 7 months ago

Maybe this informations can be useful:

python3 test.py 
DEVICE ID 187c:0550 on Bus 001 Address 003 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x210 USB 2.1
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x187c
 idProduct              : 0x0550
 bcdDevice              :  0x200 Device 2.0
 iManufacturer          :    0x1 Alienware
 iProduct               :    0x2 AW-ELC
 iSerialNumber          :    0x3 00.01
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 0 mA ====================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x29 (41 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0xe0 Self Powered, Remote Wakeup
   bMaxPower            :    0x0 (0 mA)
    INTERFACE 0: Human Interface Device ====================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x3 Human Interface Device
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x81: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x21 (33 bytes)
       bInterval        :    0xa
      ENDPOINT 0x1: Interrupt OUT ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x1 OUT
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x21 (33 bytes)
       bInterval        :   0x64
cemkaya-mpi commented 7 months ago

apply_action is defined as

apply_action(elc, red, green, blue, duration, tempo, animation=AC_CHARGING, effect=COLOR, zones=ZONES)

so you could call the function like

apply_action(elc, red, green, blue, duration, tempo, animation, effect, zones=[0,1]) 

to test the zones 0 and 1.

LAfricain commented 7 months ago

Please, I have no coding skill, can you add info, Should add the second line in the file after the first or change the first by the second?

cemkaya-mpi commented 4 months ago

Hi, please open a new issue for keyboard light zones. Readme is updated.