Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement glasses display name query #71

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion example.csharp/addons/tiltfive/T5Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ public override void _Ready()
}
}

public string GetUIDisplayName(string glassesID)
{
if(string.IsNullOrEmpty(glassesID)
|| !xrInterface.Get("is_initialized").AsBool()
|| !glassesDictionary.TryGetValue(glassesID, out var xrRigState)
|| !xrRigState.available)
{
return string.Empty;
}

return xrInterface.Call("get_glasses_name", glassesID).AsString();
}

void StartDisplay(string glassesID, T5XRRig xrRig) {

xrInterface.Call("start_display", glassesID, xrRig, xrRig.Origin);
Expand All @@ -103,7 +116,7 @@ void ProcessGlasses()
if(entry.Value.CanAttemptToReserve && Manager.ShouldUseGlasses(entry.Key))
{
entry.Value.attemptingToReserve = true;
xrInterface.Call("reserve_glasses", entry.Key, Manager.GetUIDisplayName(entry.Key));
xrInterface.Call("reserve_glasses", entry.Key, ProjectSettings.GetSetting("application/config/name"));
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion example.csharp/addons/tiltfive/T5Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public bool ShouldUseGlasses(string glassesID)

public string GetUIDisplayName(string glassesID)
{
return T5ProjectSettings.DefaultDisplayName;
var uiDisplayName = t5Interface.GetUIDisplayName(glassesID);
return string.IsNullOrEmpty(uiDisplayName)
? T5ProjectSettings.DefaultDisplayName
: uiDisplayName;
}

public T5XRRig CreateXRRig(string glassesID)
Expand Down
12 changes: 12 additions & 0 deletions extension/src/TiltFiveXRInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void TiltFiveXRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("release_glasses", "glasses_id"), &TiltFiveXRInterface::release_glasses);
ClassDB::bind_method(D_METHOD("get_available_glasses_ids"), &TiltFiveXRInterface::get_available_glasses_ids);
ClassDB::bind_method(D_METHOD("get_reserved_glasses_ids"), &TiltFiveXRInterface::get_reserved_glasses_ids);
ClassDB::bind_method(D_METHOD("get_glasses_name", "glasses_id"), &TiltFiveXRInterface::get_glasses_name);
ClassDB::bind_method(D_METHOD("get_gameboard_type", "glasses_id"), &TiltFiveXRInterface::get_gameboard_type);
ClassDB::bind_method(D_METHOD("get_gameboard_extents", "gameboard_type"), &TiltFiveXRInterface::get_gameboard_extents);

Expand Down Expand Up @@ -284,6 +285,17 @@ PackedStringArray TiltFiveXRInterface::get_reserved_glasses_ids() {
return reserved_list;
}

String TiltFiveXRInterface::get_glasses_name(const StringName glasses_id) {
if(!t5_service)
return String("");

auto entry = lookup_glasses_entry(glasses_id);
ERR_FAIL_COND_V_MSG(!entry, String(""), "Glasses id was not found");

std::string glasses_name = t5_service->get_glasses_name(entry->idx);
return String(glasses_name.c_str());
}

TiltFiveXRInterface::GameBoardType TiltFiveXRInterface::get_gameboard_type(const StringName glasses_id) {
if (!t5_service)
return NO_GAMEBOARD_SET;
Expand Down
2 changes: 2 additions & 0 deletions extension/src/TiltFiveXRInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class TiltFiveXRInterface : public XRInterfaceExtension {
PackedStringArray get_available_glasses_ids();
PackedStringArray get_reserved_glasses_ids();

String get_glasses_name(const StringName glasses_id);

// Overriden from XRInterfaceExtension
virtual StringName _get_name() const override;
virtual uint32_t _get_capabilities() const override;
Expand Down
Loading