Skip to content

Commit

Permalink
Merge branch 'master' into lua-api
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 16, 2024
2 parents c2994ca + 921163c commit 49c3623
Show file tree
Hide file tree
Showing 29 changed files with 1,264 additions and 286 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ FetchContent_Declare(bddisasm
)
FetchContent_MakeAvailable(bddisasm)

message(STATUS "Fetching kananlib (d34dd2130c9fb47b1cd5bd456ab72707e34d33bf)...")
message(STATUS "Fetching kananlib (cca66766b139994f478ea48befd67a179b7310ab)...")
FetchContent_Declare(kananlib
GIT_REPOSITORY
"https://github.com/cursey/kananlib"
GIT_TAG
d34dd2130c9fb47b1cd5bd456ab72707e34d33bf
cca66766b139994f478ea48befd67a179b7310ab
)
FetchContent_MakeAvailable(kananlib)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Universal Unreal Engine VR Mod (4/5)

## Supported Engine Versions

4.8 - 5.3
4.8 - 5.4

## Links

Expand Down
2 changes: 1 addition & 1 deletion cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tag = "70db095765ab2066dd88dfb7bbcc42259ed167c5"

[fetch-content.kananlib]
git = "https://github.com/cursey/kananlib"
tag = "d34dd2130c9fb47b1cd5bd456ab72707e34d33bf"
tag = "cca66766b139994f478ea48befd67a179b7310ab"

[fetch-content.safetyhook]
git = "https://github.com/praydog/safetyhook"
Expand Down
2 changes: 1 addition & 1 deletion dependencies/submodules/UESDK
Submodule UESDK updated from 04cac5 to b2a73d
55 changes: 55 additions & 0 deletions examples/example_plugin/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ class ExamplePlugin : public uevr::Plugin {
}
}

void reset_height() {
auto& api = API::get();
auto vr = api->param()->vr;
UEVR_Vector3f origin{};
vr->get_standing_origin(&origin);

UEVR_Vector3f hmd_pos{};
UEVR_Quaternionf hmd_rot{};
vr->get_pose(vr->get_hmd_index(), &hmd_pos, &hmd_rot);

origin.y = hmd_pos.y;

vr->set_standing_origin(&origin);
}

void on_device_reset() override {
PLUGIN_LOG_ONCE("Example Device Reset");

Expand Down Expand Up @@ -498,6 +513,46 @@ class ExamplePlugin : public uevr::Plugin {
void internal_frame() {
if (ImGui::Begin("Super Cool Plugin")) {
ImGui::Text("Hello from the super cool plugin!");
ImGui::Text("Snap turn: %i", API::VR::is_snap_turn_enabled());
ImGui::Text("Decoupled pitch: %i", API::VR::is_decoupled_pitch_enabled());
if (ImGui::Button("Toggle snap turn")) {
API::VR::set_snap_turn_enabled(!API::VR::is_snap_turn_enabled());
}

if (ImGui::Button("Toggle decoupled pitch")) {
API::VR::set_decoupled_pitch_enabled(!API::VR::is_decoupled_pitch_enabled());
}

if (ImGui::Button("Screw up world scale")) {
API::VR::set_mod_value("VR_WorldScale", 1.337f);
}

if (ImGui::Button("Toggle GUI")) {
const bool enabled = API::VR::get_mod_value<bool>("VR_EnableGUI");
API::VR::set_mod_value("VR_EnableGUI", !enabled);
}

static char input[256]{};
if (ImGui::InputText("Get mod value", input, sizeof(input))) {

}

std::string mod_value = API::VR::get_mod_value<std::string>(input);
ImGui::Text("Mod value: %s", mod_value.c_str());

if (ImGui::Button("Save Config")) {
API::VR::save_config();
}

if (ImGui::Button("Reload Config")) {
API::VR::reload_config();
}

if (ImGui::Button("Toggle UObjectHook disabled")) {
const auto value = API::UObjectHook::is_disabled();

API::UObjectHook::set_disabled(!value);
}
#if defined(__clang__)
ImGui::Text("Plugin Compiler: Clang");
#elif defined(_MSC_VER)
Expand Down
21 changes: 18 additions & 3 deletions examples/renderlib/rendering/d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ bool D3D11::initialize() {
}

void D3D11::render_imgui() {
auto draw_data = ImGui::GetDrawData();

if (draw_data == nullptr) {
return;
}

ComPtr<ID3D11DeviceContext> context{};
float clear_color[]{0.0f, 0.0f, 0.0f, 0.0f};

Expand All @@ -67,14 +73,23 @@ void D3D11::render_imgui() {
device->GetImmediateContext(&context);
context->ClearRenderTargetView(this->rt_rtv.Get(), clear_color);
context->OMSetRenderTargets(1, this->rt_rtv.GetAddressOf(), NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
ImGui_ImplDX11_RenderDrawData(draw_data);

// Set the back buffer to be the render target.
context->OMSetRenderTargets(1, this->bb_rtv.GetAddressOf(), nullptr);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
ImGui_ImplDX11_RenderDrawData(draw_data);
}

void D3D11::render_imgui_vr(ID3D11DeviceContext* context, ID3D11RenderTargetView* rtv) {
if (context == nullptr || rtv == nullptr) {
return;
}

auto draw_data = ImGui::GetDrawData();
if (draw_data == nullptr) {
return;
}

context->OMSetRenderTargets(1, &rtv, NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
ImGui_ImplDX11_RenderDrawData(draw_data);
}
10 changes: 8 additions & 2 deletions examples/renderlib/rendering/d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ bool D3D12::initialize() {
return true;
}

void D3D12::render_imgui() {
void D3D12::render_imgui() {
auto draw_data = ImGui::GetDrawData();

if (draw_data == nullptr) {
return;
}

auto& cmd = this->cmds[this->frame_count++ % this->cmds.size()];

if (cmd.fence_event != nullptr && cmd.fence != nullptr && cmd.fence->GetCompletedValue() < cmd.fence_value) {
Expand Down Expand Up @@ -166,7 +172,7 @@ void D3D12::render_imgui() {
rts[0] = this->get_cpu_rtv(device, (D3D12::RTV)bb_index);
cmd.list->OMSetRenderTargets(1, rts, FALSE, NULL);
cmd.list->SetDescriptorHeaps(1, this->srv_desc_heap.GetAddressOf());
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), cmd.list.Get());
ImGui_ImplDX12_RenderDrawData(draw_data, cmd.list.Get());
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
cmd.list->ResourceBarrier(1, &barrier);
Expand Down
14 changes: 13 additions & 1 deletion include/uevr/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SOFTWARE.
#define UEVR_OUT

#define UEVR_PLUGIN_VERSION_MAJOR 2
#define UEVR_PLUGIN_VERSION_MINOR 17
#define UEVR_PLUGIN_VERSION_MINOR 20
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -340,6 +340,9 @@ typedef struct {
UEVR_UObjectHookMotionControllerStateHandle (*get_motion_controller_state)(UEVR_UObjectHandle object);

UEVR_UObjectHookMotionControllerStateFunctions* mc_state;

bool (*is_disabled)();
void (*set_disabled)(bool disabled);
} UEVR_UObjectHookFunctions;

typedef struct {
Expand Down Expand Up @@ -517,6 +520,15 @@ typedef struct {
unsigned int (*get_hmd_height)();
unsigned int (*get_ui_width)();
unsigned int (*get_ui_height)();

bool (*is_snap_turn_enabled)();
void (*set_snap_turn_enabled)(bool enabled);
void (*set_decoupled_pitch_enabled)(bool enabled);

void (*set_mod_value)(const char* key, const char* value);
void (*get_mod_value)(const char* key, char* value, unsigned int value_size);
void (*save_config)();
void (*reload_config)();
} UEVR_VRData;

typedef struct {
Expand Down
Loading

0 comments on commit 49c3623

Please sign in to comment.