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

vrclient: Convert action manifests to unix paths #6109

Open
wants to merge 1 commit into
base: proton_7.0
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions vrclient_x64/gen_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"l2w_lens":[],
"w2l_names": ["pchActionManifestPath"],
"w2l_arrays": [False],
"file_converter": "json_convert_action_manifest",
"return_is_size": False
},
{
Expand All @@ -141,6 +142,7 @@
"l2w_lens":[],
"w2l_names": ["pchFilePath"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -149,6 +151,7 @@
"l2w_lens":[],
"w2l_names": ["pchApplicationManifestFullPath"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -157,6 +160,7 @@
"l2w_lens":[],
"w2l_names": ["pchApplicationManifestFullPath"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -165,6 +169,7 @@
"l2w_lens":[],
"w2l_names": ["pchPreviewFilename", "pchVRFilename"],
"w2l_arrays": [False, False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -173,6 +178,7 @@
"l2w_lens":[],
"w2l_names": ["pchPreviewFilename", "pchVRFilename"],
"w2l_arrays": [False, False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -181,6 +187,7 @@
"l2w_lens":[],
"w2l_names": ["pchSourcePreviewFilename", "pchSourceVRFilename"],
"w2l_arrays": [False, False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -189,6 +196,7 @@
"l2w_lens":["cchFilename"],
"w2l_names": [],
"w2l_arrays": [],
"file_converter": None,
"return_is_size": True
},
{
Expand All @@ -197,6 +205,7 @@
"l2w_lens":[],
"w2l_names": ["a"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -205,6 +214,7 @@
"l2w_lens":[],
"w2l_names": ["a"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},
{
Expand All @@ -213,6 +223,7 @@
"l2w_lens":[],
"w2l_names": ["pchRenderModelPath"],
"w2l_arrays": [False],
"file_converter": None,
"return_is_size": False
},

Expand Down Expand Up @@ -530,6 +541,8 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
else:
cfile.write(" char lin_%s[PATH_MAX];\n" % path_conv["w2l_names"][i])
cfile.write(" vrclient_dos_path_to_unix_path(%s, lin_%s);\n" % (path_conv["w2l_names"][i], path_conv["w2l_names"][i]))
if path_conv["file_converter"] is not None:
cfile.write(" %s(lin_%s);\n" % (path_conv["file_converter"], path_conv["w2l_names"][i]))
if None in path_conv["l2w_names"]:
cfile.write(" const char *path_result;\n")
elif path_conv["return_is_size"]:
Expand Down
44 changes: 44 additions & 0 deletions vrclient_x64/vrclient_x64/json_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
#include "vrclient_private.h"

#include "json/json.h"
#include <fstream>

extern "C" {

Expand Down Expand Up @@ -143,4 +144,47 @@ char *json_convert_startup_info(const char *startup_info)
return ret;
}

bool json_convert_action_manifest(const char *manifest_file)
{
char dst_path[PATH_MAX];
Json::CharReaderBuilder rbuilder;
std::ifstream manifest(manifest_file, std::ifstream::binary);
Json::Value root;
std::string errs;

WINE_TRACE("converting action manifest file %s.\n", manifest_file);

bool ok = Json::parseFromStream(rbuilder, manifest, &root, &errs);
manifest.close();
if (!ok) {
WINE_ERR("error parsing action manifest as JSON %s: %s.\n", manifest_file, errs.c_str());
return false;
}

if (!root.isMember("default_bindings"))
return true;

if (!root["default_bindings"].isArray()) {
WINE_ERR("error converting action manifest %s: default_bindings is not an array.\n", manifest_file);
return false;
}

for (Json::Value::ArrayIndex i = 0; i != root["default_bindings"].size(); i++) {
if (root["default_bindings"][i].isMember("binding_url")) {
if (!root["default_bindings"][i]["binding_url"].isString()) {
WINE_ERR("error converting action manifest %s: binding_url %i is not a string.\n", manifest_file, i);
return false;
}
vrclient_dos_path_to_unix_path(root["default_bindings"][i]["binding_url"].asCString(), dst_path);
root["default_bindings"][i]["binding_url"] = dst_path;
}
}

std::ofstream ofstream(manifest_file);
ofstream << root;
ofstream.close();

return true;
}

}
1 change: 1 addition & 0 deletions vrclient_x64/vrclient_x64/vrclient_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {

char *json_convert_paths(const char *input);
char *json_convert_startup_info(const char *startup_info);
bool json_convert_action_manifest(const char *manifest_file);

bool vrclient_dos_path_to_unix_path(const char *src, char *dst);

Expand Down
6 changes: 6 additions & 0 deletions vrclient_x64/vrclient_x64/winIVRInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_010_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_010_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down Expand Up @@ -377,6 +378,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_007_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_007_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down Expand Up @@ -688,6 +690,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_006_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_006_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down Expand Up @@ -981,6 +984,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_005_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_005_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down Expand Up @@ -1265,6 +1269,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_004_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_004_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down Expand Up @@ -1486,6 +1491,7 @@ EVRInputError __thiscall winIVRInput_IVRInput_003_SetActionManifestPath(winIVRIn
{
char lin_pchActionManifestPath[PATH_MAX];
vrclient_dos_path_to_unix_path(pchActionManifestPath, lin_pchActionManifestPath);
json_convert_action_manifest(lin_pchActionManifestPath);
TRACE("%p\n", _this);
return cppIVRInput_IVRInput_003_SetActionManifestPath(_this->linux_side, pchActionManifestPath ? lin_pchActionManifestPath : NULL);
}
Expand Down