Add timestamps for inputs

This commit is contained in:
Patrick Nicolas
2023-06-30 12:25:15 +02:00
parent 20835c6e7f
commit 2704b46927
7 changed files with 27 additions and 21 deletions
+6 -3
View File
@@ -761,7 +761,7 @@ void application::poll_actions()
instance_->xr_session.sync_actions(instance_->xr_actionset);
}
bool application::read_action(XrAction action, bool & value)
bool application::read_action(XrAction action, bool & value, XrTime& last_change_time)
{
if (!is_focused())
return false;
@@ -778,10 +778,11 @@ bool application::read_action(XrAction action, bool & value)
return false;
value = state.currentState;
last_change_time = state.lastChangeTime;
return true;
}
bool application::read_action(XrAction action, float & value)
bool application::read_action(XrAction action, float & value, XrTime& last_change_time)
{
if (!is_focused())
return false;
@@ -798,10 +799,11 @@ bool application::read_action(XrAction action, float & value)
return false;
value = state.currentState;
last_change_time = state.lastChangeTime;
return true;
}
bool application::read_action(XrAction action, XrVector2f & value)
bool application::read_action(XrAction action, XrVector2f & value, XrTime& last_change_time)
{
if (!is_focused())
return false;
@@ -818,6 +820,7 @@ bool application::read_action(XrAction action, XrVector2f & value)
return false;
value = state.currentState;
last_change_time = state.lastChangeTime;
return true;
}
+3 -3
View File
@@ -300,9 +300,9 @@ public:
};
static void poll_actions();
static bool read_action(XrAction action, float & value);
static bool read_action(XrAction action, bool & value);
static bool read_action(XrAction action, XrVector2f & value);
static bool read_action(XrAction action, float & value, XrTime& last_change_time);
static bool read_action(XrAction action, bool & value, XrTime& last_change_time);
static bool read_action(XrAction action, XrVector2f & value, XrTime& last_change_time);
static void haptic_start(XrAction action, XrPath subpath, int64_t duration, float frequency, float amplitude);
static void haptic_stop(XrAction action, XrPath subpath);
+8 -7
View File
@@ -28,26 +28,27 @@ void scenes::stream::read_actions()
{
switch (action_type)
{
XrTime last_change_time;
case XR_ACTION_TYPE_BOOLEAN_INPUT: {
bool value;
if (application::read_action(action, value))
inputs.values.push_back({id, (float)value});
if (application::read_action(action, value, last_change_time))
inputs.values.push_back({id, (float)value, (uint64_t)last_change_time});
}
break;
case XR_ACTION_TYPE_FLOAT_INPUT: {
float value;
if (application::read_action(action, value))
inputs.values.push_back({id, value});
if (application::read_action(action, value, last_change_time))
inputs.values.push_back({id, value, (uint64_t)last_change_time});
}
break;
case XR_ACTION_TYPE_VECTOR2F_INPUT: {
XrVector2f value;
if (application::read_action(action, value))
if (application::read_action(action, value, last_change_time))
{
inputs.values.push_back({id, value.x});
inputs.values.push_back({(device_id)((int)id + 1), value.y});
inputs.values.push_back({id, value.x, (uint64_t)last_change_time});
inputs.values.push_back({(device_id)((int)id + 1), value.y, (uint64_t)last_change_time});
}
}
break;