Native USB networking for Quest

Requires Horizon OS >= 2.6
This commit is contained in:
Patrick Nicolas
2026-08-29 12:33:59 +02:00
parent 8333322cd2
commit 8738131fb1
21 changed files with 317 additions and 93 deletions
+18 -6
View File
@@ -59,6 +59,15 @@ void init_stream(T & stream)
{
stream.set_receive_buffer_size(1024 * 1024 * 5);
}
auto & port(sockaddr_in & sa)
{
return sa.sin_port;
}
auto & port(sockaddr_in6 & sa)
{
return sa.sin6_port;
}
} // namespace
template <typename T>
@@ -120,7 +129,9 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke
{
stream = decltype(stream)();
stream.connect(address, h.stream_port);
port(address) = htons(h.stream_port);
stream.connect(address);
init_stream(stream);
}
break;
@@ -171,7 +182,8 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke
stream = decltype(stream)();
stream.set_aes_key_and_ivs(s.stream_key, s.stream_iv_header_to_headset, s.stream_iv_header_from_headset);
stream.connect(address, h.stream_port);
port(address) = htons(h.stream_port);
stream.connect(address);
init_stream(stream);
}
break;
@@ -209,8 +221,8 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke
}
}
wivrn_session::wivrn_session(in6_addr address, int port, bool tcp_only, crypto::key & headset_keypair, std::function<std::string(int fd)> pin_enter) :
control(address, port), stream(-1), address(address)
wivrn_session::wivrn_session(sockaddr_in6 address, bool tcp_only, crypto::key & headset_keypair, std::function<std::string(int fd)> pin_enter) :
control(address), stream(-1), address(address.sin6_addr)
{
try
{
@@ -222,8 +234,8 @@ wivrn_session::wivrn_session(in6_addr address, int port, bool tcp_only, crypto::
}
}
wivrn_session::wivrn_session(in_addr address, int port, bool tcp_only, crypto::key & headset_keypair, std::function<std::string(int fd)> pin_enter) :
control(address, port), stream(-1), address(address)
wivrn_session::wivrn_session(sockaddr_in address, bool tcp_only, crypto::key & headset_keypair, std::function<std::string(int fd)> pin_enter) :
control(address), stream(-1), address(address.sin_addr)
{
try
{