keyboard & mouse forwarding

This commit is contained in:
galister
2025-11-11 21:12:01 +01:00
committed by Patrick Nicolas
parent efde4bf247
commit 2063cae3ae
22 changed files with 924 additions and 2 deletions
+33
View File
@@ -1302,3 +1302,36 @@ void scenes::stream::on_xr_event(const xr::event & event)
break;
}
}
bool scenes::stream::forward_hid_input(from_headset::hid::input_t packet)
{
if (not hid_forwarding)
return false;
network_session->send_control(from_headset::hid::input{packet});
return true;
}
bool scenes::stream::on_input_key_down(uint8_t key_code)
{
return forward_hid_input(from_headset::hid::key_down{key_code});
}
bool scenes::stream::on_input_key_up(uint8_t key_code)
{
return forward_hid_input(from_headset::hid::key_up{key_code});
}
bool scenes::stream::on_input_mouse_move(float x, float y)
{
return forward_hid_input(from_headset::hid::mouse_move{x, y});
}
bool scenes::stream::on_input_button_down(uint8_t button)
{
return forward_hid_input(from_headset::hid::button_down{button});
}
bool scenes::stream::on_input_button_up(uint8_t button)
{
return forward_hid_input(from_headset::hid::button_up{button});
}
bool scenes::stream::on_input_scroll(float h, float v)
{
return forward_hid_input(from_headset::hid::mouse_scroll{h, v});
}
+10
View File
@@ -81,6 +81,7 @@ private:
std::array<std::atomic<interaction_profile>, 2> interaction_profiles; // left and right hand
std::atomic<bool> interaction_profile_changed = false;
std::atomic<bool> recenter_requested = false;
std::atomic<bool> hid_forwarding = false;
std::atomic<XrDuration> display_time_phase = 0;
std::atomic<XrDuration> display_time_period = 0;
XrTime last_display_time = 0;
@@ -173,6 +174,8 @@ private:
stream(std::string server_name, scene & parent_scene);
bool forward_hid_input(from_headset::hid::input_t);
public:
~stream();
@@ -187,6 +190,13 @@ public:
void on_unfocused() override;
void on_xr_event(const xr::event &) override;
bool on_input_key_down(uint8_t key_code) override;
bool on_input_key_up(uint8_t key_code) override;
bool on_input_mouse_move(float x, float y) override;
bool on_input_button_down(uint8_t button) override;
bool on_input_button_up(uint8_t button) override;
bool on_input_scroll(float h, float v) override;
void operator()(to_headset::crypto_handshake &&) {};
void operator()(to_headset::pin_check_2 &&) {};
void operator()(to_headset::pin_check_4 &&) {};
+4 -1
View File
@@ -556,7 +556,7 @@ void scenes::stream::tracking()
e.code().value() != XR_ERROR_TIME_INVALID)
throw;
}
}
} // end prediction loop
XrDuration busy_time = t.count();
// Target: polling between 1 and 5ms, with 20% busy time
@@ -658,6 +658,9 @@ void scenes::stream::operator()(to_headset::tracking_control && packet)
if (audio_handle)
audio_handle->set_mic_state(packet.enabled[m]);
auto n = size_t(wivrn::to_headset::tracking_control::id::hid_input);
hid_forwarding = packet.enabled[n];
*locked = packet;
locked->min_offset = std::min(locked->min_offset, locked->max_offset);
}