Add timestamps for inputs
This commit is contained in:
@@ -209,7 +209,6 @@ wivrn_controller::wivrn_controller(int hand_id,
|
||||
{
|
||||
case 0:
|
||||
device_type = XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
||||
SET_INPUT(MENU_CLICK);
|
||||
|
||||
// Print name.
|
||||
strcpy(str, "WiVRn HMD left hand controller");
|
||||
@@ -240,16 +239,16 @@ void wivrn_controller::update_inputs()
|
||||
inputs_array = inputs_staging;
|
||||
}
|
||||
|
||||
void wivrn_controller::set_inputs(const from_headset::inputs & inputs)
|
||||
void wivrn_controller::set_inputs(const from_headset::inputs & inputs, const clock_offset& clock_offset)
|
||||
{
|
||||
std::lock_guard lock{mutex};
|
||||
for (const auto & input: inputs.values)
|
||||
{
|
||||
set_inputs(input.id, input.value);
|
||||
set_inputs(input.id, input.value, clock_offset.from_headset(input.last_change_time));
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_controller::set_inputs(device_id input_id, float value)
|
||||
void wivrn_controller::set_inputs(device_id input_id, float value, uint64_t last_change_time)
|
||||
{
|
||||
const struct wivrn_to_wivrn_controller_input * bindings;
|
||||
size_t bindings_count;
|
||||
@@ -276,6 +275,7 @@ void wivrn_controller::set_inputs(device_id input_id, float value)
|
||||
|
||||
if (binding)
|
||||
{
|
||||
inputs_staging[binding->input_id].timestamp = last_change_time;
|
||||
switch (binding->input_type)
|
||||
{
|
||||
case wivrn_input_type::BOOL:
|
||||
|
||||
@@ -54,11 +54,11 @@ public:
|
||||
|
||||
void set_output(xrt_output_name name, const xrt_output_value * value);
|
||||
|
||||
void set_inputs(const from_headset::inputs &);
|
||||
void set_inputs(const from_headset::inputs &, const clock_offset &);
|
||||
|
||||
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||
|
||||
private:
|
||||
void
|
||||
set_inputs(device_id input_id, float value);
|
||||
set_inputs(device_id input_id, float value, uint64_t last_change_time);
|
||||
};
|
||||
|
||||
@@ -160,8 +160,9 @@ void wivrn_session::operator()(from_headset::tracking && tracking)
|
||||
|
||||
void wivrn_session::operator()(from_headset::inputs && inputs)
|
||||
{
|
||||
left_hand->set_inputs(inputs);
|
||||
right_hand->set_inputs(inputs);
|
||||
auto offset = get_offset();
|
||||
left_hand->set_inputs(inputs, offset);
|
||||
right_hand->set_inputs(inputs, offset);
|
||||
}
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
|
||||
Reference in New Issue
Block a user