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

support for the older version of HyperX Cloud II #1

Open
tottoszsolt opened this issue Jun 15, 2023 · 68 comments
Open

support for the older version of HyperX Cloud II #1

tottoszsolt opened this issue Jun 15, 2023 · 68 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@tottoszsolt
Copy link

I have installed the dependencies, but when I try to launch it, I get broken pipes error, both the cli and the hyperx app, please help. Thank you!

@LennardKittner
Copy link
Owner

Ok, strange, I never had this error before.
What version of the headset are you using (HP or HyperX)?
You can run lsusb and then look for the string "HyperX Cloud II Wireless" to find the vendor name.
Where does the error occur could you send me the full terminal output?

@LennardKittner LennardKittner added the bug Something isn't working label Jun 15, 2023
@tottoszsolt
Copy link
Author

lsusb:
Bus 003 Device 004: ID 0951:1718 Kingston Technology HyperX Cloud II Wireless
terminal output:
image

@LennardKittner
Copy link
Owner

Ok, you have the older version of the headset.
I have the newer version and hoped that only the vendorID and productID would be different between the versions.
Have you ever tried running the app without sudo?
Have you compiled the app your self or downloaded the pre-compiled version?

@tottoszsolt
Copy link
Author

I used the precompiled version, I will check the self compiled in the morning

@LennardKittner
Copy link
Owner

LennardKittner commented Jun 15, 2023

Ok, if you do, could you replace the following lines in `src/lib.rs"? This will make the app crash immediately and may tell me more about where and why the error happens.
81: let hid_api = HidApi::new().unwrap();

88: }).unwrap().unwrap();

125: self.hid_device.write(&BATTERY_PACKET).unwrap();

127: let res = self.hid_device.read_timeout(&mut buf[..], 1000).unwrap();

I'm sorry for your inconvenience :(.

@LennardKittner
Copy link
Owner

I have compiled it for you with the changes I mentioned above.
cli_app.zip

@tottoszsolt
Copy link
Author

Thank you! I will try it in a moment!

@tottoszsolt
Copy link
Author

image
This is the error I get trying it to run withouth sudo,
and this is what I get running with sudo
image

@LennardKittner
Copy link
Owner

The first error indicates that the rules are not set correctly, so the app does not have the necessary permissions to access the headset (but we can fix this later).

The second error indicates that the packet I used to request the battery level failed. The reason for this could be that your headset (the older version) expects different packets than mine.
I have seen another project on GitHub that uses the older version. I will try to use the packet from that repository and I will send you another executable in a couple of hours. I have to go to the university now.

@tottoszsolt
Copy link
Author

Okay, thank you!

@LennardKittner
Copy link
Owner

Could you please run these two executables with sudo and let me know what happens? cli_app.zip
I have changed the packet that is sent to the headset and hope that this will fix the issue.

@tottoszsolt
Copy link
Author

Sorry for the late reply, here are the results
image

@LennardKittner
Copy link
Owner

Could you please try this again cli_app.zip.
If that does not work either, try this: https://github.com/Agustin-Jerusalinsky/hyperx-cloud-II-battery/.
I think the problem is that the older version of the headset expects different packets.
Therefore, if both apps do not work, I think you will have to use Wireshark on Windows so we can figure out what the right packets are.

@LennardKittner
Copy link
Owner

One more alternative would be that you try to compile the app yourself.

@tottoszsolt
Copy link
Author

Its not working anyhow sadly.. I am trying to compile it myself, but I am very noob in the Linux field, so I tried avoiding it tbh

@tottoszsolt
Copy link
Author

While trying to compile it myself, I get this errors:

totto@zsolti-pc HyperXCloudIIWireless-main]$ cargo build --release
Updating crates.io index
Compiling pkg-config v0.3.27
Compiling libc v0.2.146
Compiling proc-macro2 v1.0.60
Compiling quote v1.0.28
Compiling unicode-ident v1.0.9
Compiling unicode-width v0.1.10
Compiling strsim v0.8.0
Compiling vec_map v0.8.2
Compiling bitflags v1.3.2
Compiling ansi_term v0.12.1
Compiling xml-rs v0.8.14
Compiling cc v1.0.79
Compiling thiserror v1.0.40
Compiling textwrap v0.11.0
Compiling libdbus-sys v0.2.5
error: failed to run custom build command for libdbus-sys v0.2.5

Caused by:
process didn't exit successfully: /home/totto/Downloads/HyperXCloudIIWireless-main/target/release/build/libdbus-sys-9400c167139cd70f/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=build_vendored.rs
cargo:rerun-if-env-changed=DBUS_1_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=DBUS_1_STATIC
cargo:rerun-if-env-changed=DBUS_1_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
pkg_config failed: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6" did not exit successfully: exit status: 1
error: could not find system library 'dbus-1' required by the 'libdbus-sys' crate

--- stderr
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
Package 'dbus-1', required by 'virtual:world', not found
Package 'dbus-1', required by 'virtual:world', not found

One possible solution is to check whether packages
'libdbus-1-dev' and 'pkg-config' are installed:
On Ubuntu:
sudo apt install libdbus-1-dev pkg-config
On Fedora:
sudo dnf install dbus-devel pkgconf-pkg-config

thread 'main' panicked at 'explicit panic', /home/totto/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdbus-sys-0.2.5/build.rs:25:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for libdbus-sys v0.2.5

Caused by:
process didn't exit successfully: /home/totto/Downloads/HyperXCloudIIWireless-main/target/release/build/libdbus-sys-9400c167139cd70f/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=build_vendored.rs
cargo:rerun-if-env-changed=DBUS_1_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=DBUS_1_STATIC
cargo:rerun-if-env-changed=DBUS_1_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
pkg_config failed: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6" did not exit successfully: exit status: 1
error: could not find system library 'dbus-1' required by the 'libdbus-sys' crate

--- stderr
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
Package 'dbus-1', required by 'virtual:world', not found
Package 'dbus-1', required by 'virtual:world', not found

One possible solution is to check whether packages
'libdbus-1-dev' and 'pkg-config' are installed:
On Ubuntu:
sudo apt install libdbus-1-dev pkg-config
On Fedora:
sudo dnf install dbus-devel pkgconf-pkg-config

thread 'main' panicked at 'explicit panic', /home/totto/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdbus-sys-0.2.5/build.rs:25:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
[totto@zsolti-pc HyperXCloudIIWireless-main]$

@LennardKittner
Copy link
Owner

LennardKittner commented Jun 16, 2023

It complains about dbus not being installed, but dbus is only used for the tray application.
try to run cargo build --bin cli_app.
If this does not work either remove the two last lines from Cargo.toml and then run cargo build --bin cli_app again.
Or you could just install the missing dependencies as shown in the error message sudo dnf install dbus-devel pkgconf-pkg-config .

@tottoszsolt
Copy link
Author

Tried compiling after installing the missing dependencies:
Compiling pkg-config v0.3.27
Compiling libc v0.2.146
Compiling proc-macro2 v1.0.60
Compiling unicode-width v0.1.10
Compiling unicode-ident v1.0.9
Compiling quote v1.0.28
Compiling vec_map v0.8.2
Compiling strsim v0.8.0
Compiling bitflags v1.3.2
Compiling ansi_term v0.12.1
Compiling xml-rs v0.8.14
Compiling thiserror v1.0.40
Compiling cc v1.0.79
Compiling textwrap v0.11.0
Compiling libdbus-sys v0.2.5
Compiling hidapi v2.3.3
Compiling syn v2.0.18
Compiling atty v0.2.14
Compiling dbus v0.9.7
Compiling clap v2.34.0
error: failed to run custom build command for hidapi v2.3.3

Caused by:
process didn't exit successfully: /home/totto/Downloads/HyperXCloudIIWireless-main/target/release/build/hidapi-5a158c9dd26ab897/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=etc/hidapi/linux/hid.c
cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBUDEV_STATIC
cargo:rerun-if-env-changed=LIBUDEV_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at 'Unable to find libudev: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "libudev" did not exit successfully: exit status: 1
error: could not find system library 'libudev' required by the 'hidapi' crate

--- stderr
Package libudev was not found in the pkg-config search path.
Perhaps you should add the directory containing libudev.pc' to the PKG_CONFIG_PATH environment variable Package 'libudev', required by 'virtual:world', not found ', /home/totto/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hidapi-2.3.3/build.rs:58:54 note: run with RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@LennardKittner
Copy link
Owner

You have to install hidapi sudo dnf install hidapi.

@tottoszsolt
Copy link
Author

I have already installed it

@LennardKittner
Copy link
Owner

ah my bad it says libudev is missing.
sudo dnf install rust-libudev-sys-devel

@tottoszsolt
Copy link
Author

Damn.. I saw that too but cant find the install command for that.. cheking if its working..

@LennardKittner
Copy link
Owner

I also found this but don't know what the difference is sudo dnf install rust-libudev+default-devel

@tottoszsolt
Copy link
Author

I have run it, but still, broken pipe error

@tottoszsolt
Copy link
Author

also, finally compiled with no error

@LennardKittner
Copy link
Owner

Try git checkout 1-fedora-38-broken-pipe-issue and build again.

@tottoszsolt
Copy link
Author

There is no git repository it says

@LennardKittner
Copy link
Owner

are you in the root of the repo?

@tottoszsolt
Copy link
Author

Yeah, I was, now I see there is a separate repo.. I download that, and check in a moment

@LennardKittner
Copy link
Owner

LennardKittner commented Aug 24, 2023

Hi,
@tottoszsolt and I tried to find out what the Hyperx app sends to the old headset, but we were not successful.
When I use Wire Shark as described in the README, I find the package, which I have to send to the device
image
[0x06, 0xff, 0xbb, 0x02].

However, we were not able to locate a similar packet on his computer.
Thus, there are currently two possibilities:

  1. Someone else tries to find the packet using Wire Shark and sends me the data I need.
  2. I (or someone else) tries to reverse engineer the Hyperx app. I heard that it has no obfuscation and is pretty easy to disassemble with dnSpy. However, I already tried to disassemble it once and failed, but I also didn't have much time and am unfamiliar with dnSpy.

@miikeyjay
Copy link

ok, im gonna try to replicate the tutorial in the README with wireshark and post here the result.

@LennardKittner
Copy link
Owner

OK, If you have any questions please ask.

@miikeyjay
Copy link

can you make a example of the packet you need, i used the print you sent as a example and got this
Captura de tela 2023-08-24 124418

@LennardKittner
Copy link
Owner

Thank you.
I have updated the device tester with your package.
To test if it works, checkout the issue branch (https://github.com/LennardKittner/HyperXCloudIIWireless/tree/1-fedora-38-broken-pipe-issue).
and run cargo run --bin device_tester.
Please let me know if any test returns a response different from [].

In general, I'm not sure what package I'm looking for, but I suspect it should be

  1. Send from host to device.
  2. Send repeatedly every few seconds.
  3. Have some data fragments.

If you find any other packages that meet these requirements, please let me know.

@LennardKittner LennardKittner self-assigned this Aug 24, 2023
@miikeyjay
Copy link

all responses are these
image

@LennardKittner
Copy link
Owner

LennardKittner commented Aug 24, 2023

Interestingly the third package (the one you sent me) did not work but the first did.
Is your headset at 89%?

@miikeyjay
Copy link

yes, it is at 89%

@miikeyjay
Copy link

running the cli_app works now but the hyperx_x_cloud_ii_wireless doesn't
image

@LennardKittner
Copy link
Owner

Strange the two apps use the same code to interact with the device.
I will look into it.

@LennardKittner
Copy link
Owner

LennardKittner commented Aug 29, 2023

Sorry for the late response.
Yes, both applications use the same backend code; the only difference is that the cli application sends the battery request just once.
Does the tray application crash immediately, or does it show the battery level and then crash at some point?
If you execute the cli app multiple times, do you get the correct response every time?

@miikeyjay
Copy link

when i run the tray app it waits a second and give the error message,
image
the cli app doesnt work every time, since the last 5 days it worked around 2 times only.
image

@LennardKittner
Copy link
Owner

Interesting @tottoszsolt reports similar behavior. It seems like the packet sent to the headset only works once per power cycle.
I think this is because the headset is waiting for a specific answer but does not get one and thus shuts down the conversation.
Could you maybe look again with Wire Shark to see if you find any additional packets that are regularly sent between the host and headset, or vice versa?
You could also send me a dump of the traffic, and I'll take a look.

@miikeyjay
Copy link

sorry for the delay, life happened, i tried to dump all the packets from the headset, if you need any other info on it feel free to ask.
only cloud ii.zip

@LennardKittner
Copy link
Owner

Thank you, I will look into it :)

@LennardKittner
Copy link
Owner

Hi, sorry for the late response. I checked the log, and the packet I sent matches the packet sent in the log. However, it seems like the host also sends some interrupts to the device; maybe these are the key? I don't see an option to send interrupts with the HID library I used in the project. I will try to find another HID library or to decompile the Windows app and look into what actually happens. Decompiling the Windows app is a bit annoying because, as far as I can tell, it is only available through the Windows Store.

@miikeyjay
Copy link

miikeyjay commented Oct 29, 2023

No problem, if you need anything that i can provide to help just ping me and i will try.

@LennardKittner
Copy link
Owner

Hey, thank you for the offer. If you want you could look into how to disassemble the hyperx windows app or haw to get the hyperx windows app without using the windows store (if that is even possible).

@miikeyjay
Copy link

after a while i started to search for information on this and found this python app that works with my headset (https://github.com/Agustin-Jerusalinsky/hyperx-cloud-II-battery) the battery.py returns the right %

@LennardKittner
Copy link
Owner

Yes, I would expect that. The first packet that was tested here, #1 (comment) is actually from that repository. However, I just noticed it does one thing different before the request for the battery level, it also sends a report request. I could also try that.
Does battery.py work every time, or only on the first try?

@miikeyjay
Copy link

yes, it is working every time, and the panel is working too

@LennardKittner
Copy link
Owner

Cool. I think the only difference is that it sends the report. I will try to do the same in my code.

@LennardKittner
Copy link
Owner

LennardKittner commented Jan 14, 2024

As far as I can tell, the library I use to interface with the headset has no get_input_report function. I could try to do something similar, but first I would like to know if this is really the issue.
Could you please run the battery.py again, but with lines 13 and 26 commented out?

@miikeyjay
Copy link

commenting both freezes my terminal, commenting only 13 still freezes my terminal, commenting only 26 gives the result every time i tested.
13-and-26-commented
13-commented
26-commented

@LennardKittner
Copy link
Owner

Thank you. I would have guessed that line 13 alone does not send anything to the device because of the "write" in line 26.
But apparently, that is not the case.

@Jason-THL
Copy link

Hello, is it possible to add a battery icon for the HyperX Cloud 3 Wireless as well?

@LennardKittner
Copy link
Owner

Hi, as you can see, supporting the old wireless 2 is already quite challenging / not possible. Therefore, I can't promise anything. However, if you provide me with the packets that have to be sent to the headset and its product id I can try to add support for it. Also, could you please create a new issue regarding the wireless 3?

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

When branches are created from issues, their pull requests are automatically linked.

4 participants