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

Keyboard RGB support Tong Fang laptops, Question #28

Closed
rodgomesc opened this issue Jul 14, 2019 · 43 comments
Closed

Keyboard RGB support Tong Fang laptops, Question #28

rodgomesc opened this issue Jul 14, 2019 · 43 comments
Labels
enhancement New feature or request

Comments

@rodgomesc
Copy link

rodgomesc commented Jul 14, 2019

I'm working on a driver to Control Integrated Technology Express ITE Device(8291).
That is present on 80% of Tong Fang laptops, and is working Very well on Linux, i like to start a support for hackintosh, but iam stuck on connect to ITE on OSX, we can help each other to bring Full Tong Fang hardware Power to osx world! if you say yes, I'm sending some troubles that I'm stuck, otherwise I'll close this issue.

Full description and Tong Fang tested/supported laptops in project page:

Unofficial Control Center

A example :

https://youtu.be/ai5Y-aoMZWo

At time: 7:58min

@kirainmoe
Copy link
Owner

I tried to install the application and got usb.core.NoBackendError: No backend available error. I wonder if this is the trouble you are facing.

I'm willing to help you with it (but I know little about Python and the project :( )

As far as I know, ITE Device can be detected on macOS:

@rodgomesc
Copy link
Author

The problem is exactly this usb.core.NoBackendError: No backend available

Maybe is a issue with pyusb on OSX, iam on smartphone now but iam search and work on this tomorow

@rodgomesc
Copy link
Author

Can you install libusb

brew install libusb

And try run It again?

@kirainmoe
Copy link
Owner

OK I will try it later.

@kirainmoe
Copy link
Owner

Seems that the program has found the backend after install the libusb, but it still says usb.core.USBError: [Errno 13] Access denied (insufficient permissions) (with sudo).

@rodgomesc
Copy link
Author

Seems that the program has found the backend after install the libusb, but it still says usb.core.USBError: [Errno 13] Access denied (insufficient permissions) (with sudo).

Iam stuck on this too, this is a big problem for me, sound like pyusb have old issues in MacOS, i wll need to find other lib to comunicante to USB devices in OSX and rewrite comunication flow

@kirainmoe kirainmoe added the enhancement New feature or request label Aug 6, 2019
@rodgomesc
Copy link
Author

rodgomesc commented Aug 6, 2019

sr @kirainmoe , can make some tests? i think i got something:

brew install hidapi
pip install hidapi

curl https://raw.githubusercontent.com/rodgomesc/avell-unofficial-control-center/master/aucc/tests/main.py -o main.py && python main.py 

unfortunately i'm not having much time but this can be a start

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 7, 2019

It shows:

Opening the device
Manufacturer: ITE Tech. Inc.
Product: ITE Device(8291)
Serial No: None

Looks like the program recognized the device successfully.

@rodgomesc
Copy link
Author

It shows:

Opening the device
Manufacturer: ITE Tech. Inc.
Product: ITE Device(8291)
Serial No: None

Looks like the program recognized the device successfully.

and keyboard dont light up to green?,

@kirainmoe
Copy link
Owner

It just disabled my keyboard light... And I can't light up it using Fn keys.

@rodgomesc
Copy link
Author

I can't light up it using Fn keys.

what is the default color of your keyboard? On my laptop even with the illumination disabled in the bios, I was able to activate using this algorithm, could make a test enabling again and check if the colors will change to green?

@kirainmoe
Copy link
Owner

I don't understand what is "default color", my setting is mixed color. Tried to run it again but nothing changed. Boot into Windows and reboot to macOS and run again, still not working.

@rodgomesc
Copy link
Author

I don't understand what is "default color", my setting is mixed color. Tried to run it again but nothing changed. Boot into Windows and reboot to macOS and run again, still not working.

"default color" i mean, when you boot in hackintosh, if keyboard lights are enabled in bios, what color show up in key caps

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 7, 2019

When I press the Power button, the color is blue. After a while it will change to the color scheme that I set.

@rodgomesc
Copy link
Author

After a while it will change to the color scheme that my set.

and what is that?

@rodgomesc
Copy link
Author

rodgomesc commented Aug 7, 2019

sr @kirainmoe , can make some tests? i think i got something:

brew install hidapi
pip install hidapi

curl https://raw.githubusercontent.com/rodgomesc/avell-unofficial-control-center/master/aucc/tests/main.py -o main.py && python main.py 

unfortunately i'm not having much time but this can be a start

very strange it didn't work since you have the same ite 8291 chip

https://dl3.pushbulletusercontent.com/0n8GrUk2lgT8vAV9Lyzav3WIogvNr6nu/IMG_20190807_014206.jpg

https://dl3.pushbulletusercontent.com/F1yqXWlW9BTLmmcEOeYc6oeBditm39w6/IMG_20190807_014542.jpg

@kirainmoe
Copy link
Owner

I'm uploading a video to show you the phenomenon.

@rodgomesc
Copy link
Author

I'm uploading a video to show you the phenomenon.

hahahaha ok, crazy

@kirainmoe
Copy link
Owner

@rodgomesc
Copy link
Author

save this in the same folder of main.py and run sh test.sh

@kirainmoe
Copy link
Owner

Running 20 times of main.py still has no change..

@rodgomesc
Copy link
Author

rodgomesc commented Aug 7, 2019

it may not make sense to send the same code 20 times, but the official software does the same thing

@rodgomesc
Copy link
Author

can you send download link of your windows software to control rgb keyboard?

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 7, 2019

here: http://www.hasee.com/drivefile/notebook/%E5%90%8C%E6%96%B9/GK5SNxx/GamingCenter_1.2.2.2_HASEE.rar

My laptop is GK5CN6X. You can find other control center of GK5CN5Z/GK5CN6Z models. The official reseller of Tongfang laptops in my country is "Mechrevo", you can download its control center:

https://mega.nz/#!OypVmAKZ!8pafkk3DTjaWZNMq2ufDY69vSr6DZRCJFlm8WEtNRjI (2.0)

https://mega.nz/#!GqgD3CKS!VQEY2x1pkI1JK9pS9_Wj9RPOK6Ycd9p52iKQmhF9asw (1.0)

@rodgomesc
Copy link
Author

rodgomesc commented Aug 8, 2019

Before Proceed

i make some fixes, try run this:

https://raw.githubusercontent.com/rodgomesc/avell-unofficial-control-center/hackintosh_support/aucc/tests/main.py

if not work;

ok, i thing we can we can make this working for your mac, your ite 8281 are in revision 0.02 and mine it's in 0.03,

if you are sure this software works on your laptop, then with a little reverse engineering we can make my project work on your hackintosh perfectly, but it will take some of your time, I can guide you through the reverse engineering process, so After capturing a few bytes you will be able to change the keyboard colors to whatever you like in windows, such as red, blue, teal, pink, yellow, orange and others.

if you agree
1 - make sure your windows have this version:

https://mega.nz/#!GqgD3CKS!VQEY2x1pkI1JK9pS9_Wj9RPOK6Ycd9p52iKQmhF9asw

2 - install this version of usb analyzer https://usb-monitor.br.uptodown.com/windows/download/46949 (last version some bugs and can't intercept ITE bytes)

3 - what is your GMT? (let's choose a time that is better for both of us)

4 - join in this chat:

https://gitter.im/Unofficial-CC/Lobby

5 - if you pass teamviewer access in windows it may be faster, other wise the process just will only be a little slower

6 - this is going to be really cool because we will start support from people using ite 8291 revision 0.02 on linux and hackintosh on this wonderful notebook

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 9, 2019

Tried to run the latest script, though the color doesn't change, but the script now isn't disabling my keyboard light. In other word, it has no effect now.

I will go to Windows and install that. I'm in GMT +8.


I was unable to open the download link of USB Analyzer (my network seems to be fine). Can you help me to download it and upload it to send.firefox.com , or give me another download link? I can find little about USBMonitor in Google.

I downloaded free-usb-analyzer for alternative. Is it OK?

@shengt25
Copy link

shengt25 commented Aug 9, 2019

On my computer the test.py successfully changed the backlit color(to red and green).
But the main.py doesn’t work. There's an error saying can’t find the module aucc. Sorry I’m not familiar with python wish there is something I can help.

@kirainmoe
Copy link
Owner

On my computer the test.py successfully changed the backlit color(to red and green).
Though the main.py doesn’t work. It always tells my can’t find the module aucc. Sorry I’m not familiar with python.

What's the model of your laptop?

@shengt25
Copy link

shengt25 commented Aug 9, 2019

On my computer the test.py successfully changed the backlit color(to red and green).
Though the main.py doesn’t work. It always tells my can’t find the module aucc. Sorry I’m not familiar with python.

What's the model of your laptop?

MECHREVO X8TI Plus. And my ITE Device is revision 0.03.

@kirainmoe
Copy link
Owner

On my computer the test.py successfully changed the backlit color(to red and green).
Though the main.py doesn’t work. It always tells my can’t find the module aucc. Sorry I’m not familiar with python.

What's the model of your laptop?

MECHREVO X8TI Plus. And my ITE Device is revision 0.03.

So this indicates the problem is the ITE revision.

@kirainmoe
Copy link
Owner

The following is the Packet View captured by the software when I changed the color to "MonoColor" in Blue:

000000: PnP Event: Device Connected (UP), 09.08.2019 17:51:30.166 (1. Device: USB Composite Device)
The USB device has just been connected to the system.
000001: Class-Specific Request (DOWN), 09.08.2019 17:51:34.321 +4.154 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 09 00 B4 FF 00 00                           ....?...
000002: Control Transfer (UP), 09.08.2019 17:51:34.322 +0.001. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 09 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000003: Class-Specific Request (DOWN), 09.08.2019 17:51:34.324 +0.001 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 0A 00 B4 FF 00 00                           ....?...

000004: Control Transfer (UP), 09.08.2019 17:51:34.324 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 0A 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 0B 00 B4 FF 00 00                           ....?...
000006: Control Transfer (UP), 09.08.2019 17:51:34.325 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 0B 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000007: Class-Specific Request (DOWN), 09.08.2019 17:51:34.327 +0.001 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 0C 00 B4 FF 00 00                           ....?...
000008: Control Transfer (UP), 09.08.2019 17:51:34.327 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 0C 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000009: Class-Specific Request (DOWN), 09.08.2019 17:51:34.342 +0.014 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 01 00 B4 FF 00 00                           ....?...
000010: Control Transfer (UP), 09.08.2019 17:51:34.342 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 01 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000011: Class-Specific Request (DOWN), 09.08.2019 17:51:34.347 +0.004 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 02 00 B4 FF 00 00                           ....?...
000012: Control Transfer (UP), 09.08.2019 17:51:34.347 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 02 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000013: Class-Specific Request (DOWN), 09.08.2019 17:51:34.350 +0.003 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 03 00 B4 FF 00 00                           ....?...
000014: Control Transfer (UP), 09.08.2019 17:51:34.350 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 03 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000015: Class-Specific Request (DOWN), 09.08.2019 17:51:34.355 +0.004 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 14 00 04 00 B4 FF 00 00                           ....?...
000016: Control Transfer (UP), 09.08.2019 17:51:34.355 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 14 00 04 00 B4 FF 00 00                           ....?...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8
000017: Class-Specific Request (DOWN), 09.08.2019 17:51:34.359 +0.003 (1. Device: USB Composite Device)
Destination: Interface, Index 1
Reserved Bits: 34
Request: 0x9
Value: 0x300
Send 0x8 bytes to the device

 08 02 01 05 24 08 00 01                           ....$...

000018: Control Transfer (UP), 09.08.2019 17:51:34.359 +0.0. (1. Device: USB Composite Device) Status: 0x00000000
Pipe Handle: Control Pipe
 08 02 01 05 24 08 00 01                           ....$...
Setup Packet
 21 09 00 03 01 00 08 00                           !.......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x9 (Unknown)
Value: 0x300
Index: 0x1
Length: 0x8

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 16, 2019

Do you need any other information? The USB Analyzer has a tried time limit and it's going to expire.

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 18, 2019

So I managed to figure out how it works on revision 0.02. The following is the rule of 0.02:

First, I don't know how to name these packet correctly, and I will use "data packet" and "ending packet" to distinguish them. When setting a color, program will send 4 (or more but not more than 8) data packets to ITE device to state the color, and ending with 1 ending packet to state brightness, speed, direction, mode and so on.

I don't know if the rule is general on every device and laptops from different resellers. But as for my laptop:

Data packet is like this: 14 00 01 FF 00 FF 00 00, the first 2 bits are certain (14 00), and the third bit is the area of keyboard that you are going to set (my keyboard has 4 discrete areas, so it often ranges from 01 ~ 04, however it sometimes may ranges from 01~08 and 09~0C with unknown reason). Then the 4th~6th bits are hex of RGB color, then 7~8th bits are certain to be 00 00.

Ending packet also has 8 bits, like this: 08 02 01 05 24 08 00 01, the first 2 bits are certain. The 3rd bit represents the light mode (mono color is 01, breathing is 02, wave is 03, rainbow is 05, flash is 12, mix is 13). The 4th bit is the speed (has 5 values of 0A, 07, 05, 03, 01 from slow to fast), and the 5th bit is the brightness (has 5 values of 00, 08, 16, 24, 32 from dark to bright). The 7th bit represents the direction, only using wave or flash it will be (01 l->r, 02 r->l; flash has 03 sync), in other mode it will be 00. The last bit decide whether you will save your change (00 for no, 01 for yes). Especially, if you want to disable the light, you can just send 08 01 00 00 00 00 00 00. For example, 08 02 03 05 24 08 01 01 will set the keyboard to wave mode, direction left to right, brightness 4/5, speed 3/5 and save change.

And as for breathing, wave, flash and mix mode, the program will send 7 packets before sending ending packet:

14 00 01 FF 00 00 00 00
14 00 02 FF 5A 00 00 00
14 00 03 FF B4 00 00 00
14 00 04 00 B4 00 00 00
14 00 05 00 00 FF 00 00
14 00 06 00 B4 FF 00 00
14 00 07 FF 00 FF 00 00
08 02 02 05 24 08 00 01  <---ending packet

I don't know what's the function of these 7 packets, but the program in Windows sent them.

There is some examples, I think you will easily understand it:

Set light to mono color blue(00b4ff).

14 00 01 00 b4 ff 00 00
14 00 02 00 b4 ff 00 00
14 00 03 00 b4 ff 00 00
14 00 04 00 b4 ff 00 00
08 02 01 05 24 08 00 01

Set light to rainbow:

14 00 01 ff 00 00 00 00
14 00 02 00 b4 00 00 00
14 00 03 00 00 ff 00 00
14 00 04 ff 00 ff 00 00
08 02 05 05 24 08 00 01

Set light to mix, with full brightness and 2/5 speed:

14 00 01 FF 00 00 00 00
14 00 02 FF 5A 00 00 00
14 00 03 FF B4 00 00 00
14 00 04 00 B4 00 00 00
14 00 05 00 00 FF 00 00
14 00 06 00 B4 FF 00 00
14 00 07 FF 00 FF 00 00
08 02 13 03 32 08 00 01

That's all. And I think that you already find the solution to the original problem of this issue. Sorry for my poor English, if you have any other problem, just tell me.

@rodgomesc
Copy link
Author

rodgomesc commented Aug 18, 2019

whanks for reply i will analyze this

@rodgomesc
Copy link
Author

I just found that the problem is not just the revision of the chip, the library I use to communicate, is acting unexpectedly, the same code that works in windows and linux, when I run on mac it spends a few bytes more than I still can't figure out where they're coming from

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 18, 2019

I modified your test.py and it works, so there may be no problem to me. btw I use hid.send_feature_report() to do everything instead of hid.write(), I don't know if this affects.

I'm now using Node.js with node-hid library, it seems to work normally and it needs no extra library like hidapi. If python has the similar library?

@rodgomesc
Copy link
Author

rodgomesc commented Aug 18, 2019

I modified your test.py and it works, so there may be no problem of me. btw I use hid.send_feature_report() to do everything instead of hid.write(), I don't know if this affects.

I'm now using Node.js with node-hid library, it seems to work normally and it needs no extra library like hidapi. If python has the similar library?

I already migrated from pyusb to hidapi because of compatibility issues, i think hidapi and node hid use same interface in backend

@kirainmoe
Copy link
Owner

kirainmoe commented Aug 18, 2019

Yes I know it, you send me a test script of hidapi, and I modified it to 0.02 rule it works.

node-hid's documentation says that it uses hidraw by default, libusb is alternative.

@rodgomesc
Copy link
Author

so, thanks for all feedbacks, i will implement this when i have more time

@kirainmoe
Copy link
Owner

You are welcome. XD

@rodgomesc
Copy link
Author

@kirainmoe if you can add my project link to people looking for support for ite 8291 revision 3 in readme of project starbeat, thanks, i will do the same here

@rodgomesc rodgomesc reopened this Aug 18, 2019
@kirainmoe
Copy link
Owner

Of course, I added it to readme of that repo.

@rodgomesc
Copy link
Author

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants