z3ntu / razer_test

An experimental replacement for OpenRazer
69 stars 10 forks source link

Add support for the Razer BlackWidow Elite (2018) #1

Open ananace opened 6 years ago

ananace commented 6 years ago

Decided to have a go at adding support for my KB in here, turned out to not be difficult at all.

Haven't tested every feature yet, but the demo ran and turned my keyboard green, so I'm going to assume that it's working enough to be worth posting a PR for.

z3ntu commented 6 years ago

Interesting that this worked (background: that device is a device that was released with Synapse 3 and the packet captures show that the device uses only "custom frame" feature for any kind of effect - I've tested on some other device if sending the "old" effect packets to the device would do anything but it didn't so I assumed no "custom frame"/Synapse 3 device would support the old packets. But that the lights turned green shows that at least yours still supports the old packets).

But please check if also the rest works (see long comment above). The easiest way is to clone the RazerGenie repository and check out the branch razer_test. You can build that the same way as this one (meson)

ananace commented 6 years ago

As a side note, just with qdbus I've been able to verify brightness changing, switching between the 'spectrum', 'breathing random', and 'none' effects, and reading information from it.

Going to build a copy of RazerGenie and see what else works.

Edit:

Built RazerGenie, the only effect that's not 100% seems to be wave left, trying to switch to that switches to the keyboard to a static colour, fades it out, and loads the wave right effect instead. I can't test the custom editor as it apparently doesn't support the nordic layout.

ananace commented 6 years ago

Added a Nordic keymap to RazerGenie to get the per-key configuration, and it seems like custom frame effects are broken, so only the default full-keyboard effects are possible to apply.

I'm going to do some debugging though, see if I can find what's going wrong. I've got PCAPs after all, and a working Windows VM if I need to grab some more captures.

ashikns commented 5 years ago

I'm looking to make my black widow elite but mine is the 2019 edition I think. All I need to do is set it to a static color (it feels like we're going downhill when it comes to usable tech). Do you have any more info on what are "custom frame" that the synapse 3 devices accept?

PS: I'm on Windows, running captures using Wireshark and usbpcap.

z3ntu commented 5 years ago

@ashikns You can try compiling this project from the branch better-bringup-v2 and then run sudo ./builddir/razer_test_bringup_util --devel --verbose and follow the steps listed there. In the best case, it will spit out a json file and otherwise this tool should be improved :P

ashikns commented 5 years ago

I tried running the master branch as described in the wiki - did not work. Tried making my own VC++ project with stripped down source - did not work. In both cases it kept complaining "Could not send feature report", the error code from HID was "Incorrect Function". I also snooped on the usb connection and the packets seemed to be different. They are almost similar, but with some subtle differences like 1 byte shift.

Anyway I can't test the better-bringup branch anymore because I returned the keyboard. The list of things Synapse 3 starts up every time it runs: A C++ library that runs some sort of rest api receiving server, a Userprocess separate from the WPF UI process, GameManager service (which I can't stop manually either), A signalR hub and corresponding client (wtf???) for god knows what. As soon as I saw a signalR + asp net core server used in a software used to run my keyboard I cannot in good conscience own this anymore. Getting a Corsair K95 next. Let's see how that goes.

ashikns commented 5 years ago

Did not like the corsair, long story short I'm back on the black widow elite. Back on this. In case it helps here's the custom frame data being sent from Synapse 3. The 5 matrix custom frames are sent continuously in a loop while Synapse3 is running. Given data is for an all green static effect.

00 1f 00 00 00 47 0f 03 00 00 00 00 15 00 00 00 00 ff 00 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 5e 00

00 1f 00 00 00 47 0f 03 00 00 01 00 15 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 a0 00

00 1f 00 00 00 47 0f 03 00 00 02 00 15 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 a3 00

00 1f 00 00 00 47 0f 03 00 00 03 00 15 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 5d 00

00 1f 00 00 00 47 0f 03 00 00 04 00 15 00 00 00 00 ff 00 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 ff 00 00 00 00 00 ff 00 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 a5 00

00 1f 00 00 00 47 0f 03 00 00 05 00 15 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 ff 00 00 00 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 5b 00

z3ntu commented 5 years ago

@ashikns Yes, those packets are:

00     1f    0000   00    47       0f    03  000000001500000000ff0000000000ff0000ff0000ff0000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 00, START 0, END 21)
00     1f    0000   00    47       0f    03  000001001500000000ff0000ff0000ff0000ff0000ff0000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 01, START 0, END 21)
00     1f    0000   00    47       0f    03  000002001500000000ff0000ff0000ff0000ff0000ff0000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 02, START 0, END 21)
00     1f    0000   00    47       0f    03  000003001500000000ff0000ff0000ff0000ff0000ff0000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 03, START 0, END 21)
00     1f    0000   00    47       0f    03  000004001500000000ff0000000000ff0000ff0000ff0000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 04, START 0, END 21)
00     1f    0000   00    47       0f    03  000005001500000000ff0000ff0000ff0000000000000000ff0... | SET EXTENDED CUSTOM FRAME(UNUSED? 0000, ROW 05, START 0, END 21)

Anyways, does your device have the usb id 1532:0228 ? If not, let's move away from this PR as it's for a different device.

ashikns commented 5 years ago

Usb id is 1532:0228

z3ntu commented 5 years ago

Okay, you can try to check out the repo from this PR (I've just rebased it on master so you should have the latest changes). As a GUI you can use RazerGenie with the razer_test branch. While buildling you have to pass -Ddaemon_target=razer_test as it would use the openrazer dbus interface otherwise.

You could also try to use polychromatic with https://github.com/z3ntu/openrazer-shim put into your PYTHONPATH (it's a python library having the same layout as the openrazer pylib but it uses the razer_test daemon)