This commit is contained in:
louist103
2024-05-22 09:04:57 -05:00
committed by Garrett Cox
parent 2ffb61f019
commit c351a4a580
9 changed files with 2085 additions and 32 deletions
+1
View File
@@ -54,3 +54,4 @@ mm/libultraship/extern/StrHash64.dir/Debug/StrHash64.tlog/Lib.command.1.tlog
/build*
/Release
.vs/*
/x64
+7 -3
View File
@@ -22,9 +22,13 @@ endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(CMake/automate-vcpkg.cmake)
set(VCPKG_TRIPLET x86-windows-static)
set(VCPKG_TARGET_TRIPLET x86-windows-static)
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
set(VCPKG_TRIPLET x86-windows-static)
set(VCPKG_TARGET_TRIPLET x86-windows-static)
elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
endif()
vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libpng sdl2 sdl2-net glew glfw3)
endif()
+1 -1
Submodule ZAPDTR updated: 8c4b116a2d...51917d817a
+24 -12
View File
@@ -52,6 +52,8 @@ CrowdControl* CrowdControl::Instance;
#include <libultraship/libultraship.h>
#include <SohGui.hpp>
#include "Enhancements/controls/SohInputEditorWindow.h"
// Resource Types/Factories
#include "2s2h/resource/type/Animation.h"
#include "2s2h/resource/type/AudioSample.h"
@@ -121,6 +123,7 @@ OTRGlobals::OTRGlobals() {
OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2 };
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
context = LUS::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3);
//context = LUS::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
@@ -1279,15 +1282,24 @@ Color_RGB8 GetColorForControllerLED() {
}
extern "C" void OTRControllerCallback(uint8_t rumble) {
auto physicalDevice = LUS::Context::GetInstance()->GetControlDeck()->GetDeviceFromPortIndex(0);
// We call this every tick, SDL accounts for this use and prevents driver spam
// https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor(
GetColorForControllerLED());
if (physicalDevice->CanSetLed()) {
// We call this every tick, SDL accounts for this use and prevents driver spam
// https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144
physicalDevice->SetLedColor(0, GetColorForControllerLED());
static std::shared_ptr<SohInputEditorWindow> controllerConfigWindow = nullptr;
if (controllerConfigWindow == nullptr) {
controllerConfigWindow = std::dynamic_pointer_cast<SohInputEditorWindow>(
LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor"));
} else if (controllerConfigWindow->TestingRumble()) {
return;
}
physicalDevice->SetRumble(0, rumble);
if (rumble) {
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble();
} else {
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble();
}
}
extern "C" float OTRGetAspectRatio() {
@@ -1326,12 +1338,12 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {
}
extern "C" int Controller_ShouldRumble(size_t slot) {
auto controlDeck = LUS::Context::GetInstance()->GetControlDeck();
if (slot < controlDeck->GetNumConnectedPorts()) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);
if (physicalDevice->GetProfile(slot)->UseRumble && physicalDevice->CanRumble()) {
for (auto [id, mapping] : LUS::Context::GetInstance()
->GetControlDeck()
->GetControllerByPort(static_cast<uint8_t>(slot))
->GetRumble()
->GetAllRumbleMappings()) {
if (mapping->PhysicalDeviceIsConnected()) {
return 1;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,89 @@
#pragma once
#include "stdint.h"
#include <libultraship/libultraship.h>
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include <ImGui/imgui.h>
#include <unordered_map>
#include <string>
#include <vector>
#include <set>
class SohInputEditorWindow : public LUS::GuiWindow {
public:
using GuiWindow::GuiWindow;
~SohInputEditorWindow();
void DrawButton(const char* label, int32_t n64Btn, int32_t currentPort, int32_t* btnReading);
void DrawInputChip(const char* buttonName, ImVec4 color);
void DrawAnalogPreview(const char* label, ImVec2 stick, float deadzone = 0, bool gyro = false);
void DrawControllerSchema();
bool TestingRumble();
protected:
void InitElement() override;
void DrawElement() override;
void UpdateElement() override;
private:
void DrawStickDirectionLine(const char* axisDirectionName, uint8_t port, uint8_t stick, LUS::Direction direction,
ImVec4 color);
void DrawButtonLine(const char* buttonName, uint8_t port, uint16_t bitmask, ImVec4 color);
void DrawButtonLineEditMappingButton(uint8_t port, uint16_t bitmask, std::string id);
void DrawButtonLineAddMappingButton(uint8_t port, uint16_t bitmask);
void DrawStickDirectionLineEditMappingButton(uint8_t port, uint8_t stick, LUS::Direction direction, std::string id);
void DrawStickDirectionLineAddMappingButton(uint8_t port, uint8_t stick, LUS::Direction direction);
void DrawStickSection(uint8_t port, uint8_t stick, int32_t id, ImVec4 color);
void DrawRumbleSection(uint8_t port);
void DrawRemoveRumbleMappingButton(uint8_t port, std::string id);
void DrawAddRumbleMappingButton(uint8_t port);
void DrawLEDSection(uint8_t port);
void DrawRemoveLEDMappingButton(uint8_t port, std::string id);
void DrawAddLEDMappingButton(uint8_t port);
void DrawGyroSection(uint8_t port);
void DrawRemoveGyroMappingButton(uint8_t port, std::string id);
void DrawAddGyroMappingButton(uint8_t port);
int32_t mGameInputBlockTimer;
int32_t mMappingInputBlockTimer;
int32_t mRumbleTimer;
std::shared_ptr<LUS::ControllerRumbleMapping> mRumbleMappingToTest;
// mBitmaskToMappingIds[port][bitmask] = { id0, id1, ... }
std::unordered_map<uint8_t, std::unordered_map<uint16_t, std::vector<std::string>>> mBitmaskToMappingIds;
// mStickDirectionToMappingIds[port][stick][direction] = { id0, id1, ... }
std::unordered_map<uint8_t,
std::unordered_map<uint8_t, std::unordered_map<LUS::Direction, std::vector<std::string>>>>
mStickDirectionToMappingIds;
void UpdateBitmaskToMappingIds(uint8_t port);
void UpdateStickDirectionToMappingIds(uint8_t port);
void GetButtonColorsForLUSDeviceIndex(LUS::LUSDeviceIndex lusIndex, ImVec4& buttonColor,
ImVec4& buttonHoveredColor);
void DrawLinkTab();
void DrawIvanTab();
void DrawDebugPortTab(uint8_t portIndex, std::string customName = "");
void DrawDevicesTab();
std::set<uint16_t> mButtonsBitmasks;
std::set<uint16_t> mDpadBitmasks;
std::set<uint16_t> mModifierButtonsBitmasks;
void DrawButtonDeviceIcons(uint8_t portIndex, std::set<uint16_t> bitmasks);
void DrawAnalogStickDeviceIcons(uint8_t portIndex, LUS::Stick stick);
void DrawRumbleDeviceIcons(uint8_t portIndex);
void DrawGyroDeviceIcons(uint8_t portIndex);
void DrawLEDDeviceIcons(uint8_t portIndex);
bool mInputEditorPopupOpen;
void DrawSetDefaultsButton(uint8_t portIndex);
void DrawClearAllButton(uint8_t portIndex);
void DrawHelpIcon(const std::string& helptext);
};
+1
View File
@@ -12,6 +12,7 @@
#include <vector>
#include <span>
#include <stdint.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <ImGui/imgui.h>
#include <libultraship/libultraship.h>
+15 -15
View File
@@ -150,14 +150,14 @@ file(GLOB_RECURSE soh__DeveloperTools RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# }}}
# soh/enhancements {{{
#file(GLOB_RECURSE soh__Enhancements RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# "soh/Enhancements/*.c"
# "soh/Enhancements/*.cpp"
# "soh/Enhancements/*.h"
# "soh/Enhancements/*.hpp"
# "soh/Enhancements/*_extern.inc"
# "soh/Enhancements/*.mm"
#)
file(GLOB_RECURSE soh__Enhancements RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"2s2h/Enhancements/*.c"
"2s2h/Enhancements/*.cpp"
"2s2h/Enhancements/*.h"
"2s2h/Enhancements/*.hpp"
"2s2h/Enhancements/*_extern.inc"
"2s2h/Enhancements/*.mm"
)
#list(REMOVE_ITEM soh__Enhancements "soh/Enhancements/gamecommand.h")
#list(FILTER soh__Enhancements EXCLUDE REGEX "soh/Enhancements/gfx.*")
@@ -180,7 +180,7 @@ file(GLOB_RECURSE soh__DeveloperTools RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
#source_group("soh\\Enhancements" REGULAR_EXPRESSION "soh/Enhancements/*")
#source_group("soh\\Enhancements\\audio" REGULAR_EXPRESSION "soh/Enhancements/audio/*")
#source_group("soh\\Enhancements\\controls" REGULAR_EXPRESSION "soh/Enhancements/controls/*")
source_group("2s2h\\Enhancements\\controls" REGULAR_EXPRESSION "2s2h/Enhancements/controls/*")
#source_group("soh\\Enhancements\\cosmetics" REGULAR_EXPRESSION "soh/Enhancements/cosmetics/*")
#source_group("soh\\Enhancements\\crowd-control" REGULAR_EXPRESSION "soh/Enhancements/crowd-control/*")
#source_group("soh\\Enhancements\\custom-message" REGULAR_EXPRESSION "soh/Enhancements/custom-message/*")
@@ -269,7 +269,7 @@ set(ALL_FILES
${libultra_headers}
${soh__DeveloperTools}
# ${soh__config}
# ${soh__Enhancements}
${soh__Enhancements}
${soh__Extractor}
${soh__Resource}
${src__}
@@ -426,9 +426,9 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"$<$<BOOL:${BUILD_CROWD_CONTROL}>:ENABLE_CROWD_CONTROL>"
# "$<$<BOOL:${BUILD_CROWD_CONTROL}>:ENABLE_CROWD_CONTROL>"
"INCLUDE_GAME_PRINTF;"
"ENABLE_CROWD_CONTROL;"
# "ENABLE_CROWD_CONTROL;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
@@ -475,7 +475,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"$<$<BOOL:${BUILD_CROWD_CONTROL}>:ENABLE_CROWD_CONTROL>"
# "$<$<BOOL:${BUILD_CROWD_CONTROL}>:ENABLE_CROWD_CONTROL>"
"SPDLOG_ACTIVE_LEVEL=0;"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
@@ -713,7 +713,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"glu32;"
"SDL2::SDL2;"
"SDL2::SDL2main;"
"$<$<BOOL:${BUILD_CROWD_CONTROL}>:SDL2_net::SDL2_net-static>"
# "$<$<BOOL:${BUILD_CROWD_CONTROL}>:SDL2_net::SDL2_net-static>"
"glfw;"
"winmm;"
"imm32;"
@@ -766,7 +766,7 @@ else()
"ZAPDUtils;"
"ZAPDLib;"
SDL2::SDL2
"$<$<BOOL:${BUILD_CROWD_CONTROL}>:SDL2_net::SDL2_net>"
# "$<$<BOOL:${BUILD_CROWD_CONTROL}>:SDL2_net::SDL2_net>"
${CMAKE_DL_LIBS}
Threads::Threads
)