Skip to content

Commit

Permalink
HITL - Make client loading state available to applications. (facebook…
Browse files Browse the repository at this point in the history
…research#1955)

* Make client loading state available to applications.

* Simplify code.
  • Loading branch information
0mdc authored and dannymcy committed Jun 26, 2024
1 parent 17edaa6 commit 0970291
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions habitat-hitl/habitat_hitl/core/remote_client_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(
self._client_state_history.append([])
self._receive_rate_trackers.append(AverageRateTracker(2.0))

self._client_loading: List[bool] = [False] * users.max_user_count

# temp map VR button to key
self._button_map = {
0: GuiInput.KeyNS.ZERO,
Expand All @@ -81,6 +83,10 @@ def get_gui_inputs(self) -> List[GuiInput]:
"""Get a list of all GuiInputs indexed by user index."""
return self._gui_inputs

def is_user_loading(self, user_index: int) -> bool:
"""Return true if the specified user's client is in a loading state."""
return self._client_loading[user_index]

def bind_gui_input(self, gui_input: GuiInput, user_index: int) -> None:
"""
Bind the specified GuiInput to a specified user, allowing the associated remote client to control it.
Expand Down Expand Up @@ -282,6 +288,11 @@ def _update_input_state(
# frame and other ways that keyHeld, keyDown, and keyUp can be inconsistent.
last_client_state = client_states[-1]

# Loading states.
self._client_loading[user_index] = last_client_state.get(
"isLoading", False
)

input_json = (
last_client_state["input"]
if "input" in last_client_state
Expand Down

0 comments on commit 0970291

Please sign in to comment.