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

Redragon Keyboards "Evision v2" chip (e.g. K556 Devarajas 320f:5000) support #31

Open
hirak99 opened this issue Jul 28, 2024 · 10 comments

Comments

@hirak99
Copy link

hirak99 commented Jul 28, 2024

Hi,

I have a K551 which I would love to control with this program.

Physically the K551 model is almost identical to K552 (which is in the supported list), except it also has a Numpad.

I was playing around with the code to check if I can add support for it.

The device reads as -

$ lsusb
...
Bus 001 Device 002: ID 320f:5000 Evision RGB Keyboard
...

Adding 0x5000 to the keyboard_pid list made it recognize it, however I was unable to set anything using the binary.

The following gives no results -

$ ./rgb_keyboard --leds rain --color 0000ff
(Waits for 2s and returns with no error but nothing changes on keyboard)

However, it does communicate with the keyboard (since I can't type anything for 1 or 2 seconds when it runs unless I use --interface0).

The readout appears to have garbage. None of the modes match with what I have set, also Profile2 appears to have bad values for mode and brightness -

./rgb_keyboard --read
Active profile: 1

Profile 1:
Led mode: ripple
Direction: right
Color: 000000
Brightness: 0
Speed: 3
Report rate: 125 Hz

Profile 2:
Led mode: unknown
Color: 7c0000
Brightness: 31867
Speed: 1
Report rate: 125 Hz

Profile 3:
Led mode: horizontal-wave
Direction: right
Color: 000000
Brightness: 0
Speed: 3
Report rate: 125 Hz

Question: Is there anything I can try to debug or get it working?

Could the Keyboard be using a different protocol for USB communications (I can see defined in data.cpp and used in writers.cpp), and if so, is there anything I can use to debug and detect what is the USB protocol it uses?

Currently, openrgb works on my keyboard, so it can be done - just need to find out how.

@dokutan
Copy link
Owner

dokutan commented Jul 29, 2024

The general idea is to use wireshark to capture the USB communication with the official software, then recreate the data that was sent in writers.cpp (expect some trial and error). Considering that openrgb and rgb_keyboard have at least some support, i recommend capturing that data as well and doing a diff.

However, before that i would try to enable the control transfer mode used by some keyboards, e.g. by adding the PID to:

const std::map<uint16_t, bool> use_control_transfer = {

@hirak99
Copy link
Author

hirak99 commented Jul 31, 2024

Thanks! With control transfer predefined patterns like this are working -

# This works!
./rgb_keyboard --leds fixed --color 70ff00
# And this works!
./rgb_keyboard --leds ripple --color 70ff00 --brightness=2 direction=right

However, custom key lighting is not working as expected -

./rgb_keyboard --leds custom --custom-keys "z=00ff00;"
# Should light up only z, but this happens -
# https://imgur.com/a/23YF7j9

Custom per-key lighting also works from openrgb. I actually want to use rgb_keyboard for per-key lighting, with my own configuration files.

Thanks for the pointer to Wireshark - may be I can monitor how openrgb does this with Wireshark. Haven't used it before, seems like a nifty tool to learn.

Is there any other trick I can try before that to see if per-key lighting already works with some other configuration? Looks like write_custom() does it, may be I can tinker it to see if any change would make it work.

@hirak99
Copy link
Author

hirak99 commented Jul 31, 2024

Correction, the keyboard is K552 Kumara, with a second PID, according to openrgb's registration.

...
REGISTER_HID_DETECTOR_IP("EVision Keyboard 320F:5000", DetectEVisionKeyboards,   EVISION_KEYBOARD2_VID, REDRAGON_K552_V2_PID,      1, EVISION_KEYBOARD_USAGE_PAGE);
...

@hirak99 hirak99 changed the title K551 Mitra support K552 Kumara v2 320f:5000 support Jul 31, 2024
@hirak99 hirak99 changed the title K552 Kumara v2 320f:5000 support Redragon Keyboards v2 (320f:5000) support Jul 31, 2024
@hirak99 hirak99 changed the title Redragon Keyboards v2 (320f:5000) support Redragon Keyboards "Evision v2" chip (e.g. K556 Devarajas 320f:5000) support Jul 31, 2024
@hirak99
Copy link
Author

hirak99 commented Jul 31, 2024

I used Wireshark on OpenRGB using it, also am looking at the OpenRGB code.

Also have been researching, found this very nice video on EVision chips that power the RGB in these keyboards - https://www.youtube.com/watch?v=2MHtLEiXaXg Edit: The video is about flashing a different firmware, so most of it is not very relevant in reverse engineering the existing Evision 2 firmware.

@dokutan
Copy link
Owner

dokutan commented Aug 3, 2024

If this keyboard uses different codes to identify the individual keys for custom patterns (and key remapping), you could add the keycodes in rgb_keyboard.h and data.cpp, similar to e.g.

const std::map<std::string, std::array<uint8_t, 3>> rgb_keyboard::keyboard::keycodes_brazil_k552rgb1 = {

and allow them to be selected here:

if (string_layout == "ansi") {

Figuring out the keycodes is possible by reverse engineering the USB communication or by trial and error (changing the values in data.cpp).

@amitsandhel
Copy link

Thanks! With control transfer predefined patterns like this are working -

# This works!
./rgb_keyboard --leds fixed --color 70ff00
# And this works!
./rgb_keyboard --leds ripple --color 70ff00 --brightness=2 direction=right

However, custom key lighting is not working as expected -

./rgb_keyboard --leds custom --custom-keys "z=00ff00;"
# Should light up only z, but this happens -
# https://imgur.com/a/23YF7j9

Custom per-key lighting also works from openrgb. I actually want to use rgb_keyboard for per-key lighting, with my own configuration files.

Thanks for the pointer to Wireshark - may be I can monitor how openrgb does this with Wireshark. Haven't used it before, seems like a nifty tool to learn.

Is there any other trick I can try before that to see if per-key lighting already works with some other configuration? Looks like write_custom() does it, may be I can tinker it to see if any change would make it work.

@hirak99 so you got your redragon to work with openrgb and can make it use the new patterns and how did you get it working if I may ask >

I have the redragon k582 but It doesn't work with openrgb at all Id like to try it with my redragon k582?

@dokutan does your software allow us to program our own themes for our redragon keyboards ?

@hirak99
Copy link
Author

hirak99 commented Aug 6, 2024

@amitsandhel someone already added it to OpenRGB, it works out of the box for k552.

The easiest thing to try is to add your product id to rgb_keyboard.h here.

You can then compile this project make clean; make and test if it works for your keyboard.

If it does, you can send a PR to this project.

You can find the product id typing lsusb, it should have a line that reads like this -

Bus 001 Device 002: ID 320f:5000 Evision RGB Keyboard

In that example 320f is vendor id, 5000 is product id.

You can also do this on openrgb if you want.

@dokutan thank you for acquainting me to Wireshark.

I will send a PR for K552 but it may take some time because (a) I still need to figure out the key codes and (b) because of some bureaucratic reasons - my current company has a process that I need to follow. (It's a bit cumbersome but I since I moved out of California and the moonlighting laws are ambiguous here, probably best for me to try to follow it. There's also a growing chance that I will leave which might make it easier for me to contribute to open source.)

If anyone in the meanwhile solves this, that's great.

With Wireshark, I have also been successful to use it to create a script to set RGB leds for another device (HP X1000 speakers), for which no other way exists in Linux to my knowledge. This was an unexpected and pleasant turn of events!

@amitsandhel
Copy link

@amitsandhel someone already added it to OpenRGB, it works out of the box for k552.

The easiest thing to try is to add your product id to rgb_keyboard.h here.

You can then compile this project make clean; make and test if it works for your keyboard.

If it does, you can send a PR to this project.

You can find the product id typing lsusb, it should have a line that reads like this -

Bus 001 Device 002: ID 320f:5000 Evision RGB Keyboard

In that example 320f is vendor id, 5000 is product id.

You can also do this on openrgb if you want.

@dokutan thank you for acquainting me to Wireshark.

I will send a PR for K552 but it may take some time because (a) I still need to figure out the key codes and (b) because of some bureaucratic reasons - my current company has a process that I need to follow. (It's a bit cumbersome but I since I moved out of California and the moonlighting laws are ambiguous here, probably best for me to try to follow it. There's also a growing chance that I will leave which might make it easier for me to contribute to open source.)

If anyone in the meanwhile solves this, that's great.

With Wireshark, I have also been successful to use it to create a script to set RGB leds for another device (HP X1000 speakers), for which no other way exists in Linux to my knowledge. This was an unexpected and pleasant turn of events!

@hirak99 apologies but I am still confused.
My question wrt to to openRGB is do redragon keyboards have accesss to directmode, which would then allow us to have other animation effects aside from whatever comes default with the keyboard.

And does this software do the exact same thing. I can then create my own custom pattern per say and have my keyboard display that pattern somehow ?

@hirak99
Copy link
Author

hirak99 commented Aug 6, 2024

I'm sorry the fault is mine, I misunderstood your question.

With OpenRGB I can statically change the colors on a per key basis.

However I don't think it has a direct mode. The factory firmware stores the colors in memory every time it's set, which causes delay and flicker. So a new animated pattern is not possible with it. For that the firmware needs to be changed, and this video goes deeper into that topic: https://www.youtube.com/watch?v=2MHtLEiXaXg

@amitsandhel
Copy link

I'm sorry the fault is mine, I misunderstood your question.

With OpenRGB I can statically change the colors on a per key basis.

However I don't think it has a direct mode. The factory firmware stores the colors in memory every time it's set, which causes delay and flicker. So a new animated pattern is not possible with it. For that the firmware needs to be changed, and this video goes deeper into that topic: https://www.youtube.com/watch?v=2MHtLEiXaXg

@hirak99
yes thats my issue as well. I can use openrgb to use the default in memory rgb themes and some per key basis but using direct modei s impossible. i tried changing the firmeare but sonix didn't even detect my keyboard out of the box.

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

No branches or pull requests

3 participants