JafarAkhondali / acer-predator-turbo-and-rgb-keyboard-linux-module

Linux kernel module to support Turbo mode and RGB Keyboard for Acer Predator notebook series
GNU General Public License v3.0
342 stars 59 forks source link

Predator PT515-52 does not work #83

Open RashidKuri opened 1 year ago

RashidKuri commented 1 year ago

Model: Predator PT515-52

Count of keyboard RGB zones: Not shure what do you mean, but I think only 1

Count of Cpu Fans: 1

Count of Gpu Fans: 2

RGB keyboard works? No

Turbo button turn on fans? Yes

Turbo button turn on LED? Yes

Turbo button activates overclock? Yes

dsdt.aml.txt dsdt.aml.zip

RashidKuri commented 1 year ago

HI Jafar,

Unfortunately, turbo-fan program didn't work on my lap PT515-52. Turbo seems to work fine, but lcd keyboard does not.

I'm sending you the dsdt.aml file, and the rest of the information you ask is next:

rashid@Predator:~/acer-predator-turbo-and-rgb-keyboard-linux-module$ sudo dmidecode | grep "Product Name" -B 2 -A 4 System Information Manufacturer: Acer Product Name: Predator PT515-52 Version: V1.10 Serial Number: NHQ6WAL002030039F66600 UUID: 7bf3bc78-cd97-11ea-99ad-a302b367e6ee Wake-up Type: Power Switch

Base Board Information Manufacturer: CML Product Name: Spyder_CMS Version: V1.10 Serial Number: NBQ6W110010300000D6600 Asset Tag:
Features:

Hope information enough for you and thanks a lot. Regards.

JafarAkhondali commented 1 year ago

Hi, Unfortunately, this project only works on 4-zone RGB keyboards. I believe your laptop have per-key RGB. I don't have a model similar to you, and it can be time consuming to reverse engineer the mechanism for controlling per-key RGB.
To implement it, I'll need separate implementations and trial and errors on your laptop (with help of you). So if you think you can help me with this, drop me a message https://t.me/deallocate

Confuze commented 1 year ago

Hi, how's the per-key backlight support coming along? Have you started to do any work on it, or do you consider it too cumbersome? I don't mean to push or anything, and I completely understand if you don't want to make it, but if you do, I'd love to help you. I'm kind of a noob so I doubt I'd be able to contribute anything to the code, but I do own a PT515-52 device, so if you need any testing, I'd be glad to do it.

JafarAkhondali commented 1 year ago

Hi @Confuze , Can you test this script? https://github.com/JafarAkhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/issues/91 I don't have access to such model, neither my previous laptop, so I'm kinda stuck in further development of this project

Confuze commented 1 year ago

Thanks for the quick response, @JafarAkhondali I installed the hid module via pip, made the file an executable and ran it but it doesn't work (unless I did something wrong). I have very little experience with python scripting but it seems like the provided script has some errors. The shebang is missing the exclamation mark, one '(' was never closed and a couple more. I tried debugging it a little and right now I'm dealing with the following error:

Traceback (most recent call last):
  File "/home/stefanz/Downloads/./led_color_adjust.txt", line 37, in <module>
    h = hid.device()
AttributeError: module 'hid' has no attribute 'device'. Did you mean: 'Device'?

Replacing 'device' with 'Device' worked but it requires some arguments so it looks like I'm gonna have to do some research.

I know you can't really test the script but could you please have a look at the python code and tell me if you actually see anything wrong with it or am I doing something wrong? Chances are, it's just my lack of understanding the code so it could probably help. Either way, I'll try investigating a bit more myself too once I have the time.

JafarAkhondali commented 1 year ago

uninstall hid: pip uninstall hid then install hidapi pip install hidapi

Confuze commented 1 year ago

Yup, that fixes it. Script remains broken though. Once I ran it, i returned the error

  File "/home/stefanz/Downloads/./led_color_adjust.txt", line 41, in <module>
    device = [dev for dev in hl if dev['usage_page'] == 65282][0]
IndexError: list index out of range

and then I found out the hl variable is an empty array too. I changed the vendor and product IDs to what I'm pretty sure is my internal keyboard and now hl returns this:

[
    {'path': b'1-6:1.0', 'vendor_id': 3426, 'product_id': 31921, 'serial_number': '', 'release_number': 12806, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 0},
    {'path': b'1-6:1.1', 'vendor_id': 3426, 'product_id': 31921, 'serial_number': '', 'release_number': 12806, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 1},
    {'path': b'1-6:1.2', 'vendor_id': 3426, 'product_id': 31921, 'serial_number': '', 'release_number': 12806, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 2},
    {'path': b'1-6:1.3', 'vendor_id': 3426, 'product_id': 31921, 'serial_number': '', 'release_number': 12806, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 3}
]

So I've got 4 different devices all with the same properties (with the exception of interface_number) and no usage_page and usage specified. I tried testing all of them one by one and managed to run the script without any errors but it still didn't do anything.

Here's everything I have right now along with some comments:

#!/usr/bin/env python
import hid
import sys
import argparse

def light_on(mode, brightness, speed, direction, color_R, color_G, color_B):
    prefix = [0]
    print("mode {}, brightness {}, speed {}, direction {}, ".format(mode, brightness, speed, direction))
    h.send_feature_report(prefix + [0x3a] + [0]*6 + [0xc5])

    # adjust color
    h.send_feature_report(prefix + [0x14,0,1,
                    color_R,color_G,color_B, 0,
                        0xED])

    h.send_feature_report(prefix + [8,4,
                                    mode,
                                    speed,
                                    brightness,
                                    # 0 for blue
                                    # 1 for red
                                    # 2 for white
                                    # 3 for yellow
                                    # 4 for blue+
                                    # 5 for cyan
                                    # 6 for purple
                                    # 7 for white2
                                    2,
                                    direction,
                                    0xB9
                                    ])
    return

h = hid.device()
hl = hid.enumerate(0x0d62, 0x7cb1) # these ids correspond to a device named 'Darfon Electronics Corp. USB-HID Keyboard' which I'm 99% sure is my internal keyboard

device = [dev for dev in hl if dev['interface_number'] == 0][0] #interface_number is the only property that's different for all devices in hl so I'm just using it and manually switching the value to 0, 1, 2 and 3 to manually test all of them
h.open_path(
    device['path']
    ) #Open from path. This requires sudo permissions.

parser = argparse.ArgumentParser(
                    prog='keyboard LED color changer')
parser.add_argument("--mode", "-m", choices=range(0,256), default=1, type=int,
                    help="""
# 0x1 for simple light
# 0x2 for blink
# 0x3 for light change
# 0x5 for snake
# 0x6 for wave
# 0x8 for light change
# 10 for starfall
# 18 for heart
# 38 for random flash
# 40 for snow
# 41 for fire""") # is choices=range(0,256) an incorrect value? the help lists completely different values
parser.add_argument("--brightness", "-b", choices=range(0,256), default=2, type=int, help="0-50, larger means brighter")
parser.add_argument("--speed", "-s", choices=range(0,256), default=3, type=int, help="0-10?, larger means faster, but 5 is the slowest, larger is very fast")
parser.add_argument("--direction", "-d", choices=range(0,256), default=0, type=int, help="0-5, l'm lazy to explain")
parser.add_argument("--color_R", "-R", choices=range(0,256), default=0xff, type=int, help="red color")
parser.add_argument("--color_G", "-G", choices=range(0,256), default=0xff, type=int, help="green color")
parser.add_argument("--color_B", "-B", choices=range(0,256), default=0xff, type=int, help="blue color")
args = parser.parse_args()

light_on(args.mode, args.brightness, args.speed, args.direction, args.color_R, args.color_G, args.color_B)

Any ideas on what else I could try?

JafarAkhondali commented 1 year ago

Hmmm we may need @nqsnqsnqs input on this. For now, try booting in Windows and set the keyboard color to dynamic per key mode, then do a full reboot using this command in cmd shutdown /r /p. Then try to run the script as root and play with other parameters like mode, brightness, speed, etc. I can't think of any other options for now.

Confuze commented 1 year ago

Are you sure you mean shutdown /r /p? According to the documentation, /p can only be used with /f and /d.