diff --git a/.github/workflows/tidy-format-validation.yml b/.github/workflows/tidy-format-validation.yml index 5059d9c..9c1eb16 100644 --- a/.github/workflows/tidy-format-validation.yml +++ b/.github/workflows/tidy-format-validation.yml @@ -50,7 +50,7 @@ jobs: mkdir clang-tidy-result - name: Analyze run: | - git diff -U0 HEAD^ -- 'src' 'include' ':!include/color.h' ':!include/libultra/*' ':!src/public/libultra/*' ':!src/graphic/Fast3D/*' ':!src/log/spd' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml + git diff -U0 HEAD^ -- 'src' 'include' ':!include/libultraship/color.h' ':!include/libultraship/libultra/*' ':!src/libultraship/libultra/*' ':!src/fast/*' ':!src/ship/utils/AppleFolderManager.mm' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml - name: Save PR metadata run: | echo ${{ github.event.number }} > clang-tidy-result/pr-id.txt diff --git a/.gitignore b/.gitignore index 12318ab..de70266 100644 --- a/.gitignore +++ b/.gitignore @@ -358,7 +358,7 @@ cmake_install.cmake *.lib *.tlog *.recipe -src/install_config.h +src/ship/install_config.h # Removed jsonConfig and jsonConfigVersion extern/nlohmann-json/*_jsonConfig* *.pbxproj diff --git a/src/graphic/Fast3D/Fast3dWindow.h b/include/fast/Fast3dWindow.h similarity index 89% rename from src/graphic/Fast3D/Fast3dWindow.h rename to include/fast/Fast3dWindow.h index ae8151a..c9cb9c2 100644 --- a/src/graphic/Fast3D/Fast3dWindow.h +++ b/include/fast/Fast3dWindow.h @@ -1,10 +1,9 @@ #pragma once -#include "window/Window.h" -#include "window/gui/Gui.h" -#include "graphic/Fast3D/backends/gfx_window_manager_api.h" -#include "graphic/Fast3D/backends/gfx_rendering_api.h" -#include "public/bridge/gfxbridge.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/window/Window.h" +#include "ship/window/gui/Gui.h" +#include "fast/backends/gfx_window_manager_api.h" +#include "fast/backends/gfx_rendering_api.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" union Gfx; #include "interpreter.h" diff --git a/src/graphic/Fast3D/LICENSE.txt b/include/fast/LICENSE.txt similarity index 100% rename from src/graphic/Fast3D/LICENSE.txt rename to include/fast/LICENSE.txt diff --git a/src/graphic/Fast3D/README.md b/include/fast/README.md similarity index 100% rename from src/graphic/Fast3D/README.md rename to include/fast/README.md diff --git a/src/graphic/Fast3D/backends/gfx_direct3d11.h b/include/fast/backends/gfx_direct3d11.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_direct3d11.h rename to include/fast/backends/gfx_direct3d11.h diff --git a/src/graphic/Fast3D/backends/gfx_direct3d_common.h b/include/fast/backends/gfx_direct3d_common.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_direct3d_common.h rename to include/fast/backends/gfx_direct3d_common.h diff --git a/src/graphic/Fast3D/backends/gfx_dxgi.h b/include/fast/backends/gfx_dxgi.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_dxgi.h rename to include/fast/backends/gfx_dxgi.h diff --git a/src/graphic/Fast3D/backends/gfx_metal.h b/include/fast/backends/gfx_metal.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_metal.h rename to include/fast/backends/gfx_metal.h diff --git a/src/graphic/Fast3D/backends/gfx_metal_shader.h b/include/fast/backends/gfx_metal_shader.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_metal_shader.h rename to include/fast/backends/gfx_metal_shader.h diff --git a/src/graphic/Fast3D/backends/gfx_opengl.h b/include/fast/backends/gfx_opengl.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_opengl.h rename to include/fast/backends/gfx_opengl.h diff --git a/src/graphic/Fast3D/backends/gfx_rendering_api.h b/include/fast/backends/gfx_rendering_api.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_rendering_api.h rename to include/fast/backends/gfx_rendering_api.h diff --git a/src/graphic/Fast3D/backends/gfx_screen_config.h b/include/fast/backends/gfx_screen_config.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_screen_config.h rename to include/fast/backends/gfx_screen_config.h diff --git a/src/graphic/Fast3D/backends/gfx_sdl.h b/include/fast/backends/gfx_sdl.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_sdl.h rename to include/fast/backends/gfx_sdl.h diff --git a/src/graphic/Fast3D/backends/gfx_window_manager_api.h b/include/fast/backends/gfx_window_manager_api.h similarity index 100% rename from src/graphic/Fast3D/backends/gfx_window_manager_api.h rename to include/fast/backends/gfx_window_manager_api.h diff --git a/src/graphic/Fast3D/debug/GfxDebugger.h b/include/fast/debug/GfxDebugger.h similarity index 100% rename from src/graphic/Fast3D/debug/GfxDebugger.h rename to include/fast/debug/GfxDebugger.h diff --git a/src/graphic/Fast3D/f3dex.h b/include/fast/f3dex.h similarity index 100% rename from src/graphic/Fast3D/f3dex.h rename to include/fast/f3dex.h diff --git a/src/graphic/Fast3D/f3dex2.h b/include/fast/f3dex2.h similarity index 100% rename from src/graphic/Fast3D/f3dex2.h rename to include/fast/f3dex2.h diff --git a/src/graphic/Fast3D/interpreter.h b/include/fast/interpreter.h similarity index 99% rename from src/graphic/Fast3D/interpreter.h rename to include/fast/interpreter.h index 1bd2b18..2df3e4f 100644 --- a/src/graphic/Fast3D/interpreter.h +++ b/include/fast/interpreter.h @@ -10,13 +10,13 @@ #include #include -#include "graphic/Fast3D/lus_gbi.h" +#include "fast/lus_gbi.h" #include "libultraship/libultra/types.h" -#include "public/bridge/gfxbridge.h" +#include "fast/ucodehandlers.h" #include "backends/gfx_rendering_api.h" -#include "resource/type/Texture.h" -#include "resource/Resource.h" +#include "fast/resource/type/Texture.h" +#include "ship/resource/Resource.h" // TODO figure out why changing these to 640x480 makes the game only render in a quarter of the window #define SCREEN_WIDTH 320 diff --git a/src/graphic/Fast3D/lus_gbi.h b/include/fast/lus_gbi.h similarity index 100% rename from src/graphic/Fast3D/lus_gbi.h rename to include/fast/lus_gbi.h diff --git a/src/resource/ResourceType.h b/include/fast/resource/ResourceType.h similarity index 60% rename from src/resource/ResourceType.h rename to include/fast/resource/ResourceType.h index 6834376..a00fe30 100644 --- a/src/resource/ResourceType.h +++ b/include/fast/resource/ResourceType.h @@ -1,16 +1,5 @@ #pragma once -namespace Ship { - -enum class ResourceType { - None = 0x00000000, - - Blob = 0x4F424C42, // OBLB - Json = 0x4A534F4E, // JSON - Shader = 0x53484144, // SHAD -}; -} // namespace Ship - namespace Fast { enum class ResourceType { diff --git a/src/resource/factory/DisplayListFactory.h b/include/fast/resource/factory/DisplayListFactory.h similarity index 86% rename from src/resource/factory/DisplayListFactory.h rename to include/fast/resource/factory/DisplayListFactory.h index 3961d73..05afcb7 100644 --- a/src/resource/factory/DisplayListFactory.h +++ b/include/fast/resource/factory/DisplayListFactory.h @@ -1,8 +1,8 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" -#include "resource/ResourceFactoryXML.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" +#include "ship/resource/ResourceFactoryXML.h" namespace Fast { class ResourceFactoryDisplayList { diff --git a/src/resource/factory/LightFactory.h b/include/fast/resource/factory/LightFactory.h similarity index 79% rename from src/resource/factory/LightFactory.h rename to include/fast/resource/factory/LightFactory.h index 5ffbc44..acf699f 100644 --- a/src/resource/factory/LightFactory.h +++ b/include/fast/resource/factory/LightFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Fast { class ResourceFactoryBinaryLightV0 final : public Ship::ResourceFactoryBinary { diff --git a/src/resource/factory/MatrixFactory.h b/include/fast/resource/factory/MatrixFactory.h similarity index 80% rename from src/resource/factory/MatrixFactory.h rename to include/fast/resource/factory/MatrixFactory.h index ed51253..45425da 100644 --- a/src/resource/factory/MatrixFactory.h +++ b/include/fast/resource/factory/MatrixFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Fast { class ResourceFactoryBinaryMatrixV0 final : public Ship::ResourceFactoryBinary { diff --git a/src/resource/factory/TextureFactory.h b/include/fast/resource/factory/TextureFactory.h similarity index 88% rename from src/resource/factory/TextureFactory.h rename to include/fast/resource/factory/TextureFactory.h index 1e77a52..f561fda 100644 --- a/src/resource/factory/TextureFactory.h +++ b/include/fast/resource/factory/TextureFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Fast { class ResourceFactoryBinaryTextureV0 final : public Ship::ResourceFactoryBinary { diff --git a/src/resource/factory/VertexFactory.h b/include/fast/resource/factory/VertexFactory.h similarity index 82% rename from src/resource/factory/VertexFactory.h rename to include/fast/resource/factory/VertexFactory.h index 0852162..6333dbf 100644 --- a/src/resource/factory/VertexFactory.h +++ b/include/fast/resource/factory/VertexFactory.h @@ -1,8 +1,8 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" -#include "resource/ResourceFactoryXML.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" +#include "ship/resource/ResourceFactoryXML.h" namespace Fast { class ResourceFactoryBinaryVertexV0 final : public Ship::ResourceFactoryBinary { diff --git a/src/resource/type/DisplayList.h b/include/fast/resource/type/DisplayList.h similarity index 85% rename from src/resource/type/DisplayList.h rename to include/fast/resource/type/DisplayList.h index e8e3dcb..b356534 100644 --- a/src/resource/type/DisplayList.h +++ b/include/fast/resource/type/DisplayList.h @@ -1,8 +1,8 @@ #pragma once #include -#include "resource/Resource.h" -#include "public/bridge/gfxbridge.h" +#include "ship/resource/Resource.h" +#include "fast/ucodehandlers.h" #include namespace Fast { diff --git a/src/resource/type/Light.h b/include/fast/resource/type/Light.h similarity index 97% rename from src/resource/type/Light.h rename to include/fast/resource/type/Light.h index 914adb9..1205258 100644 --- a/src/resource/type/Light.h +++ b/include/fast/resource/type/Light.h @@ -1,7 +1,7 @@ #pragma once #include -#include "resource/Resource.h" +#include "ship/resource/Resource.h" namespace Fast { diff --git a/src/resource/type/Matrix.h b/include/fast/resource/type/Matrix.h similarity index 88% rename from src/resource/type/Matrix.h rename to include/fast/resource/type/Matrix.h index 2074abc..c4b9371 100644 --- a/src/resource/type/Matrix.h +++ b/include/fast/resource/type/Matrix.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" #include "libultraship/libultra/types.h" namespace Fast { diff --git a/src/resource/type/Texture.h b/include/fast/resource/type/Texture.h similarity index 95% rename from src/resource/type/Texture.h rename to include/fast/resource/type/Texture.h index 7625049..c0fd710 100644 --- a/src/resource/type/Texture.h +++ b/include/fast/resource/type/Texture.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" #define TEX_FLAG_LOAD_AS_RAW (1 << 0) #define TEX_FLAG_LOAD_AS_IMG (1 << 1) diff --git a/src/resource/type/Vertex.h b/include/fast/resource/type/Vertex.h similarity index 89% rename from src/resource/type/Vertex.h rename to include/fast/resource/type/Vertex.h index cd78667..3fec39a 100644 --- a/src/resource/type/Vertex.h +++ b/include/fast/resource/type/Vertex.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" #include union Vtx; diff --git a/include/fast/ucodehandlers.h b/include/fast/ucodehandlers.h new file mode 100644 index 0000000..330375e --- /dev/null +++ b/include/fast/ucodehandlers.h @@ -0,0 +1,11 @@ +#pragma once + +typedef enum UcodeHandlers { + ucode_f3db, + ucode_f3d, + ucode_f3dex, + ucode_f3dexb, + ucode_f3dex2, + ucode_s2dex, + ucode_max, +} UcodeHandlers; diff --git a/include/libultraship/bridge.h b/include/libultraship/bridge.h index 8a519ca..e19b6cc 100644 --- a/include/libultraship/bridge.h +++ b/include/libultraship/bridge.h @@ -1,10 +1,10 @@ #pragma once -#include "public/bridge/resourcebridge.h" -#include "public/bridge/audiobridge.h" -#include "public/bridge/controllerbridge.h" -#include "public/bridge/windowbridge.h" -#include "public/bridge/consolevariablebridge.h" -#include "public/bridge/crashhandlerbridge.h" -#include "public/bridge/gfxdebuggerbridge.h" -#include "public/bridge/gfxbridge.h" +#include "libultraship/bridge/resourcebridge.h" +#include "libultraship/bridge/audiobridge.h" +#include "libultraship/bridge/controllerbridge.h" +#include "libultraship/bridge/windowbridge.h" +#include "libultraship/bridge/consolevariablebridge.h" +#include "libultraship/bridge/crashhandlerbridge.h" +#include "libultraship/bridge/gfxdebuggerbridge.h" +#include "libultraship/bridge/gfxbridge.h" diff --git a/src/public/bridge/audiobridge.h b/include/libultraship/bridge/audiobridge.h similarity index 76% rename from src/public/bridge/audiobridge.h rename to include/libultraship/bridge/audiobridge.h index 5930cb5..93fca70 100644 --- a/src/public/bridge/audiobridge.h +++ b/include/libultraship/bridge/audiobridge.h @@ -2,8 +2,7 @@ #include "stdint.h" #include "stddef.h" - -typedef enum AudioChannelsSetting { audioStereo, audioSurround51, audioMax } AudioChannelsSetting; +#include "ship/audio/AudioChannelsSetting.h" #ifdef __cplusplus extern "C" { diff --git a/src/public/bridge/consolevariablebridge.h b/include/libultraship/bridge/consolevariablebridge.h similarity index 97% rename from src/public/bridge/consolevariablebridge.h rename to include/libultraship/bridge/consolevariablebridge.h index 2915266..32400b4 100644 --- a/src/public/bridge/consolevariablebridge.h +++ b/include/libultraship/bridge/consolevariablebridge.h @@ -5,7 +5,7 @@ #ifdef __cplusplus #include -#include +#include "ship/config/ConsoleVariable.h" std::shared_ptr CVarGet(const char* name); extern "C" { diff --git a/src/public/bridge/controllerbridge.h b/include/libultraship/bridge/controllerbridge.h similarity index 100% rename from src/public/bridge/controllerbridge.h rename to include/libultraship/bridge/controllerbridge.h diff --git a/src/public/bridge/crashhandlerbridge.h b/include/libultraship/bridge/crashhandlerbridge.h similarity index 100% rename from src/public/bridge/crashhandlerbridge.h rename to include/libultraship/bridge/crashhandlerbridge.h diff --git a/src/public/bridge/gfxbridge.h b/include/libultraship/bridge/gfxbridge.h similarity index 57% rename from src/public/bridge/gfxbridge.h rename to include/libultraship/bridge/gfxbridge.h index 0ae5f18..4a87b71 100644 --- a/src/public/bridge/gfxbridge.h +++ b/include/libultraship/bridge/gfxbridge.h @@ -1,16 +1,7 @@ #pragma once #include "stdint.h" - -typedef enum UcodeHandlers { - ucode_f3db, - ucode_f3d, - ucode_f3dex, - ucode_f3dexb, - ucode_f3dex2, - ucode_s2dex, - ucode_max, -} UcodeHandlers; +#include "fast/ucodehandlers.h" #ifdef __cplusplus extern "C" { diff --git a/src/public/bridge/gfxdebuggerbridge.h b/include/libultraship/bridge/gfxdebuggerbridge.h similarity index 100% rename from src/public/bridge/gfxdebuggerbridge.h rename to include/libultraship/bridge/gfxdebuggerbridge.h diff --git a/src/public/bridge/resourcebridge.h b/include/libultraship/bridge/resourcebridge.h similarity index 95% rename from src/public/bridge/resourcebridge.h rename to include/libultraship/bridge/resourcebridge.h index 6a6e42a..161dec6 100644 --- a/src/public/bridge/resourcebridge.h +++ b/include/libultraship/bridge/resourcebridge.h @@ -3,8 +3,8 @@ #include "stdint.h" #ifdef __cplusplus -#include "resource/type/Texture.h" -#include "resource/Resource.h" +#include "fast/resource/type/Texture.h" +#include "ship/resource/Resource.h" #include std::shared_ptr ResourceLoad(const char* name); diff --git a/src/public/bridge/windowbridge.h b/include/libultraship/bridge/windowbridge.h similarity index 100% rename from src/public/bridge/windowbridge.h rename to include/libultraship/bridge/windowbridge.h diff --git a/include/libultraship/classes.h b/include/libultraship/classes.h index 499cc84..ab2183c 100644 --- a/include/libultraship/classes.h +++ b/include/libultraship/classes.h @@ -1,38 +1,38 @@ #pragma once #ifdef __cplusplus -#include "resource/archive/ArchiveManager.h" -#include "resource/archive/Archive.h" -#include "resource/archive/OtrArchive.h" -#include "resource/archive/O2rArchive.h" -#include "resource/ResourceManager.h" -#include "Context.h" -#include "window/Window.h" -#include "debug/Console.h" -#include "debug/CrashHandler.h" -#include "config/ConsoleVariable.h" -#include "config/Config.h" -#include "window/gui/ConsoleWindow.h" -#include "window/gui/GameOverlay.h" -#include "window/gui/Gui.h" -#include "window/gui/GuiMenuBar.h" -#include "window/gui/GuiElement.h" -#include "window/gui/GuiWindow.h" -#include "window/gui/InputEditorWindow.h" -#include "window/gui/StatsWindow.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" -#include "controller/controldevice/controller/Controller.h" -#include "controller/controldeck/ControlDeck.h" -#include "utils/binarytools/BinaryReader.h" -#include "utils/binarytools/MemoryStream.h" -#include "utils/binarytools/BinaryWriter.h" -#include "audio/Audio.h" -#include "audio/AudioPlayer.h" +#include "ship/resource/archive/ArchiveManager.h" +#include "ship/resource/archive/Archive.h" +#include "ship/resource/archive/OtrArchive.h" +#include "ship/resource/archive/O2rArchive.h" +#include "ship/resource/ResourceManager.h" +#include "ship/Context.h" +#include "ship/window/Window.h" +#include "ship/debug/Console.h" +#include "ship/debug/CrashHandler.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/config/Config.h" +#include "ship/window/gui/ConsoleWindow.h" +#include "ship/window/gui/GameOverlay.h" +#include "ship/window/gui/Gui.h" +#include "ship/window/gui/GuiMenuBar.h" +#include "ship/window/gui/GuiElement.h" +#include "ship/window/gui/GuiWindow.h" +#include "ship/window/gui/InputEditorWindow.h" +#include "ship/window/gui/StatsWindow.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/Controller.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/utils/binarytools/BinaryReader.h" +#include "ship/utils/binarytools/MemoryStream.h" +#include "ship/utils/binarytools/BinaryWriter.h" +#include "ship/audio/Audio.h" +#include "ship/audio/AudioPlayer.h" #if defined(_WIN32) -#include "audio/WasapiAudioPlayer.h" +#include "ship/audio/WasapiAudioPlayer.h" #endif -#include "audio/SDLAudioPlayer.h" +#include "ship/audio/SDLAudioPlayer.h" #ifdef __APPLE__ -#include "utils/AppleFolderManager.h" +#include "ship/utils/AppleFolderManager.h" #endif #endif diff --git a/include/libultraship/controller/controldeck/ControlDeck.h b/include/libultraship/controller/controldeck/ControlDeck.h new file mode 100644 index 0000000..ea670a9 --- /dev/null +++ b/include/libultraship/controller/controldeck/ControlDeck.h @@ -0,0 +1,28 @@ +#pragma once + +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/controller/controldeck/ControlPort.h" +#include +#include "ship/config/Config.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.h" +#include "ship/controller/physicaldevice/GlobalSDLDeviceSettings.h" +#include "ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h" + +namespace LUS { +class ControlDeck final : public Ship::ControlDeck { + public: + ControlDeck(); + ControlDeck(std::vector additionalBitmasks); + ControlDeck(std::vector additionalBitmasks, + std::shared_ptr controllerDefaultMappings); + + OSContPad* GetPads(); + void WriteToPad(void* pad) override; + + private: + void WriteToOSContPad(OSContPad* pad); + + OSContPad* mPads; +}; +} // namespace LUS diff --git a/include/libultraship/controller/controldevice/controller/Controller.h b/include/libultraship/controller/controldevice/controller/Controller.h new file mode 100644 index 0000000..19149f9 --- /dev/null +++ b/include/libultraship/controller/controldevice/controller/Controller.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "libultraship/libultra/controller.h" +#include "libultraship/color.h" +#include +#include "ship/controller/controldevice/controller/Controller.h" + +namespace LUS { +class Controller : public Ship::Controller { + public: + Controller(uint8_t portIndex); + Controller(uint8_t portIndex, std::vector additionalBitmasks); + + void ReadToPad(void* pad) override; + + private: + void ReadToOSContPad(OSContPad* pad); + + std::deque mPadBuffer; +}; +} // namespace LUS diff --git a/src/log/luslog.h b/include/libultraship/log/luslog.h similarity index 100% rename from src/log/luslog.h rename to include/libultraship/log/luslog.h diff --git a/src/window/gui/GfxDebuggerWindow.h b/include/libultraship/window/gui/GfxDebuggerWindow.h similarity index 94% rename from src/window/gui/GfxDebuggerWindow.h rename to include/libultraship/window/gui/GfxDebuggerWindow.h index 6f4ab84..43666e2 100644 --- a/src/window/gui/GfxDebuggerWindow.h +++ b/include/libultraship/window/gui/GfxDebuggerWindow.h @@ -1,6 +1,6 @@ #pragma once -#include "window/gui/GuiWindow.h" +#include "ship/window/gui/GuiWindow.h" #include #include diff --git a/src/Context.h b/include/ship/Context.h similarity index 99% rename from src/Context.h rename to include/ship/Context.h index 80a2765..7c9ef45 100644 --- a/src/Context.h +++ b/include/ship/Context.h @@ -5,7 +5,7 @@ #include #include #include -#include "audio/Audio.h" +#include "ship/audio/Audio.h" namespace spdlog { class logger; diff --git a/src/audio/Audio.h b/include/ship/audio/Audio.h similarity index 95% rename from src/audio/Audio.h rename to include/ship/audio/Audio.h index f82d377..3190664 100644 --- a/src/audio/Audio.h +++ b/include/ship/audio/Audio.h @@ -3,7 +3,7 @@ #include #include #include -#include "audio/AudioPlayer.h" +#include "ship/audio/AudioPlayer.h" namespace Ship { enum class AudioBackend { WASAPI, SDL, NUL }; diff --git a/include/ship/audio/AudioChannelsSetting.h b/include/ship/audio/AudioChannelsSetting.h new file mode 100644 index 0000000..853a699 --- /dev/null +++ b/include/ship/audio/AudioChannelsSetting.h @@ -0,0 +1,3 @@ +#pragma once + +typedef enum AudioChannelsSetting { audioStereo, audioSurround51, audioMax } AudioChannelsSetting; diff --git a/src/audio/AudioPlayer.h b/include/ship/audio/AudioPlayer.h similarity index 96% rename from src/audio/AudioPlayer.h rename to include/ship/audio/AudioPlayer.h index e6f627d..1d8b1c4 100644 --- a/src/audio/AudioPlayer.h +++ b/include/ship/audio/AudioPlayer.h @@ -2,7 +2,7 @@ #include "stdint.h" #include "stddef.h" #include -#include "public/bridge/audiobridge.h" +#include "ship/audio/AudioChannelsSetting.h" namespace Ship { diff --git a/src/audio/NullAudioPlayer.h b/include/ship/audio/NullAudioPlayer.h similarity index 100% rename from src/audio/NullAudioPlayer.h rename to include/ship/audio/NullAudioPlayer.h diff --git a/src/audio/SDLAudioPlayer.h b/include/ship/audio/SDLAudioPlayer.h similarity index 100% rename from src/audio/SDLAudioPlayer.h rename to include/ship/audio/SDLAudioPlayer.h diff --git a/src/audio/WasapiAudioPlayer.h b/include/ship/audio/WasapiAudioPlayer.h similarity index 100% rename from src/audio/WasapiAudioPlayer.h rename to include/ship/audio/WasapiAudioPlayer.h diff --git a/src/config/Config.h b/include/ship/config/Config.h similarity index 98% rename from src/config/Config.h rename to include/ship/config/Config.h index 8275550..104f0c9 100644 --- a/src/config/Config.h +++ b/include/ship/config/Config.h @@ -4,8 +4,8 @@ #include #include -#include "audio/Audio.h" -#include "window/Window.h" +#include "ship/audio/Audio.h" +#include "ship/window/Window.h" namespace Ship { diff --git a/src/config/ConsoleVariable.h b/include/ship/config/ConsoleVariable.h similarity index 100% rename from src/config/ConsoleVariable.h rename to include/ship/config/ConsoleVariable.h diff --git a/src/controller/controldeck/ControlDeck.h b/include/ship/controller/controldeck/ControlDeck.h similarity index 64% rename from src/controller/controldeck/ControlDeck.h rename to include/ship/controller/controldeck/ControlDeck.h index ea14d76..adda786 100644 --- a/src/controller/controldeck/ControlDeck.h +++ b/include/ship/controller/controldeck/ControlDeck.h @@ -2,11 +2,11 @@ #include "ControlPort.h" #include -#include -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" -#include "controller/physicaldevice/ConnectedPhysicalDeviceManager.h" -#include "controller/physicaldevice/GlobalSDLDeviceSettings.h" -#include "controller/controldevice/controller/mapping/ControllerDefaultMappings.h" +#include "ship/config/Config.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.h" +#include "ship/controller/physicaldevice/GlobalSDLDeviceSettings.h" +#include "ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h" namespace Ship { @@ -44,21 +44,3 @@ class ControlDeck { std::shared_ptr mControllerDefaultMappings; }; } // namespace Ship - -namespace LUS { -class ControlDeck final : public Ship::ControlDeck { - public: - ControlDeck(); - ControlDeck(std::vector additionalBitmasks); - ControlDeck(std::vector additionalBitmasks, - std::shared_ptr controllerDefaultMappings); - - OSContPad* GetPads(); - void WriteToPad(void* pad) override; - - private: - void WriteToOSContPad(OSContPad* pad); - - OSContPad* mPads; -}; -} // namespace LUS diff --git a/src/controller/controldeck/ControlPort.h b/include/ship/controller/controldeck/ControlPort.h similarity index 80% rename from src/controller/controldeck/ControlPort.h rename to include/ship/controller/controldeck/ControlPort.h index 903ccce..620e727 100644 --- a/src/controller/controldeck/ControlPort.h +++ b/include/ship/controller/controldeck/ControlPort.h @@ -1,7 +1,7 @@ #pragma once -#include "controller/controldevice/ControlDevice.h" -#include "controller/controldevice/controller/Controller.h" +#include "ship/controller/controldevice/ControlDevice.h" +#include "ship/controller/controldevice/controller/Controller.h" #include namespace Ship { diff --git a/src/controller/controldevice/ControlDevice.h b/include/ship/controller/controldevice/ControlDevice.h similarity index 100% rename from src/controller/controldevice/ControlDevice.h rename to include/ship/controller/controldevice/ControlDevice.h diff --git a/src/controller/controldevice/controller/Controller.h b/include/ship/controller/controldevice/controller/Controller.h similarity index 81% rename from src/controller/controldevice/controller/Controller.h rename to include/ship/controller/controldevice/controller/Controller.h index 3c59da4..2691860 100644 --- a/src/controller/controldevice/controller/Controller.h +++ b/include/ship/controller/controldevice/controller/Controller.h @@ -15,8 +15,8 @@ #include "ControllerGyro.h" #include "ControllerRumble.h" #include "ControllerLED.h" -#include "controller/controldevice/ControlDevice.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/ControlDevice.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { @@ -66,18 +66,3 @@ class Controller : public ControlDevice { std::shared_ptr mLED; }; } // namespace Ship - -namespace LUS { -class Controller : public Ship::Controller { - public: - Controller(uint8_t portIndex); - Controller(uint8_t portIndex, std::vector additionalBitmasks); - - void ReadToPad(void* pad) override; - - private: - void ReadToOSContPad(OSContPad* pad); - - std::deque mPadBuffer; -}; -} // namespace LUS diff --git a/src/controller/controldevice/controller/ControllerButton.h b/include/ship/controller/controldevice/controller/ControllerButton.h similarity index 95% rename from src/controller/controldevice/controller/ControllerButton.h rename to include/ship/controller/controldevice/controller/ControllerButton.h index 70e0aa8..1a1b38f 100644 --- a/src/controller/controldevice/controller/ControllerButton.h +++ b/include/ship/controller/controldevice/controller/ControllerButton.h @@ -5,7 +5,7 @@ #include #include #include "libultraship/libultra/controller.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { diff --git a/src/controller/controldevice/controller/ControllerGyro.h b/include/ship/controller/controldevice/controller/ControllerGyro.h similarity index 89% rename from src/controller/controldevice/controller/ControllerGyro.h rename to include/ship/controller/controldevice/controller/ControllerGyro.h index 90696b1..c0501ba 100644 --- a/src/controller/controldevice/controller/ControllerGyro.h +++ b/include/ship/controller/controldevice/controller/ControllerGyro.h @@ -3,7 +3,7 @@ #include #include -#include "controller/controldevice/controller/mapping/ControllerGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h" namespace Ship { class ControllerGyro { diff --git a/src/controller/controldevice/controller/ControllerLED.h b/include/ship/controller/controldevice/controller/ControllerLED.h similarity index 92% rename from src/controller/controldevice/controller/ControllerLED.h rename to include/ship/controller/controldevice/controller/ControllerLED.h index 338251d..b6d2914 100644 --- a/src/controller/controldevice/controller/ControllerLED.h +++ b/include/ship/controller/controldevice/controller/ControllerLED.h @@ -5,7 +5,7 @@ #include #include -#include "controller/controldevice/controller/mapping/ControllerLEDMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h" namespace Ship { class ControllerLED { diff --git a/src/controller/controldevice/controller/ControllerRumble.h b/include/ship/controller/controldevice/controller/ControllerRumble.h similarity index 92% rename from src/controller/controldevice/controller/ControllerRumble.h rename to include/ship/controller/controldevice/controller/ControllerRumble.h index ff4da2f..c9b1055 100644 --- a/src/controller/controldevice/controller/ControllerRumble.h +++ b/include/ship/controller/controldevice/controller/ControllerRumble.h @@ -5,7 +5,7 @@ #include #include -#include "controller/controldevice/controller/mapping/ControllerRumbleMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h" namespace Ship { class ControllerRumble { diff --git a/src/controller/controldevice/controller/ControllerStick.h b/include/ship/controller/controldevice/controller/ControllerStick.h similarity index 94% rename from src/controller/controldevice/controller/ControllerStick.h rename to include/ship/controller/controldevice/controller/ControllerStick.h index f673af9..9a57ccd 100644 --- a/src/controller/controldevice/controller/ControllerStick.h +++ b/include/ship/controller/controldevice/controller/ControllerStick.h @@ -1,10 +1,10 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include #include #include -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h diff --git a/src/controller/controldevice/controller/mapping/ControllerButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h diff --git a/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.h b/include/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h similarity index 97% rename from src/controller/controldevice/controller/mapping/ControllerDefaultMappings.h rename to include/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h index 4b0623d..56797a7 100644 --- a/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.h +++ b/include/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h @@ -11,7 +11,7 @@ #define CONTROLLERBUTTONS_T uint16_t #endif -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/ControllerGyroMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerGyroMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h diff --git a/src/controller/controldevice/controller/mapping/ControllerInputMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerInputMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerInputMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerInputMapping.h diff --git a/src/controller/controldevice/controller/mapping/ControllerLEDMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerLEDMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h diff --git a/src/controller/controldevice/controller/mapping/ControllerMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerMapping.h similarity index 88% rename from src/controller/controldevice/controller/mapping/ControllerMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerMapping.h index 9062247..9aa0ed4 100644 --- a/src/controller/controldevice/controller/mapping/ControllerMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/ControllerMapping.h @@ -1,7 +1,7 @@ #pragma once #include -#include "controller/physicaldevice/PhysicalDeviceType.h" +#include "ship/controller/physicaldevice/PhysicalDeviceType.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/ControllerRumbleMapping.h b/include/ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/ControllerRumbleMapping.h rename to include/ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h diff --git a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h b/include/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h similarity index 91% rename from src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h rename to include/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h index 212f0ff..9bea99a 100644 --- a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h +++ b/include/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include #include #include diff --git a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h b/include/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h similarity index 92% rename from src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h rename to include/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h index a533e78..ea5d220 100644 --- a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h +++ b/include/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" #include #include #include diff --git a/src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h b/include/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h similarity index 80% rename from src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h rename to include/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h index 97a0fb3..5a2fbd6 100644 --- a/src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h +++ b/include/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h" #include #include diff --git a/src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h b/include/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h similarity index 81% rename from src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h rename to include/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h index b129c2e..a587e86 100644 --- a/src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h +++ b/include/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerLEDMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h" #include #include #include diff --git a/src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h b/include/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h similarity index 86% rename from src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h rename to include/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h index e81ba5f..f2ded89 100644 --- a/src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h +++ b/include/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerRumbleMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h" #include #include #include diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h similarity index 85% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h rename to include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h index f7f5b7d..e3ccb46 100644 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h @@ -1,6 +1,6 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" #include "KeyboardScancodes.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h similarity index 88% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h index 2f410d8..ddb06ae 100644 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include "KeyboardKeyToAnyMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h similarity index 87% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h index 6b6521b..04bb085 100644 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" #include "KeyboardKeyToAnyMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h b/include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h similarity index 100% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h rename to include/ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h similarity index 71% rename from src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h index 35c13b2..95394f2 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h @@ -1,7 +1,7 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerInputMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseButtonToAnyMapping : virtual public ControllerInputMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h similarity index 78% rename from src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h index 85c1963..ebeb0b6 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h @@ -1,8 +1,8 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include "MouseButtonToAnyMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseButtonToAxisDirectionMapping final : public MouseButtonToAnyMapping, public ControllerAxisDirectionMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h similarity index 78% rename from src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h index d80b1ec..cae84b6 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h @@ -1,8 +1,8 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" #include "MouseButtonToAnyMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseButtonToButtonMapping final : public MouseButtonToAnyMapping, public ControllerButtonMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h similarity index 68% rename from src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h index f058515..deabf2f 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h @@ -1,7 +1,7 @@ #pragma once -#include "controller/controldevice/controller/mapping/ControllerInputMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseWheelToAnyMapping : virtual public ControllerInputMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h similarity index 79% rename from src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h index 71c362f..c96d6d3 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h @@ -1,8 +1,8 @@ #pragma once #include "MouseWheelToAnyMapping.h" -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseWheelToAxisDirectionMapping final : public MouseWheelToAnyMapping, public ControllerAxisDirectionMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h similarity index 69% rename from src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h index e6b3b92..6d26598 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h @@ -1,8 +1,8 @@ #pragma once -#include "MouseWheelToAnyMapping.h" -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { class MouseWheelToButtonMapping final : public MouseWheelToAnyMapping, public ControllerButtonMapping { diff --git a/src/controller/controldevice/controller/mapping/mouse/WheelHandler.h b/include/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h similarity index 86% rename from src/controller/controldevice/controller/mapping/mouse/WheelHandler.h rename to include/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h index 4599a73..3fd40b6 100644 --- a/src/controller/controldevice/controller/mapping/mouse/WheelHandler.h +++ b/include/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h @@ -2,8 +2,8 @@ #include -#include "window/Window.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/window/Window.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { struct WheelDirections { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h similarity index 75% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h index 3ff4e3d..373b10c 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h @@ -1,7 +1,7 @@ #pragma once -#include "SDLMapping.h" -#include "controller/controldevice/controller/mapping/ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" namespace Ship { class SDLAxisDirectionToAnyMapping : virtual public ControllerInputMapping { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h similarity index 89% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h index 3057ffd..89dd9fa 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include "SDLAxisDirectionToAnyMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h similarity index 78% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h index a5e85ce..361dc3e 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h @@ -1,5 +1,5 @@ -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" -#include "SDLAxisDirectionToAnyMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h" namespace Ship { class SDLAxisDirectionToButtonMapping final : public ControllerButtonMapping, public SDLAxisDirectionToAnyMapping { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h similarity index 73% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h index 093c03d..fb42c2f 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h @@ -1,7 +1,7 @@ #pragma once -#include "SDLMapping.h" -#include "controller/controldevice/controller/mapping/ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" namespace Ship { class SDLButtonToAnyMapping : virtual public ControllerInputMapping { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h similarity index 88% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h index aeb0e44..a033b5a 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include "SDLButtonToAnyMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h similarity index 76% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h index 6df1cad..3f8a7b3 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h @@ -1,5 +1,5 @@ -#include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" -#include "SDLButtonToAnyMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h" namespace Ship { class SDLButtonToButtonMapping final : public SDLButtonToAnyMapping, public ControllerButtonMapping { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h similarity index 87% rename from src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h index 15ca176..75ec491 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h" #include "SDLMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h similarity index 83% rename from src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h index d11a7cc..6718b2e 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerLEDMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h" #include "SDLMapping.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLMapping.h similarity index 100% rename from src/controller/controldevice/controller/mapping/sdl/SDLMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLMapping.h diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h b/include/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h similarity index 89% rename from src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h rename to include/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h index 4d7f2ff..9d1e44f 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h +++ b/include/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h @@ -1,4 +1,4 @@ -#include "controller/controldevice/controller/mapping/ControllerRumbleMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h" #include "SDLMapping.h" namespace Ship { diff --git a/src/controller/physicaldevice/ConnectedPhysicalDeviceManager.h b/include/ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.h similarity index 100% rename from src/controller/physicaldevice/ConnectedPhysicalDeviceManager.h rename to include/ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.h diff --git a/src/controller/physicaldevice/GlobalSDLDeviceSettings.h b/include/ship/controller/physicaldevice/GlobalSDLDeviceSettings.h similarity index 100% rename from src/controller/physicaldevice/GlobalSDLDeviceSettings.h rename to include/ship/controller/physicaldevice/GlobalSDLDeviceSettings.h diff --git a/src/controller/physicaldevice/PhysicalDeviceType.h b/include/ship/controller/physicaldevice/PhysicalDeviceType.h similarity index 100% rename from src/controller/physicaldevice/PhysicalDeviceType.h rename to include/ship/controller/physicaldevice/PhysicalDeviceType.h diff --git a/src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h b/include/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h similarity index 89% rename from src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h rename to include/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h index 1b403d7..63c3afa 100644 --- a/src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h +++ b/include/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h @@ -1,6 +1,6 @@ #pragma once -#include "window/gui/GuiWindow.h" +#include "ship/window/gui/GuiWindow.h" namespace Ship { diff --git a/src/debug/Console.h b/include/ship/debug/Console.h similarity index 100% rename from src/debug/Console.h rename to include/ship/debug/Console.h diff --git a/src/debug/CrashHandler.h b/include/ship/debug/CrashHandler.h similarity index 100% rename from src/debug/CrashHandler.h rename to include/ship/debug/CrashHandler.h diff --git a/src/port/mobile/MobileImpl.h b/include/ship/port/mobile/MobileImpl.h similarity index 100% rename from src/port/mobile/MobileImpl.h rename to include/ship/port/mobile/MobileImpl.h diff --git a/src/resource/File.h b/include/ship/resource/File.h similarity index 88% rename from src/resource/File.h rename to include/ship/resource/File.h index 01b83d6..14d4e37 100644 --- a/src/resource/File.h +++ b/include/ship/resource/File.h @@ -5,8 +5,8 @@ #include #include #include -#include "resource/ResourceType.h" -#include "utils/binarytools/BinaryReader.h" +#include "ship/resource/ResourceType.h" +#include "ship/utils/binarytools/BinaryReader.h" namespace tinyxml2 { class XMLDocument; diff --git a/src/resource/Resource.h b/include/ship/resource/Resource.h similarity index 95% rename from src/resource/Resource.h rename to include/ship/resource/Resource.h index 7659f71..e30a1b5 100644 --- a/src/resource/Resource.h +++ b/include/ship/resource/Resource.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/File.h" +#include "ship/resource/File.h" namespace Ship { class ResourceManager; diff --git a/src/resource/ResourceFactory.h b/include/ship/resource/ResourceFactory.h similarity index 93% rename from src/resource/ResourceFactory.h rename to include/ship/resource/ResourceFactory.h index 256b916..9806776 100644 --- a/src/resource/ResourceFactory.h +++ b/include/ship/resource/ResourceFactory.h @@ -2,7 +2,7 @@ #include #include "File.h" -#include "Resource.h" +#include namespace Ship { class ResourceFactory { diff --git a/src/resource/ResourceFactoryBinary.h b/include/ship/resource/ResourceFactoryBinary.h similarity index 86% rename from src/resource/ResourceFactoryBinary.h rename to include/ship/resource/ResourceFactoryBinary.h index ea02194..e035f9c 100644 --- a/src/resource/ResourceFactoryBinary.h +++ b/include/ship/resource/ResourceFactoryBinary.h @@ -1,6 +1,6 @@ #pragma once -#include "ResourceFactory.h" +#include namespace Ship { class ResourceFactoryBinary : public ResourceFactory { diff --git a/src/resource/ResourceFactoryXML.h b/include/ship/resource/ResourceFactoryXML.h similarity index 86% rename from src/resource/ResourceFactoryXML.h rename to include/ship/resource/ResourceFactoryXML.h index 12f0232..1dc1b26 100644 --- a/src/resource/ResourceFactoryXML.h +++ b/include/ship/resource/ResourceFactoryXML.h @@ -1,6 +1,6 @@ #pragma once -#include "ResourceFactory.h" +#include namespace Ship { class ResourceFactoryXML : public ResourceFactory { diff --git a/src/resource/ResourceLoader.h b/include/ship/resource/ResourceLoader.h similarity index 97% rename from src/resource/ResourceLoader.h rename to include/ship/resource/ResourceLoader.h index 2c998d4..6fd5342 100644 --- a/src/resource/ResourceLoader.h +++ b/include/ship/resource/ResourceLoader.h @@ -3,8 +3,8 @@ #include #include #include "ResourceType.h" -#include "ResourceFactory.h" -#include "Resource.h" +#include +#include namespace Ship { struct File; diff --git a/src/resource/ResourceManager.h b/include/ship/resource/ResourceManager.h similarity index 97% rename from src/resource/ResourceManager.h rename to include/ship/resource/ResourceManager.h index 064478a..cca57eb 100644 --- a/src/resource/ResourceManager.h +++ b/include/ship/resource/ResourceManager.h @@ -8,10 +8,10 @@ #include #include #include -#include "resource/Resource.h" -#include "resource/ResourceLoader.h" -#include "resource/archive/Archive.h" -#include "resource/archive/ArchiveManager.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceLoader.h" +#include "ship/resource/archive/Archive.h" +#include "ship/resource/archive/ArchiveManager.h" #define BS_THREAD_POOL_ENABLE_PRIORITY #define BS_THREAD_POOL_ENABLE_PAUSE diff --git a/include/ship/resource/ResourceType.h b/include/ship/resource/ResourceType.h new file mode 100644 index 0000000..865cbc0 --- /dev/null +++ b/include/ship/resource/ResourceType.h @@ -0,0 +1,12 @@ +#pragma once + +namespace Ship { + +enum class ResourceType { + None = 0x00000000, + + Blob = 0x4F424C42, // OBLB + Json = 0x4A534F4E, // JSON + Shader = 0x53484144, // SHAD +}; +} // namespace Ship diff --git a/src/resource/archive/Archive.h b/include/ship/resource/archive/Archive.h similarity index 96% rename from src/resource/archive/Archive.h rename to include/ship/resource/archive/Archive.h index e2e35ac..4d760b7 100644 --- a/src/resource/archive/Archive.h +++ b/include/ship/resource/archive/Archive.h @@ -4,7 +4,7 @@ #include #include #include -#include "utils/binarytools/BinaryReader.h" +#include "ship/utils/binarytools/BinaryReader.h" namespace tinyxml2 { class XMLDocument; diff --git a/src/resource/archive/ArchiveManager.h b/include/ship/resource/archive/ArchiveManager.h similarity index 98% rename from src/resource/archive/ArchiveManager.h rename to include/ship/resource/archive/ArchiveManager.h index cb8a140..f6e8234 100644 --- a/src/resource/archive/ArchiveManager.h +++ b/include/ship/resource/archive/ArchiveManager.h @@ -7,7 +7,7 @@ #include #include #include -#include "resource/File.h" +#include "ship/resource/File.h" namespace Ship { struct File; diff --git a/src/resource/archive/FolderArchive.h b/include/ship/resource/archive/FolderArchive.h similarity index 86% rename from src/resource/archive/FolderArchive.h rename to include/ship/resource/archive/FolderArchive.h index 311c5d4..84b398c 100644 --- a/src/resource/archive/FolderArchive.h +++ b/include/ship/resource/archive/FolderArchive.h @@ -6,9 +6,9 @@ #include #include -#include "resource/File.h" -#include "resource/Resource.h" -#include "resource/archive/Archive.h" +#include "ship/resource/File.h" +#include "ship/resource/Resource.h" +#include "ship/resource/archive/Archive.h" namespace Ship { struct File; diff --git a/src/resource/archive/O2rArchive.h b/include/ship/resource/archive/O2rArchive.h similarity index 83% rename from src/resource/archive/O2rArchive.h rename to include/ship/resource/archive/O2rArchive.h index 5421fff..57dec58 100644 --- a/src/resource/archive/O2rArchive.h +++ b/include/ship/resource/archive/O2rArchive.h @@ -8,9 +8,9 @@ #include "zip.h" -#include "resource/File.h" -#include "resource/Resource.h" -#include "resource/archive/Archive.h" +#include "ship/resource/File.h" +#include "ship/resource/Resource.h" +#include "ship/resource/archive/Archive.h" namespace Ship { struct File; diff --git a/src/resource/archive/OtrArchive.h b/include/ship/resource/archive/OtrArchive.h similarity index 90% rename from src/resource/archive/OtrArchive.h rename to include/ship/resource/archive/OtrArchive.h index c47b025..3981e80 100644 --- a/src/resource/archive/OtrArchive.h +++ b/include/ship/resource/archive/OtrArchive.h @@ -15,8 +15,8 @@ #include #include -#include "resource/Resource.h" -#include "resource/archive/Archive.h" +#include "ship/resource/Resource.h" +#include "ship/resource/archive/Archive.h" namespace Ship { struct File; diff --git a/src/resource/factory/BlobFactory.h b/include/ship/resource/factory/BlobFactory.h similarity index 79% rename from src/resource/factory/BlobFactory.h rename to include/ship/resource/factory/BlobFactory.h index f29620a..6ec7538 100644 --- a/src/resource/factory/BlobFactory.h +++ b/include/ship/resource/factory/BlobFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Ship { class ResourceFactoryBinaryBlobV0 final : public Ship::ResourceFactoryBinary { diff --git a/src/resource/factory/JsonFactory.h b/include/ship/resource/factory/JsonFactory.h similarity index 78% rename from src/resource/factory/JsonFactory.h rename to include/ship/resource/factory/JsonFactory.h index 4f781b4..5afaa29 100644 --- a/src/resource/factory/JsonFactory.h +++ b/include/ship/resource/factory/JsonFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Ship { class ResourceFactoryBinaryJsonV0 final : public ResourceFactoryBinary { diff --git a/src/resource/factory/ShaderFactory.h b/include/ship/resource/factory/ShaderFactory.h similarity index 71% rename from src/resource/factory/ShaderFactory.h rename to include/ship/resource/factory/ShaderFactory.h index a433d9e..20d7d23 100644 --- a/src/resource/factory/ShaderFactory.h +++ b/include/ship/resource/factory/ShaderFactory.h @@ -1,8 +1,8 @@ #pragma once -#include "resource/Resource.h" -#include "resource/type/Shader.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/type/Shader.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Ship { class ResourceFactoryBinaryShaderV0 final : public ResourceFactoryBinary { diff --git a/src/resource/type/Blob.h b/include/ship/resource/type/Blob.h similarity index 87% rename from src/resource/type/Blob.h rename to include/ship/resource/type/Blob.h index 265a587..0a41205 100644 --- a/src/resource/type/Blob.h +++ b/include/ship/resource/type/Blob.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" namespace Ship { class Blob final : public Ship::Resource { diff --git a/src/resource/type/Json.h b/include/ship/resource/type/Json.h similarity index 89% rename from src/resource/type/Json.h rename to include/ship/resource/type/Json.h index 6d99d92..20e10b8 100644 --- a/src/resource/type/Json.h +++ b/include/ship/resource/type/Json.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" #include namespace Ship { diff --git a/src/resource/type/Shader.h b/include/ship/resource/type/Shader.h similarity index 87% rename from src/resource/type/Shader.h rename to include/ship/resource/type/Shader.h index 9395f42..93c3154 100644 --- a/src/resource/type/Shader.h +++ b/include/ship/resource/type/Shader.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" namespace Ship { class Shader final : public Resource { diff --git a/src/utils/AppleFolderManager.h b/include/ship/utils/AppleFolderManager.h similarity index 100% rename from src/utils/AppleFolderManager.h rename to include/ship/utils/AppleFolderManager.h diff --git a/src/utils/StrHash64.h b/include/ship/utils/StrHash64.h similarity index 100% rename from src/utils/StrHash64.h rename to include/ship/utils/StrHash64.h diff --git a/src/utils/StringHelper.h b/include/ship/utils/StringHelper.h similarity index 100% rename from src/utils/StringHelper.h rename to include/ship/utils/StringHelper.h diff --git a/src/utils/Utils.h b/include/ship/utils/Utils.h similarity index 100% rename from src/utils/Utils.h rename to include/ship/utils/Utils.h diff --git a/src/utils/binarytools/BinaryReader.h b/include/ship/utils/binarytools/BinaryReader.h similarity index 100% rename from src/utils/binarytools/BinaryReader.h rename to include/ship/utils/binarytools/BinaryReader.h diff --git a/src/utils/binarytools/BinaryWriter.h b/include/ship/utils/binarytools/BinaryWriter.h similarity index 100% rename from src/utils/binarytools/BinaryWriter.h rename to include/ship/utils/binarytools/BinaryWriter.h diff --git a/src/utils/binarytools/BitConverter.h b/include/ship/utils/binarytools/BitConverter.h similarity index 100% rename from src/utils/binarytools/BitConverter.h rename to include/ship/utils/binarytools/BitConverter.h diff --git a/src/utils/binarytools/MemoryStream.h b/include/ship/utils/binarytools/MemoryStream.h similarity index 100% rename from src/utils/binarytools/MemoryStream.h rename to include/ship/utils/binarytools/MemoryStream.h diff --git a/src/utils/binarytools/Stream.h b/include/ship/utils/binarytools/Stream.h similarity index 100% rename from src/utils/binarytools/Stream.h rename to include/ship/utils/binarytools/Stream.h diff --git a/src/utils/binarytools/endianness.h b/include/ship/utils/binarytools/endianness.h similarity index 100% rename from src/utils/binarytools/endianness.h rename to include/ship/utils/binarytools/endianness.h diff --git a/src/utils/filesystemtools/Directory.h b/include/ship/utils/filesystemtools/Directory.h similarity index 97% rename from src/utils/filesystemtools/Directory.h rename to include/ship/utils/filesystemtools/Directory.h index aeefe7f..eb09edf 100644 --- a/src/utils/filesystemtools/Directory.h +++ b/include/ship/utils/filesystemtools/Directory.h @@ -2,7 +2,6 @@ #include #include -#include "utils/StringHelper.h" #include #if __has_include() diff --git a/src/utils/filesystemtools/DiskFile.h b/include/ship/utils/filesystemtools/DiskFile.h similarity index 98% rename from src/utils/filesystemtools/DiskFile.h rename to include/ship/utils/filesystemtools/DiskFile.h index 39388cf..a7d5d7f 100644 --- a/src/utils/filesystemtools/DiskFile.h +++ b/include/ship/utils/filesystemtools/DiskFile.h @@ -6,7 +6,6 @@ #include #include #include "Path.h" -#include "utils/StringHelper.h" #include "Directory.h" class DiskFile { diff --git a/src/utils/filesystemtools/FileHelper.h b/include/ship/utils/filesystemtools/FileHelper.h similarity index 97% rename from src/utils/filesystemtools/FileHelper.h rename to include/ship/utils/filesystemtools/FileHelper.h index b39a5dd..f92a35b 100644 --- a/src/utils/filesystemtools/FileHelper.h +++ b/include/ship/utils/filesystemtools/FileHelper.h @@ -6,8 +6,7 @@ #include #include #include "PathHelper.h" -#include "utils/StringHelper.h" -#include "utils/filesystemtools/Directory.h" +#include "Directory.h" namespace Ship { class FileHelper { diff --git a/src/utils/filesystemtools/Path.h b/include/ship/utils/filesystemtools/Path.h similarity index 97% rename from src/utils/filesystemtools/Path.h rename to include/ship/utils/filesystemtools/Path.h index 87bc85b..95ef88f 100644 --- a/src/utils/filesystemtools/Path.h +++ b/include/ship/utils/filesystemtools/Path.h @@ -2,7 +2,7 @@ #include #include -#include "utils/StringHelper.h" +#include "../StringHelper.h" #if __has_include() #include diff --git a/src/utils/filesystemtools/PathHelper.h b/include/ship/utils/filesystemtools/PathHelper.h similarity index 97% rename from src/utils/filesystemtools/PathHelper.h rename to include/ship/utils/filesystemtools/PathHelper.h index ece66c9..e441355 100644 --- a/src/utils/filesystemtools/PathHelper.h +++ b/include/ship/utils/filesystemtools/PathHelper.h @@ -2,7 +2,7 @@ #include #include -#include "utils/StringHelper.h" +#include "../StringHelper.h" #if __has_include() #include diff --git a/src/utils/glob.h b/include/ship/utils/glob.h similarity index 100% rename from src/utils/glob.h rename to include/ship/utils/glob.h diff --git a/src/utils/macUtils.h b/include/ship/utils/macUtils.h similarity index 100% rename from src/utils/macUtils.h rename to include/ship/utils/macUtils.h diff --git a/src/utils/stox.h b/include/ship/utils/stox.h similarity index 100% rename from src/utils/stox.h rename to include/ship/utils/stox.h diff --git a/src/window/FileDropMgr.h b/include/ship/window/FileDropMgr.h similarity index 100% rename from src/window/FileDropMgr.h rename to include/ship/window/FileDropMgr.h diff --git a/src/window/Window.h b/include/ship/window/Window.h similarity index 96% rename from src/window/Window.h rename to include/ship/window/Window.h index da8e1f7..389e38c 100644 --- a/src/window/Window.h +++ b/include/ship/window/Window.h @@ -6,8 +6,8 @@ #include #include #include -#include "window/gui/Gui.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/window/gui/Gui.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { enum class WindowBackend { FAST3D_DXGI_DX11, FAST3D_SDL_OPENGL, FAST3D_SDL_METAL, WINDOW_BACKEND_COUNT }; diff --git a/src/window/gui/ConsoleWindow.h b/include/ship/window/gui/ConsoleWindow.h similarity index 98% rename from src/window/gui/ConsoleWindow.h rename to include/ship/window/gui/ConsoleWindow.h index e2272e7..8aaf09c 100644 --- a/src/window/gui/ConsoleWindow.h +++ b/include/ship/window/gui/ConsoleWindow.h @@ -5,8 +5,8 @@ #include #include -#include "window/gui/GuiWindow.h" -#include "debug/Console.h" +#include "ship/window/gui/GuiWindow.h" +#include "ship/debug/Console.h" #include #include diff --git a/src/window/gui/Fonts.h b/include/ship/window/gui/Fonts.h similarity index 100% rename from src/window/gui/Fonts.h rename to include/ship/window/gui/Fonts.h diff --git a/src/window/gui/GameOverlay.h b/include/ship/window/gui/GameOverlay.h similarity index 94% rename from src/window/gui/GameOverlay.h rename to include/ship/window/gui/GameOverlay.h index 23b7708..90343f1 100644 --- a/src/window/gui/GameOverlay.h +++ b/include/ship/window/gui/GameOverlay.h @@ -3,10 +3,10 @@ #include #include -#include "debug/Console.h" +#include "ship/debug/Console.h" #include #include -#include "resource/ResourceManager.h" +#include "ship/resource/ResourceManager.h" namespace Ship { diff --git a/src/window/gui/Gui.h b/include/ship/window/gui/Gui.h similarity index 89% rename from src/window/gui/Gui.h rename to include/ship/window/gui/Gui.h index 88bcb4a..5276cb5 100644 --- a/src/window/gui/Gui.h +++ b/include/ship/window/gui/Gui.h @@ -10,17 +10,17 @@ #include #include #include -#include "window/gui/ConsoleWindow.h" -#include "window/gui/InputEditorWindow.h" -#include "controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h" -#include "window/gui/IconsFontAwesome4.h" -#include "window/gui/GameOverlay.h" -#include "window/gui/StatsWindow.h" -#include "window/gui/GuiWindow.h" -#include "window/gui/GuiMenuBar.h" +#include "ship/window/gui/ConsoleWindow.h" +#include "ship/window/gui/InputEditorWindow.h" +#include "ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/window/gui/GameOverlay.h" +#include "ship/window/gui/StatsWindow.h" +#include "ship/window/gui/GuiWindow.h" +#include "ship/window/gui/GuiMenuBar.h" #include "libultraship/libultra/controller.h" -#include "resource/type/Texture.h" -#include "window/gui/resource/GuiTexture.h" +#include "fast/resource/type/Texture.h" +#include "ship/window/gui/resource/GuiTexture.h" namespace Fast { class Interpreter; diff --git a/src/window/gui/GuiElement.h b/include/ship/window/gui/GuiElement.h similarity index 100% rename from src/window/gui/GuiElement.h rename to include/ship/window/gui/GuiElement.h diff --git a/src/window/gui/GuiMenuBar.h b/include/ship/window/gui/GuiMenuBar.h similarity index 91% rename from src/window/gui/GuiMenuBar.h rename to include/ship/window/gui/GuiMenuBar.h index 76a4f54..059b824 100644 --- a/src/window/gui/GuiMenuBar.h +++ b/include/ship/window/gui/GuiMenuBar.h @@ -1,7 +1,7 @@ #pragma once #include -#include "window/gui/GuiElement.h" +#include "ship/window/gui/GuiElement.h" namespace Ship { class GuiMenuBar : public GuiElement { diff --git a/src/window/gui/GuiWindow.h b/include/ship/window/gui/GuiWindow.h similarity index 97% rename from src/window/gui/GuiWindow.h rename to include/ship/window/gui/GuiWindow.h index a1bac96..6c5e1d9 100644 --- a/src/window/gui/GuiWindow.h +++ b/include/ship/window/gui/GuiWindow.h @@ -3,7 +3,7 @@ #include #include #include -#include "window/gui/GuiElement.h" +#include "ship/window/gui/GuiElement.h" #include namespace Ship { diff --git a/src/window/gui/IconsFontAwesome4.h b/include/ship/window/gui/IconsFontAwesome4.h similarity index 100% rename from src/window/gui/IconsFontAwesome4.h rename to include/ship/window/gui/IconsFontAwesome4.h diff --git a/src/window/gui/InputEditorWindow.h b/include/ship/window/gui/InputEditorWindow.h similarity index 96% rename from src/window/gui/InputEditorWindow.h rename to include/ship/window/gui/InputEditorWindow.h index 924655a..810b274 100644 --- a/src/window/gui/InputEditorWindow.h +++ b/include/ship/window/gui/InputEditorWindow.h @@ -1,13 +1,13 @@ #pragma once #include "stdint.h" -#include "window/gui/GuiWindow.h" +#include "ship/window/gui/GuiWindow.h" #include #include #include #include #include -#include "controller/controldevice/controller/Controller.h" +#include "ship/controller/controldevice/controller/Controller.h" namespace Ship { diff --git a/src/window/gui/StatsWindow.h b/include/ship/window/gui/StatsWindow.h similarity index 87% rename from src/window/gui/StatsWindow.h rename to include/ship/window/gui/StatsWindow.h index 159ad92..ada0386 100644 --- a/src/window/gui/StatsWindow.h +++ b/include/ship/window/gui/StatsWindow.h @@ -1,6 +1,6 @@ #pragma once -#include "window/gui/GuiWindow.h" +#include "ship/window/gui/GuiWindow.h" namespace Ship { class StatsWindow : public GuiWindow { diff --git a/src/window/gui/resource/Font.h b/include/ship/window/gui/resource/Font.h similarity index 90% rename from src/window/gui/resource/Font.h rename to include/ship/window/gui/resource/Font.h index 246c41b..27365ec 100644 --- a/src/window/gui/resource/Font.h +++ b/include/ship/window/gui/resource/Font.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" namespace Ship { #define RESOURCE_TYPE_FONT 0x464F4E54 // FONT diff --git a/src/window/gui/resource/FontFactory.h b/include/ship/window/gui/resource/FontFactory.h similarity index 78% rename from src/window/gui/resource/FontFactory.h rename to include/ship/window/gui/resource/FontFactory.h index 28254b5..7593921 100644 --- a/src/window/gui/resource/FontFactory.h +++ b/include/ship/window/gui/resource/FontFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Ship { class ResourceFactoryBinaryFontV0 final : public ResourceFactoryBinary { diff --git a/src/window/gui/resource/GuiTexture.h b/include/ship/window/gui/resource/GuiTexture.h similarity index 93% rename from src/window/gui/resource/GuiTexture.h rename to include/ship/window/gui/resource/GuiTexture.h index a5145a6..74d594d 100644 --- a/src/window/gui/resource/GuiTexture.h +++ b/include/ship/window/gui/resource/GuiTexture.h @@ -1,6 +1,6 @@ #pragma once -#include "resource/Resource.h" +#include "ship/resource/Resource.h" #include namespace Ship { diff --git a/src/window/gui/resource/GuiTextureFactory.h b/include/ship/window/gui/resource/GuiTextureFactory.h similarity index 79% rename from src/window/gui/resource/GuiTextureFactory.h rename to include/ship/window/gui/resource/GuiTextureFactory.h index f7f8d46..d2ecee7 100644 --- a/src/window/gui/resource/GuiTextureFactory.h +++ b/include/ship/window/gui/resource/GuiTextureFactory.h @@ -1,7 +1,7 @@ #pragma once -#include "resource/Resource.h" -#include "resource/ResourceFactoryBinary.h" +#include "ship/resource/Resource.h" +#include "ship/resource/ResourceFactoryBinary.h" namespace Ship { class ResourceFactoryBinaryGuiTextureV0 final : public ResourceFactoryBinary { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50ff812..8fd72e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -include(../cmake/cvars.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cvars.cmake) add_library(libultraship STATIC) set_target_properties(libultraship PROPERTIES PREFIX "") @@ -15,153 +15,28 @@ use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") endif() #=================== Top-Level =================== +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/ship/install_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/ship/install_config.h @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/install_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/install_config.h @ONLY) +#=================== Fast =================== -file(GLOB Source_Files__TopLevel RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp") +add_subdirectory("fast") -source_group("" FILES ${Source_Files__TopLevel}) -target_sources(libultraship PRIVATE ${Source_Files__TopLevel}) +#=================== LUS =================== -#=================== Audio =================== +add_subdirectory("libultraship") -file(GLOB Source_Files__Audio RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "audio/*.h" "audio/*.cpp") +#=================== Ship =================== -if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") - list(FILTER Source_Files__Audio EXCLUDE REGEX "audio/WasapiAudioPlayer.*") -endif() - -source_group("audio" FILES ${Source_Files__Audio}) -target_sources(libultraship PRIVATE ${Source_Files__Audio}) - -#=================== Controller =================== - -file(GLOB_RECURSE Source_Files__Controller RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "controller/*.h" "controller/*.cpp") - -source_group("controller" FILES ${Source_Files__Controller}) -target_sources(libultraship PRIVATE ${Source_Files__Controller}) - -#=================== Config =================== - -file(GLOB Source_Files__Config RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "config/*.h" "config/*.cpp") - -source_group("config" FILES ${Source_Files__Config}) -target_sources(libultraship PRIVATE ${Source_Files__Config}) - -#=================== Public =================== - -source_group("public") - -file(GLOB Source_Files__Public__Libultra RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "public/libultra/*.h" "public/libultra/*.cpp") - -source_group("public/libultra" FILES ${Source_Files__Public__Libultra}) - -file(GLOB Source_Files__Public__Bridge RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "public/bridge/*.h" "public/bridge/*.cpp") - -source_group("public/bridge" FILES ${Source_Files__Public__Bridge}) -target_sources(libultraship PRIVATE ${Source_Files__Public__Libultra} ${Source_Files__Public__Bridge}) - -#=================== Debug =================== - -file(GLOB Source_Files__Debug RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "debug/*.h" "debug/*.cpp") - -source_group("debug" FILES ${Source_Files__Debug}) -target_sources(libultraship PRIVATE ${Source_Files__Debug}) - -#=================== Log =================== - -file(GLOB Source_Files__Log RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "log/*.h" "log/*.cpp") - -source_group("log" FILES ${Source_Files__Log}) - -target_sources(libultraship PRIVATE ${Source_Files__Log}) - -#=================== Window =================== - -file(GLOB Source_Files__Window RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/*.h" "window/*.cpp") - -source_group("window" FILES ${Source_Files__Window}) -target_sources(libultraship PRIVATE ${Source_Files__Window}) - -#=================== Gui =================== - -file(GLOB_RECURSE Source_Files__Window__Gui RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/gui/*.h" "window/gui/*.cpp") - -source_group("window/gui" FILES ${Source_Files__Window__Gui}) -target_sources(libultraship PRIVATE ${Source_Files__Window__Gui}) - -#=================== Utils =================== - -file(GLOB_RECURSE Source_Files__Utils RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "utils/*.h" "utils/*.cpp" "utils/*.c") +add_subdirectory("ship") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(APPEND Source_Files__Utils ${CMAKE_CURRENT_SOURCE_DIR}/utils/AppleFolderManager.mm) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/utils/AppleFolderManager.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc) -else() - list(REMOVE_ITEM Header_Files__include ${CMAKE_CURRENT_SOURCE_DIR}/utils/AppleFolderManager.h) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ship/utils/AppleFolderManager.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc) endif() if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - list(APPEND Source_Files__Utils ${CMAKE_CURRENT_SOURCE_DIR}/utils/macUtils.mm) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/utils/macUtils.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc) -else() - list(REMOVE_ITEM Header_Files__include ${CMAKE_CURRENT_SOURCE_DIR}/utils/macUtils.h) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ship/utils/macUtils.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc) endif() -source_group("utils" FILES ${Source_Files__Utils}) -target_sources(libultraship PRIVATE ${Source_Files__Utils}) - -#=================== Port =================== - -if (CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") - set(Source_Files__Port - ${CMAKE_CURRENT_SOURCE_DIR}/port/mobile/MobileImpl.h - ${CMAKE_CURRENT_SOURCE_DIR}/port/mobile/MobileImpl.cpp - ) -endif() - -source_group("port" FILES ${Source_Files__Port}) -target_sources(libultraship PRIVATE ${Source_Files__Port}) - -#=================== Resource =================== - -file(GLOB Source_Files__Resource RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/*.h" "resource/*.cpp") -source_group("resource" FILES ${Source_Files__Resource}) - -file(GLOB Source_Files__Resource__Types RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/type/*.h" "resource/type/*.cpp") -source_group("resource/type" FILES ${Source_Files__Resource__Types}) - -file(GLOB Source_Files__Resource__Factories RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/factory/*.h" "resource/factory/*.cpp") -source_group("resource/factory" FILES ${Source_Files__Resource__Factories}) - -file(GLOB Source_Files__Resource__Archive RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/archive/*.h" "resource/archive/*.cpp") -source_group("resource/archive" FILES ${Source_Files__Resource__Archive}) - -target_sources(libultraship PRIVATE ${Source_Files__Resource} ${Source_Files__Resource__Types} ${Source_Files__Resource__Factories} ${Source_Files__Resource__Archive}) - -#=================== Graphic =================== - -file(GLOB Source_Files__Graphic RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "graphic/Fast3D/*.h" "graphic/Fast3D/*.cpp" "graphic/Fast3D/*.c" "graphic/Fast3D/backends/*.cpp" "graphic/Fast3D/debug/*.h" "graphic/Fast3D/debug/*.cpp" "graphic/Fast3D/debug/*.c") - -if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") - list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_dxgi*") - list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_direct3d*") - list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/dxsdk/*") -endif() - -if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_metal*") -endif() - -if (CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_opengl*") -endif() - -source_group("graphic" FILES ${Source_Files__Graphic}) -source_group("graphic_debug" FILES ${Source_Files__Graphic_Debug}) -target_sources(libultraship PRIVATE ${Source_Files__Graphic}) -target_sources(libultraship PRIVATE ${Source_Files__Graphic_Debug}) - #=================== Packages & Includes =================== target_include_directories(libultraship @@ -351,3 +226,4 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") ) endif() endif() + diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp b/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp deleted file mode 100644 index 2da4571..0000000 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "KeyboardKeyToAxisDirectionMapping.h" -#include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" - -namespace Ship { -KeyboardKeyToAxisDirectionMapping::KeyboardKeyToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, - Direction direction, KbScancode scancode) - : ControllerInputMapping(PhysicalDeviceType::Keyboard), KeyboardKeyToAnyMapping(scancode), - ControllerAxisDirectionMapping(PhysicalDeviceType::Keyboard, portIndex, stickIndex, direction) { -} - -float KeyboardKeyToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { - if (Context::GetInstance()->GetControlDeck()->KeyboardGameInputBlocked()) { - return 0.0f; - } - - return mKeyPressed ? MAX_AXIS_RANGE : 0.0f; -} - -std::string KeyboardKeyToAxisDirectionMapping::GetAxisDirectionMappingId() { - return StringHelper::Sprintf("P%d-S%d-D%d-KB%d", mPortIndex, mStickIndex, mDirection, mKeyboardScancode); -} - -void KeyboardKeyToAxisDirectionMapping::SaveToConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "KeyboardKeyToAxisDirectionMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); - CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); - CVarSetInteger(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), mKeyboardScancode); - CVarSave(); -} - -void KeyboardKeyToAxisDirectionMapping::EraseFromConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str()); - CVarSave(); -} - -int8_t KeyboardKeyToAxisDirectionMapping::GetMappingType() { - return MAPPING_TYPE_KEYBOARD; -} - -std::string KeyboardKeyToAxisDirectionMapping::GetPhysicalDeviceName() { - return KeyboardKeyToAnyMapping::GetPhysicalDeviceName(); -} - -std::string KeyboardKeyToAxisDirectionMapping::GetPhysicalInputName() { - return KeyboardKeyToAnyMapping::GetPhysicalInputName(); -} -} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp deleted file mode 100644 index 88d6907..0000000 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "MouseButtonToAxisDirectionMapping.h" -#include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" - -namespace Ship { -MouseButtonToAxisDirectionMapping::MouseButtonToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, - Direction direction, MouseBtn button) - : ControllerInputMapping(PhysicalDeviceType::Mouse), MouseButtonToAnyMapping(button), - ControllerAxisDirectionMapping(PhysicalDeviceType::Mouse, portIndex, stickIndex, direction) { -} - -float MouseButtonToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { - if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { - return 0.0f; - } - - return mKeyPressed ? MAX_AXIS_RANGE : 0.0f; -} - -std::string MouseButtonToAxisDirectionMapping::GetAxisDirectionMappingId() { - return StringHelper::Sprintf("P%d-S%d-D%d-MOUSE%d", mPortIndex, mStickIndex, mDirection, mButton); -} - -void MouseButtonToAxisDirectionMapping::SaveToConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseButtonToAxisDirectionMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); - CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); - CVarSetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); - CVarSave(); -} - -void MouseButtonToAxisDirectionMapping::EraseFromConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str()); - CVarSave(); -} - -int8_t MouseButtonToAxisDirectionMapping::GetMappingType() { - return MAPPING_TYPE_MOUSE; -} - -std::string MouseButtonToAxisDirectionMapping::GetPhysicalDeviceName() { - return MouseButtonToAnyMapping::GetPhysicalDeviceName(); -} - -std::string MouseButtonToAxisDirectionMapping::GetPhysicalInputName() { - return MouseButtonToAnyMapping::GetPhysicalInputName(); -} -} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp b/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp deleted file mode 100644 index 5d79d95..0000000 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "MouseWheelToAxisDirectionMapping.h" -#include -#include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "WheelHandler.h" -#include "controller/controldeck/ControlDeck.h" - -namespace Ship { -MouseWheelToAxisDirectionMapping::MouseWheelToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, - Direction direction, WheelDirection wheelDirection) - : ControllerInputMapping(PhysicalDeviceType::Mouse), MouseWheelToAnyMapping(wheelDirection), - ControllerAxisDirectionMapping(PhysicalDeviceType::Mouse, portIndex, stickIndex, direction) { -} - -float MouseWheelToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { - if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { - return 0.0f; - } - - if (WheelHandler::GetInstance()->GetBufferedDirectionValue(mWheelDirection) > 0) { - return MAX_AXIS_RANGE; - } else { - return 0.0f; - } -} - -std::string MouseWheelToAxisDirectionMapping::GetAxisDirectionMappingId() { - return StringHelper::Sprintf("P%d-S%d-D%d-WHEEL%d", mPortIndex, mStickIndex, mDirection, mWheelDirection); -} - -void MouseWheelToAxisDirectionMapping::SaveToConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseWheelToAxisDirectionMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); - CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); - CVarSetInteger(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), - static_cast(mWheelDirection)); - CVarSave(); -} - -void MouseWheelToAxisDirectionMapping::EraseFromConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str()); - CVarSave(); -} - -int8_t MouseWheelToAxisDirectionMapping::GetMappingType() { - return MAPPING_TYPE_MOUSE; -} - -std::string MouseWheelToAxisDirectionMapping::GetPhysicalDeviceName() { - return MouseWheelToAnyMapping::GetPhysicalDeviceName(); -} - -std::string MouseWheelToAxisDirectionMapping::GetPhysicalInputName() { - return MouseWheelToAnyMapping::GetPhysicalInputName(); -} -} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp b/src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp deleted file mode 100644 index a234027..0000000 --- a/src/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "SDLLEDMapping.h" - -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" - -namespace Ship { -SDLLEDMapping::SDLLEDMapping(uint8_t portIndex, uint8_t colorSource, Color_RGB8 savedColor) - : ControllerLEDMapping(PhysicalDeviceType::SDLGamepad, portIndex, colorSource, savedColor) { -} - -void SDLLEDMapping::SetLEDColor(Color_RGB8 color) { - if (mColorSource == LED_COLOR_SOURCE_OFF) { - color = { 0, 0, 0 }; - } - - if (mColorSource == LED_COLOR_SOURCE_SET) { - color = mSavedColor; - } - - for (const auto& [instanceId, gamepad] : - Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort( - mPortIndex)) { - if (!SDL_GameControllerHasLED(gamepad)) { - continue; - } - - SDL_JoystickSetLED(SDL_GameControllerGetJoystick(gamepad), color.r, color.g, color.b); - } -} - -std::string SDLLEDMapping::GetLEDMappingId() { - return StringHelper::Sprintf("P%d", mPortIndex); -} - -void SDLLEDMapping::SaveToConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + GetLEDMappingId(); - CVarSetString(StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str(), "SDLLEDMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str(), mColorSource); - CVarSetColor24(StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str(), mSavedColor); - CVarSave(); -} - -void SDLLEDMapping::EraseFromConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + GetLEDMappingId(); - - CVarClear(StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str()); - - CVarSave(); -} - -std::string SDLLEDMapping::GetPhysicalDeviceName() { - return "SDL Gamepad"; -} -} // namespace Ship diff --git a/src/controller/physicaldevice/GlobalSDLDeviceSettings.cpp b/src/controller/physicaldevice/GlobalSDLDeviceSettings.cpp deleted file mode 100644 index c738688..0000000 --- a/src/controller/physicaldevice/GlobalSDLDeviceSettings.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "GlobalSDLDeviceSettings.h" - -#include -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" - -namespace Ship { -GlobalSDLDeviceSettings::GlobalSDLDeviceSettings() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; - const int32_t defaultAxisThresholdPercentage = 25; - mStickAxisThresholdPercentage = - CVarGetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), - defaultAxisThresholdPercentage); - mTriggerAxisThresholdPercentage = - CVarGetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), - defaultAxisThresholdPercentage); -} - -GlobalSDLDeviceSettings::~GlobalSDLDeviceSettings() { -} - -int32_t GlobalSDLDeviceSettings::GetStickAxisThresholdPercentage() { - return mStickAxisThresholdPercentage; -} - -void GlobalSDLDeviceSettings::SetStickAxisThresholdPercentage(int32_t stickAxisThresholdPercentage) { - mStickAxisThresholdPercentage = stickAxisThresholdPercentage; -} - -int32_t GlobalSDLDeviceSettings::GetTriggerAxisThresholdPercentage() { - return mTriggerAxisThresholdPercentage; -} - -void GlobalSDLDeviceSettings::SetTriggerAxisThresholdPercentage(int32_t triggerAxisThresholdPercentage) { - mTriggerAxisThresholdPercentage = triggerAxisThresholdPercentage; -} - -void GlobalSDLDeviceSettings::SaveToConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; - CVarSetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), - mStickAxisThresholdPercentage); - CVarSetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), - mTriggerAxisThresholdPercentage); - CVarSave(); -} - -void GlobalSDLDeviceSettings::EraseFromConfig() { - const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; - CVarClear(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); - - CVarSave(); -} -} // namespace Ship diff --git a/src/fast/CMakeLists.txt b/src/fast/CMakeLists.txt new file mode 100644 index 0000000..66bf70d --- /dev/null +++ b/src/fast/CMakeLists.txt @@ -0,0 +1,43 @@ +#=================== Top-Level =================== +file(GLOB Source_Files__TopLevel RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") + +source_group("" FILES ${Source_Files__TopLevel}) +target_sources(libultraship PRIVATE ${Source_Files__TopLevel}) + +#=================== Debug =================== + +file(GLOB Source_Files__Debug RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "debug/*.cpp") + +source_group("debug" FILES ${Source_Files__Debug}) +target_sources(libultraship PRIVATE ${Source_Files__Debug}) + +#=================== Resource =================== + +file(GLOB Source_Files__Resource__Types RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/type/*.h" "resource/type/*.cpp") +source_group("resource/type" FILES ${Source_Files__Resource__Types}) + +file(GLOB Source_Files__Resource__Factories RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/factory/*.h" "resource/factory/*.cpp") +source_group("resource/factory" FILES ${Source_Files__Resource__Factories}) + +target_sources(libultraship PRIVATE ${Source_Files__Resource} ${Source_Files__Resource__Types} ${Source_Files__Resource__Factories} ${Source_Files__Resource__Archive}) + +#=================== Graphic =================== + +file(GLOB Source_Files__Graphic RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "backends/*.cpp") + +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_dxgi*") + list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_direct3d*") + list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/dxsdk/*") +endif() + +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_metal*") +endif() + +if (CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/backends/gfx_opengl*") +endif() + +source_group("graphic" FILES ${Source_Files__Graphic}) +target_sources(libultraship PRIVATE ${Source_Files__Graphic}) diff --git a/src/graphic/Fast3D/Fast3dWindow.cpp b/src/fast/Fast3dWindow.cpp similarity index 94% rename from src/graphic/Fast3D/Fast3dWindow.cpp rename to src/fast/Fast3dWindow.cpp index e946f86..6267090 100644 --- a/src/graphic/Fast3D/Fast3dWindow.cpp +++ b/src/fast/Fast3dWindow.cpp @@ -1,17 +1,17 @@ -#include "Fast3dWindow.h" +#include "fast/Fast3dWindow.h" -#include "Context.h" -#include "config/Config.h" -#include "controller/controldeck/ControlDeck.h" -#include "public/bridge/consolevariablebridge.h" -#include "graphic/Fast3D/interpreter.h" -#include "graphic/Fast3D/backends/gfx_sdl.h" -#include "graphic/Fast3D/backends/gfx_dxgi.h" -#include "graphic/Fast3D/backends/gfx_opengl.h" -#include "graphic/Fast3D/backends/gfx_metal.h" -#include "graphic/Fast3D/backends/gfx_direct3d_common.h" -#include "graphic/Fast3D/backends/gfx_direct3d11.h" -#include "backends/gfx_window_manager_api.h" +#include "ship/Context.h" +#include "ship/config/Config.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/config/ConsoleVariable.h" +#include "fast/interpreter.h" +#include "fast/backends/gfx_sdl.h" +#include "fast/backends/gfx_dxgi.h" +#include "fast/backends/gfx_opengl.h" +#include "fast/backends/gfx_metal.h" +#include "fast/backends/gfx_direct3d_common.h" +#include "fast/backends/gfx_direct3d11.h" +#include "fast/backends/gfx_window_manager_api.h" #include @@ -98,7 +98,8 @@ void Fast3dWindow::Init() { mWindowManagerApi->SetKeyboardCallbacks(KeyDown, KeyUp, AllKeysUp); mWindowManagerApi->SetMouseCallbacks(MouseButtonDown, MouseButtonUp); - SetTextureFilter((FilteringMode)CVarGetInteger(CVAR_TEXTURE_FILTER, FILTER_THREE_POINT)); + SetTextureFilter((FilteringMode)Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_TEXTURE_FILTER, FILTER_THREE_POINT)); } int32_t Fast3dWindow::GetTargetFps() { diff --git a/src/fast/LICENSE.txt b/src/fast/LICENSE.txt new file mode 100644 index 0000000..2857b7e --- /dev/null +++ b/src/fast/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Emill, MaikelChan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/fast/README.md b/src/fast/README.md new file mode 100644 index 0000000..942427e --- /dev/null +++ b/src/fast/README.md @@ -0,0 +1,30 @@ +# Nintendo 64 Fast3D renderer + +Implementation of a Fast3D renderer for games built originally for the Nintendo 64 platform. + +For rendering OpenGL, Direct3D 11 and Direct3D 12 are supported. + +Supported windowing systems are GLX (used on Linux), DXGI (used on Windows) and SDL (generic). + +# Usage + +See `gfx_pc.h`. You will also need a copy of `PR/gbi.h`, found in libultra. + +First call `gfx_init(struct GfxBackend *wapi, struct GfxRenderingAPI *rapi, const char *game_name, bool start_in_fullscreen)` and supply the desired backends at program start. + +Some callbacks can be set on `wapi`. See `gfx_window_manager_api.h` for more info. + +Each game main loop iteration should look like this: + +```C +gfx_start_frame(); // Handles input events such as keyboard and window events +// perform game logic here +gfx_run(cmds); // submit display list and render a frame +// do more expensive work here, such as play audio +gfx_end_frame(); // this just waits until the frame is shown on the screen (vsync), to provide correct game timing +``` + +When you are ready to start the main loop, call `wapi->main_loop(one_iteration_func)`. + +For the best experience, please change the Vtx and Mtx structures to use floats instead of fixed point arithmetic (`GBI_FLOATS`). + diff --git a/src/graphic/Fast3D/backends/gfx_direct3d11.cpp b/src/fast/backends/gfx_direct3d11.cpp similarity index 99% rename from src/graphic/Fast3D/backends/gfx_direct3d11.cpp rename to src/fast/backends/gfx_direct3d11.cpp index 6f740ca..1077d2a 100644 --- a/src/graphic/Fast3D/backends/gfx_direct3d11.cpp +++ b/src/fast/backends/gfx_direct3d11.cpp @@ -19,25 +19,25 @@ #define _LANGUAGE_C #endif -#include "gfx_window_manager_api.h" -#include "gfx_direct3d_common.h" +#include "fast/backends/gfx_window_manager_api.h" +#include "fast/backends/gfx_direct3d_common.h" #define DECLARE_GFX_DXGI_FUNCTIONS -#include "gfx_dxgi.h" +#include "fast/backends/gfx_dxgi.h" -#include "gfx_screen_config.h" -#include "window/gui/Gui.h" -#include "Context.h" -#include "config/ConsoleVariable.h" -#include "window/Window.h" +#include "fast/backends/gfx_screen_config.h" +#include "ship/window/gui/Gui.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/window/Window.h" -#include "gfx_rendering_api.h" -#include "../interpreter.h" +#include "fast/backends/gfx_rendering_api.h" +#include "fast/interpreter.h" #include -#include -#include -#include +#include "ship/config/ConsoleVariable.h" +#include +#include #include "spdlog/spdlog.h" #include "nlohmann/json.hpp" diff --git a/src/graphic/Fast3D/backends/gfx_direct3d_common.cpp b/src/fast/backends/gfx_direct3d_common.cpp similarity index 100% rename from src/graphic/Fast3D/backends/gfx_direct3d_common.cpp rename to src/fast/backends/gfx_direct3d_common.cpp diff --git a/src/graphic/Fast3D/backends/gfx_dxgi.cpp b/src/fast/backends/gfx_dxgi.cpp similarity index 99% rename from src/graphic/Fast3D/backends/gfx_dxgi.cpp rename to src/fast/backends/gfx_dxgi.cpp index 9b3a1ba..1c0775a 100644 --- a/src/graphic/Fast3D/backends/gfx_dxgi.cpp +++ b/src/fast/backends/gfx_dxgi.cpp @@ -21,19 +21,19 @@ #define _LANGUAGE_C #endif -#include "config/ConsoleVariable.h" -#include "config/Config.h" -#include "Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/config/Config.h" +#include "ship/Context.h" -#include "gfx_window_manager_api.h" -#include "gfx_rendering_api.h" -#include "gfx_direct3d_common.h" -#include "gfx_screen_config.h" -#include "../interpreter.h" -#include "window/FileDropMgr.h" +#include "fast/backends/gfx_window_manager_api.h" +#include "fast/backends/gfx_rendering_api.h" +#include "fast/backends/gfx_direct3d_common.h" +#include "fast/backends/gfx_screen_config.h" +#include "fast/interpreter.h" +#include "ship/window/FileDropMgr.h" #define DECLARE_GFX_DXGI_FUNCTIONS -#include "gfx_dxgi.h" +#include "fast/backends/gfx_dxgi.h" #define WINCLASS_NAME L"N64GAME" #define GFX_BACKEND_NAME "DXGI" diff --git a/src/graphic/Fast3D/backends/gfx_metal.cpp b/src/fast/backends/gfx_metal.cpp similarity index 98% rename from src/graphic/Fast3D/backends/gfx_metal.cpp rename to src/fast/backends/gfx_metal.cpp index b965523..27540d2 100644 --- a/src/graphic/Fast3D/backends/gfx_metal.cpp +++ b/src/fast/backends/gfx_metal.cpp @@ -7,7 +7,7 @@ #ifdef __APPLE__ -#include "gfx_metal.h" +#include "fast/backends/gfx_metal.h" #include #include @@ -32,10 +32,11 @@ #include #include -#include "gfx_metal_shader.h" +#include "fast/backends/gfx_metal_shader.h" #include "libultraship/libultra/abi.h" -#include "public/bridge/consolevariablebridge.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) @@ -445,7 +446,7 @@ void GfxRenderingAPIMetal::DrawTriangles(float buf_vbo[], size_t buf_vbo_len, si const int n64modeFactor = 120; const int noVanishFactor = 100; float SSDB = -2; - switch (CVarGetInteger(CVAR_Z_FIGHTING_MODE, 0)) { + switch (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_Z_FIGHTING_MODE, 0)) { case 1: // scaled z-fighting (N64 mode like) SSDB = -1.0f * (float)mRenderTargetHeight / n64modeFactor; break; @@ -598,7 +599,7 @@ void GfxRenderingAPIMetal::SetupScreenFramebuffer(uint32_t width, uint32_t heigh mCurrentDrawable = nullptr; mCurrentDrawable = mLayer->nextDrawable(); - bool msaa_enabled = CVarGetInteger("gMSAAValue", 1) > 1; + bool msaa_enabled = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger("gMSAAValue", 1) > 1; FramebufferMetal& fb = mFramebuffers[0]; TextureDataMetal& tex = mTextures[fb.mTextureId]; @@ -711,7 +712,8 @@ void GfxRenderingAPIMetal::UpdateFramebufferParameters(int fb_id, uint32_t width MTL::RenderPassDescriptor* render_pass_descriptor = MTL::RenderPassDescriptor::renderPassDescriptor(); bool fb_msaa_enabled = (msaa_level > 1); - bool game_msaa_enabled = CVarGetInteger("gMSAAValue", 1) > 1; + bool game_msaa_enabled = + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger("gMSAAValue", 1) > 1; if (fb_msaa_enabled) { render_pass_descriptor->colorAttachments()->object(0)->setTexture(tex.msaaTexture); diff --git a/src/graphic/Fast3D/backends/gfx_metal_shader.cpp b/src/fast/backends/gfx_metal_shader.cpp similarity index 98% rename from src/graphic/Fast3D/backends/gfx_metal_shader.cpp rename to src/fast/backends/gfx_metal_shader.cpp index bdfec12..d71c6d6 100644 --- a/src/graphic/Fast3D/backends/gfx_metal_shader.cpp +++ b/src/fast/backends/gfx_metal_shader.cpp @@ -7,20 +7,20 @@ #ifdef __APPLE__ -#include -#include +#include +#include // This is a workaround for conflicting defines on Metal.hpp #define TRUE 1 #define FALSE 0 #include #undef TRUE #undef FALSE -#include -#include "gfx_metal_shader.h" +#include +#include "fast/backends/gfx_metal_shader.h" #include -#include "resource/ResourceManager.h" +#include #include "spdlog/spdlog.h" -#include "../interpreter.h" +#include "fast/interpreter.h" // MARK: - String Helpers #define RAND_NOISE \ diff --git a/src/graphic/Fast3D/backends/gfx_opengl.cpp b/src/fast/backends/gfx_opengl.cpp similarity index 99% rename from src/graphic/Fast3D/backends/gfx_opengl.cpp rename to src/fast/backends/gfx_opengl.cpp index 097e2e8..0b11466 100644 --- a/src/graphic/Fast3D/backends/gfx_opengl.cpp +++ b/src/fast/backends/gfx_opengl.cpp @@ -1,4 +1,4 @@ -#include "window/Window.h" +#include "ship/window/Window.h" #ifdef ENABLE_OPENGL #include @@ -18,14 +18,14 @@ #define FOR_WINDOWS 0 #endif -#include "gfx_opengl.h" -#include "window/gui/Gui.h" +#include "fast/backends/gfx_opengl.h" +#include "ship/window/gui/Gui.h" #include #include -#include "Context.h" -#include -#include "../interpreter.h" -#include +#include "ship/Context.h" +#include "ship/resource/factory/ShaderFactory.h" +#include "fast/interpreter.h" +#include "ship/config/ConsoleVariable.h" namespace Fast { int GfxRenderingAPIOGL::GetMaxTextureSize() { @@ -616,7 +616,7 @@ void GfxRenderingAPIOGL::DrawTriangles(float buf_vbo[], size_t buf_vbo_len, size const int n64modeFactor = 120; const int noVanishFactor = 100; GLfloat SSDB = -2; - switch (CVarGetInteger(CVAR_Z_FIGHTING_MODE, 0)) { + switch (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_Z_FIGHTING_MODE, 0)) { // scaled z-fighting (N64 mode like) case 1: if (mFrameBuffers.size() > diff --git a/src/graphic/Fast3D/backends/gfx_sdl2.cpp b/src/fast/backends/gfx_sdl2.cpp similarity index 97% rename from src/graphic/Fast3D/backends/gfx_sdl2.cpp rename to src/fast/backends/gfx_sdl2.cpp index 74bb5b2..63aa57e 100644 --- a/src/graphic/Fast3D/backends/gfx_sdl2.cpp +++ b/src/fast/backends/gfx_sdl2.cpp @@ -8,11 +8,11 @@ #define FOR_WINDOWS 0 #endif -#include "Context.h" -#include "config/ConsoleVariable.h" -#include "controller/controldeck/ControlDeck.h" -#include "window/FileDropMgr.h" -#include "gfx_sdl.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/window/FileDropMgr.h" +#include "fast/backends/gfx_sdl.h" #if FOR_WINDOWS #include @@ -21,16 +21,15 @@ #include "SDL_opengl.h" #elif __APPLE__ #include -#include "gfx_metal.h" -#include "utils/macUtils.h" +#include "fast/backends/gfx_metal.h" +#include "ship/utils/macUtils.h" #else #include #define GL_GLEXT_PROTOTYPES 1 #include #endif -#include "window/gui/Gui.h" -#include "public/bridge/consolevariablebridge.h" +#include "ship/window/gui/Gui.h" #ifdef _WIN32 #include @@ -235,10 +234,11 @@ void GfxWindowBackendSDL2::SetFullscreenImpl(bool on, bool call_callback) { } mFullScreen = on; #else - if (SDL_SetWindowFullscreen(mWnd, - on ? (CVarGetInteger(CVAR_SDL_WINDOWED_FULLSCREEN, 0) ? SDL_WINDOW_FULLSCREEN_DESKTOP - : SDL_WINDOW_FULLSCREEN) - : 0) >= 0) { + if (SDL_SetWindowFullscreen( + mWnd, on ? (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_SDL_WINDOWED_FULLSCREEN, 0) + ? SDL_WINDOW_FULLSCREEN_DESKTOP + : SDL_WINDOW_FULLSCREEN) + : 0) >= 0) { mFullScreen = on; } else { SPDLOG_ERROR("Failed to switch from or to fullscreen mode."); diff --git a/src/graphic/Fast3D/debug/GfxDebugger.cpp b/src/fast/debug/GfxDebugger.cpp similarity index 96% rename from src/graphic/Fast3D/debug/GfxDebugger.cpp rename to src/fast/debug/GfxDebugger.cpp index 65f966b..f136e80 100644 --- a/src/graphic/Fast3D/debug/GfxDebugger.cpp +++ b/src/fast/debug/GfxDebugger.cpp @@ -1,4 +1,4 @@ -#include "GfxDebugger.h" +#include "fast/debug/GfxDebugger.h" #include namespace Fast { diff --git a/src/graphic/Fast3D/interpreter.cpp b/src/fast/interpreter.cpp similarity index 99% rename from src/graphic/Fast3D/interpreter.cpp rename to src/fast/interpreter.cpp index 617f3ef..e13ccea 100644 --- a/src/graphic/Fast3D/interpreter.cpp +++ b/src/fast/interpreter.cpp @@ -15,24 +15,24 @@ #include #include #include -#include "resource/type/Light.h" +#include "fast/resource/type/Light.h" #ifndef _LANGUAGE_C #define _LANGUAGE_C #endif -#include "graphic/Fast3D/debug/GfxDebugger.h" +#include "fast/debug/GfxDebugger.h" #include "libultraship/libultra/types.h" #include -#include "interpreter.h" -#include "lus_gbi.h" -#include "backends/gfx_window_manager_api.h" -#include "backends/gfx_rendering_api.h" +#include "fast/interpreter.h" +#include "fast/lus_gbi.h" +#include "fast/backends/gfx_window_manager_api.h" +#include "fast/backends/gfx_rendering_api.h" -#include "window/gui/Gui.h" -#include "resource/ResourceManager.h" -#include "utils/Utils.h" -#include "Context.h" +#include "ship/window/gui/Gui.h" +#include "ship/resource/ResourceManager.h" +#include "ship/utils/Utils.h" +#include "ship/Context.h" #include "libultraship/bridge.h" #include @@ -4108,7 +4108,8 @@ static void gfx_step() { int8_t opcode = (int8_t)(cmd->words.w0 >> 24); #ifdef USE_GBI_TRACE - if (cmd->words.trace.valid && CVarGetInteger("gEnableGFXTrace", 0)) { + if (cmd->words.trace.valid && + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger("gEnableGFXTrace", 0)) { #define TRACE \ "\n====================================\n" \ " - CMD: {:02X}\n" \ @@ -4176,8 +4177,9 @@ void Interpreter::Init(class GfxWindowBackend* wapi, class GfxRenderingAPI* rapi mWapi->Init(game_name, rapi->GetName(), start_in_fullscreen, width, height, posX, posY); mRapi->Init(); mRapi->UpdateFramebufferParameters(0, width, height, 1, false, true, true, true); - mCurDimensions.internal_mul = CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1); - mMsaaLevel = CVarGetInteger(CVAR_MSAA_VALUE, 1); + mCurDimensions.internal_mul = + Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat(CVAR_INTERNAL_RESOLUTION, 1); + mMsaaLevel = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_MSAA_VALUE, 1); mCurDimensions.width = width; mCurDimensions.height = height; diff --git a/src/resource/factory/DisplayListFactory.cpp b/src/fast/resource/factory/DisplayListFactory.cpp similarity index 99% rename from src/resource/factory/DisplayListFactory.cpp rename to src/fast/resource/factory/DisplayListFactory.cpp index 6f9f7c6..a42b7c5 100644 --- a/src/resource/factory/DisplayListFactory.cpp +++ b/src/fast/resource/factory/DisplayListFactory.cpp @@ -1,8 +1,8 @@ -#include "resource/factory/DisplayListFactory.h" -#include "resource/type/DisplayList.h" +#include "fast/resource/factory/DisplayListFactory.h" +#include "fast/resource/type/DisplayList.h" #include "spdlog/spdlog.h" #include "libultraship/libultra/gbi.h" -#include "graphic/Fast3D/lus_gbi.h" +#include "fast/lus_gbi.h" #include namespace Fast { diff --git a/src/resource/factory/LightFactory.cpp b/src/fast/resource/factory/LightFactory.cpp similarity index 86% rename from src/resource/factory/LightFactory.cpp rename to src/fast/resource/factory/LightFactory.cpp index 62c5c37..c8b733b 100644 --- a/src/resource/factory/LightFactory.cpp +++ b/src/fast/resource/factory/LightFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/LightFactory.h" -#include "resource/type/Light.h" +#include "fast/resource/factory/LightFactory.h" +#include "fast/resource/type/Light.h" std::shared_ptr Fast::ResourceFactoryBinaryLightV0::ReadResource(std::shared_ptr file, diff --git a/src/resource/factory/MatrixFactory.cpp b/src/fast/resource/factory/MatrixFactory.cpp similarity index 89% rename from src/resource/factory/MatrixFactory.cpp rename to src/fast/resource/factory/MatrixFactory.cpp index b91d00e..f5e4125 100644 --- a/src/resource/factory/MatrixFactory.cpp +++ b/src/fast/resource/factory/MatrixFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/MatrixFactory.h" -#include "resource/type/Matrix.h" +#include "fast/resource/factory/MatrixFactory.h" +#include "fast/resource/type/Matrix.h" #include "spdlog/spdlog.h" namespace Fast { diff --git a/src/resource/factory/TextureFactory.cpp b/src/fast/resource/factory/TextureFactory.cpp similarity index 95% rename from src/resource/factory/TextureFactory.cpp rename to src/fast/resource/factory/TextureFactory.cpp index d655637..c525612 100644 --- a/src/resource/factory/TextureFactory.cpp +++ b/src/fast/resource/factory/TextureFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/TextureFactory.h" -#include "resource/type/Texture.h" +#include "fast/resource/factory/TextureFactory.h" +#include "fast/resource/type/Texture.h" #include "spdlog/spdlog.h" namespace Fast { diff --git a/src/resource/factory/VertexFactory.cpp b/src/fast/resource/factory/VertexFactory.cpp similarity index 96% rename from src/resource/factory/VertexFactory.cpp rename to src/fast/resource/factory/VertexFactory.cpp index 54582ac..c1680fe 100644 --- a/src/resource/factory/VertexFactory.cpp +++ b/src/fast/resource/factory/VertexFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/VertexFactory.h" -#include "resource/type/Vertex.h" +#include "fast/resource/factory/VertexFactory.h" +#include "fast/resource/type/Vertex.h" #include "spdlog/spdlog.h" #include "libultraship/libultra/gbi.h" #include diff --git a/src/resource/type/DisplayList.cpp b/src/fast/resource/type/DisplayList.cpp similarity index 90% rename from src/resource/type/DisplayList.cpp rename to src/fast/resource/type/DisplayList.cpp index 03d0acd..bf0e76e 100644 --- a/src/resource/type/DisplayList.cpp +++ b/src/fast/resource/type/DisplayList.cpp @@ -1,4 +1,4 @@ -#include "resource/type/DisplayList.h" +#include "fast/resource/type/DisplayList.h" #include namespace Fast { diff --git a/src/resource/type/Light.cpp b/src/fast/resource/type/Light.cpp similarity index 80% rename from src/resource/type/Light.cpp rename to src/fast/resource/type/Light.cpp index 5f0277c..f8280d1 100644 --- a/src/resource/type/Light.cpp +++ b/src/fast/resource/type/Light.cpp @@ -1,4 +1,4 @@ -#include "Light.h" +#include "fast/resource/type/Light.h" namespace Fast { LightEntry* Light::GetPointer() { diff --git a/src/resource/type/Matrix.cpp b/src/fast/resource/type/Matrix.cpp similarity index 85% rename from src/resource/type/Matrix.cpp rename to src/fast/resource/type/Matrix.cpp index d4d166f..d398ecc 100644 --- a/src/resource/type/Matrix.cpp +++ b/src/fast/resource/type/Matrix.cpp @@ -1,4 +1,4 @@ -#include "resource/type/Matrix.h" +#include "fast/resource/type/Matrix.h" namespace Fast { Matrix::Matrix() : Resource(std::shared_ptr()) { diff --git a/src/resource/type/Texture.cpp b/src/fast/resource/type/Texture.cpp similarity index 89% rename from src/resource/type/Texture.cpp rename to src/fast/resource/type/Texture.cpp index 2e522b6..4ae81d6 100644 --- a/src/resource/type/Texture.cpp +++ b/src/fast/resource/type/Texture.cpp @@ -1,4 +1,4 @@ -#include "resource/type/Texture.h" +#include "fast/resource/type/Texture.h" namespace Fast { Texture::Texture() : Resource(std::shared_ptr()) { diff --git a/src/resource/type/Vertex.cpp b/src/fast/resource/type/Vertex.cpp similarity index 88% rename from src/resource/type/Vertex.cpp rename to src/fast/resource/type/Vertex.cpp index a1bd182..5a4f7af 100644 --- a/src/resource/type/Vertex.cpp +++ b/src/fast/resource/type/Vertex.cpp @@ -1,4 +1,4 @@ -#include "resource/type/Vertex.h" +#include "fast/resource/type/Vertex.h" #include "libultraship/libultra/gbi.h" namespace Fast { diff --git a/src/graphic/Fast3D/shaders/directx/default.shader.hlsl b/src/fast/shaders/directx/default.shader.hlsl similarity index 100% rename from src/graphic/Fast3D/shaders/directx/default.shader.hlsl rename to src/fast/shaders/directx/default.shader.hlsl diff --git a/src/graphic/Fast3D/shaders/metal/default.shader.metal b/src/fast/shaders/metal/default.shader.metal similarity index 100% rename from src/graphic/Fast3D/shaders/metal/default.shader.metal rename to src/fast/shaders/metal/default.shader.metal diff --git a/src/graphic/Fast3D/shaders/opengl/default.shader.fs b/src/fast/shaders/opengl/default.shader.fs similarity index 100% rename from src/graphic/Fast3D/shaders/opengl/default.shader.fs rename to src/fast/shaders/opengl/default.shader.fs diff --git a/src/graphic/Fast3D/shaders/opengl/default.shader.vs b/src/fast/shaders/opengl/default.shader.vs similarity index 100% rename from src/graphic/Fast3D/shaders/opengl/default.shader.vs rename to src/fast/shaders/opengl/default.shader.vs diff --git a/src/graphic/Fast3D/.gitrepo b/src/graphic/Fast3D/.gitrepo deleted file mode 100644 index c588332..0000000 --- a/src/graphic/Fast3D/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/Emill/n64-fast3d-engine - branch = master - commit = 7353aa30570682ef3bfe31cffc115f1561163270 - parent = 36d578a78dff501c380e24b2c41fda62c173ea20 - method = merge - cmdver = 0.4.3 diff --git a/src/libultraship/CMakeLists.txt b/src/libultraship/CMakeLists.txt new file mode 100644 index 0000000..38ab3fb --- /dev/null +++ b/src/libultraship/CMakeLists.txt @@ -0,0 +1,48 @@ +#=================== Controller =================== + +file(GLOB_RECURSE Source_Files__Controller RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "controller/*.cpp") + +source_group("controller" FILES ${Source_Files__Controller}) +target_sources(libultraship PRIVATE ${Source_Files__Controller}) + +#=================== Bridge =================== + +source_group("bridge") + +file(GLOB Source_Files__Bridge RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "bridge/*.cpp") + +source_group("bridge" FILES ${Source_Files__Bridge}) + +target_sources(libultraship PRIVATE ${Source_Files__Bridge}) + +#=================== libultra =================== + +source_group("libultra") + +file(GLOB Source_Files__Libultra RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "libultra/*.cpp") + +source_group("libultra" FILES ${Source_Files__Libultra}) + +target_sources(libultraship PRIVATE ${Source_Files__Libultra}) + +#=================== Log =================== + +file(GLOB Source_Files__Log RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "log/*.cpp") + +source_group("log" FILES ${Source_Files__Log}) + +target_sources(libultraship PRIVATE ${Source_Files__Log}) + +#=================== Window =================== + +file(GLOB Source_Files__Window RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/*.cpp") + +source_group("window" FILES ${Source_Files__Window}) +target_sources(libultraship PRIVATE ${Source_Files__Window}) + +#=================== Gui =================== + +file(GLOB_RECURSE Source_Files__Window__Gui RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/gui/*.cpp") + +source_group("window/gui" FILES ${Source_Files__Window__Gui}) +target_sources(libultraship PRIVATE ${Source_Files__Window__Gui}) diff --git a/src/public/bridge/audiobridge.cpp b/src/libultraship/bridge/audiobridge.cpp similarity index 92% rename from src/public/bridge/audiobridge.cpp rename to src/libultraship/bridge/audiobridge.cpp index c256f10..bfe60a3 100644 --- a/src/public/bridge/audiobridge.cpp +++ b/src/libultraship/bridge/audiobridge.cpp @@ -1,6 +1,6 @@ -#include "public/bridge/audiobridge.h" -#include "Context.h" -#include "audio/Audio.h" +#include "libultraship/bridge/audiobridge.h" +#include "ship/Context.h" +#include "ship/audio/Audio.h" extern "C" { diff --git a/src/public/bridge/consolevariablebridge.cpp b/src/libultraship/bridge/consolevariablebridge.cpp similarity index 97% rename from src/public/bridge/consolevariablebridge.cpp rename to src/libultraship/bridge/consolevariablebridge.cpp index c635ccd..c4d97e9 100644 --- a/src/public/bridge/consolevariablebridge.cpp +++ b/src/libultraship/bridge/consolevariablebridge.cpp @@ -1,5 +1,5 @@ -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" +#include "libultraship/bridge/consolevariablebridge.h" +#include "ship/Context.h" std::shared_ptr CVarGet(const char* name) { return Ship::Context::GetInstance()->GetConsoleVariables()->Get(name); diff --git a/src/public/bridge/controllerbridge.cpp b/src/libultraship/bridge/controllerbridge.cpp similarity index 72% rename from src/public/bridge/controllerbridge.cpp rename to src/libultraship/bridge/controllerbridge.cpp index 95843d5..3d3a2af 100644 --- a/src/public/bridge/controllerbridge.cpp +++ b/src/libultraship/bridge/controllerbridge.cpp @@ -1,6 +1,6 @@ -#include "public/bridge/controllerbridge.h" -#include "controller/controldeck/ControlDeck.h" -#include "Context.h" +#include "libultraship/bridge/controllerbridge.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/Context.h" extern "C" { diff --git a/src/public/bridge/crashhandlerbridge.cpp b/src/libultraship/bridge/crashhandlerbridge.cpp similarity index 56% rename from src/public/bridge/crashhandlerbridge.cpp rename to src/libultraship/bridge/crashhandlerbridge.cpp index 6194585..03fe13f 100644 --- a/src/public/bridge/crashhandlerbridge.cpp +++ b/src/libultraship/bridge/crashhandlerbridge.cpp @@ -1,6 +1,6 @@ -#include "crashhandlerbridge.h" -#include "Context.h" -#include "debug/CrashHandler.h" +#include "libultraship/bridge/crashhandlerbridge.h" +#include "ship/Context.h" +#include "ship/debug/CrashHandler.h" void CrashHandlerRegisterCallback(CrashHandlerCallback callback) { Ship::Context::GetInstance()->GetCrashHandler()->RegisterCallback(callback); diff --git a/src/public/bridge/gfxbridge.cpp b/src/libultraship/bridge/gfxbridge.cpp similarity index 88% rename from src/public/bridge/gfxbridge.cpp rename to src/libultraship/bridge/gfxbridge.cpp index 79355b1..195732a 100644 --- a/src/public/bridge/gfxbridge.cpp +++ b/src/libultraship/bridge/gfxbridge.cpp @@ -1,8 +1,8 @@ -#include "gfxbridge.h" +#include "libultraship/bridge/gfxbridge.h" -#include "Context.h" -#include "graphic/Fast3D/Fast3dWindow.h" -#include "graphic/Fast3D/interpreter.h" +#include "ship/Context.h" +#include "fast/Fast3dWindow.h" +#include "fast/interpreter.h" // Set the dimensions for the VI mode that the console would be using // (Usually 320x240 for lo-res and 640x480 for hi-res) diff --git a/src/public/bridge/gfxdebuggerbridge.cpp b/src/libultraship/bridge/gfxdebuggerbridge.cpp similarity index 81% rename from src/public/bridge/gfxdebuggerbridge.cpp rename to src/libultraship/bridge/gfxdebuggerbridge.cpp index e490940..47b3b9d 100644 --- a/src/public/bridge/gfxdebuggerbridge.cpp +++ b/src/libultraship/bridge/gfxdebuggerbridge.cpp @@ -1,6 +1,6 @@ -#include "gfxdebuggerbridge.h" -#include "Context.h" -#include "graphic/Fast3D/debug/GfxDebugger.h" +#include "libultraship/bridge/gfxdebuggerbridge.h" +#include "ship/Context.h" +#include "fast/debug/GfxDebugger.h" void GfxDebuggerRequestDebugging() { Ship::Context::GetInstance()->GetGfxDebugger()->RequestDebugging(); diff --git a/src/public/bridge/resourcebridge.cpp b/src/libultraship/bridge/resourcebridge.cpp similarity index 97% rename from src/public/bridge/resourcebridge.cpp rename to src/libultraship/bridge/resourcebridge.cpp index 4fa914a..a70e2da 100644 --- a/src/public/bridge/resourcebridge.cpp +++ b/src/libultraship/bridge/resourcebridge.cpp @@ -1,9 +1,9 @@ -#include "public/bridge/resourcebridge.h" -#include "Context.h" +#include "libultraship/bridge/resourcebridge.h" +#include "ship/Context.h" #include #include -#include "utils/StrHash64.h" -#include "window/Window.h" +#include "ship/utils/StrHash64.h" +#include "ship/window/Window.h" std::shared_ptr ResourceLoad(const char* name) { return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(name); diff --git a/src/public/bridge/windowbridge.cpp b/src/libultraship/bridge/windowbridge.cpp similarity index 87% rename from src/public/bridge/windowbridge.cpp rename to src/libultraship/bridge/windowbridge.cpp index ef2bab4..bfa5e7e 100644 --- a/src/public/bridge/windowbridge.cpp +++ b/src/libultraship/bridge/windowbridge.cpp @@ -1,6 +1,6 @@ -#include "public/bridge/windowbridge.h" -#include "window/Window.h" -#include "Context.h" +#include "libultraship/bridge/windowbridge.h" +#include "ship/window/Window.h" +#include "ship/Context.h" extern "C" { diff --git a/src/libultraship/controller/controldeck/ControlDeck.cpp b/src/libultraship/controller/controldeck/ControlDeck.cpp new file mode 100644 index 0000000..fe5ad48 --- /dev/null +++ b/src/libultraship/controller/controldeck/ControlDeck.cpp @@ -0,0 +1,52 @@ +#include "libultraship/controller/controldeck/ControlDeck.h" + +#include "ship/Context.h" +#include "libultraship/controller/controldevice/controller/Controller.h" +#include "ship/utils/StringHelper.h" +// #include "ship/public/bridge/consolevariablebridge.h" +#include +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" + +namespace LUS { +ControlDeck::ControlDeck(std::vector additionalBitmasks, + std::shared_ptr controllerDefaultMappings) + : Ship::ControlDeck(additionalBitmasks, controllerDefaultMappings), mPads(nullptr) { + for (int32_t i = 0; i < MAXCONTROLLERS; i++) { + mPorts.push_back(std::make_shared(i, std::make_shared(i, additionalBitmasks))); + } +} + +ControlDeck::ControlDeck(std::vector additionalBitmasks) + : ControlDeck(additionalBitmasks, nullptr) { +} + +ControlDeck::ControlDeck() : ControlDeck(std::vector()) { +} + +OSContPad* ControlDeck::GetPads() { + return mPads; +} + +void ControlDeck::WriteToPad(void* pad) { + WriteToOSContPad((OSContPad*)pad); +} + +void ControlDeck::WriteToOSContPad(OSContPad* pad) { + SDL_PumpEvents(); + Ship::WheelHandler::GetInstance()->Update(); + + if (AllGameInputBlocked()) { + return; + } + + mPads = pad; + + for (size_t i = 0; i < mPorts.size(); i++) { + const std::shared_ptr controller = mPorts[i]->GetConnectedController(); + + if (controller != nullptr) { + controller->ReadToPad(&pad[i]); + } + } +} +} // namespace LUS diff --git a/src/libultraship/controller/controldevice/controller/Controller.cpp b/src/libultraship/controller/controldevice/controller/Controller.cpp new file mode 100644 index 0000000..9388b2a --- /dev/null +++ b/src/libultraship/controller/controldevice/controller/Controller.cpp @@ -0,0 +1,78 @@ +#include "libultraship/controller/controldevice/controller/Controller.h" +#include +#include +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#if __APPLE__ +#include +#else +#include +#endif +#include +#include "ship/utils/StringHelper.h" + +#define M_TAU 6.2831853071795864769252867665590057 // 2 * pi +#define MINIMUM_RADIUS_TO_MAP_NOTCH 0.9 + +namespace LUS { +Controller::Controller(uint8_t portIndex, std::vector additionalBitmasks) + : Ship::Controller(portIndex, additionalBitmasks) { +} + +Controller::Controller(uint8_t portIndex) : Ship::Controller(portIndex, {}) { +} + +void Controller::ReadToPad(void* pad) { + ReadToOSContPad((OSContPad*)pad); +} + +void Controller::ReadToOSContPad(OSContPad* pad) { + OSContPad padToBuffer = { 0 }; + + // Button Inputs + for (auto [bitmask, button] : mButtons) { + button->UpdatePad(padToBuffer.button); + } + + // Stick Inputs + GetLeftStick()->UpdatePad(padToBuffer.stick_x, padToBuffer.stick_y); + GetRightStick()->UpdatePad(padToBuffer.right_stick_x, padToBuffer.right_stick_y); + + // Gyro + GetGyro()->UpdatePad(padToBuffer.gyro_x, padToBuffer.gyro_y); + + mPadBuffer.push_front(padToBuffer); + if (pad != nullptr) { + auto& padFromBuffer = mPadBuffer[std::min( + mPadBuffer.size() - 1, + (size_t)Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_SIMULATED_INPUT_LAG, 0))]; + + pad->button |= padFromBuffer.button; + + if (pad->stick_x == 0) { + pad->stick_x = padFromBuffer.stick_x; + } + if (pad->stick_y == 0) { + pad->stick_y = padFromBuffer.stick_y; + } + + if (pad->right_stick_x == 0) { + pad->right_stick_x = padFromBuffer.right_stick_x; + } + if (pad->right_stick_y == 0) { + pad->right_stick_y = padFromBuffer.right_stick_y; + } + + if (pad->gyro_x == 0) { + pad->gyro_x = padFromBuffer.gyro_x; + } + if (pad->gyro_y == 0) { + pad->gyro_y = padFromBuffer.gyro_y; + } + } + + while (mPadBuffer.size() > 6) { + mPadBuffer.pop_back(); + } +} +} // namespace LUS diff --git a/src/public/libultra/os.cpp b/src/libultraship/libultra/os.cpp similarity index 100% rename from src/public/libultra/os.cpp rename to src/libultraship/libultra/os.cpp diff --git a/src/public/libultra/os_cache.cpp b/src/libultraship/libultra/os_cache.cpp similarity index 100% rename from src/public/libultra/os_cache.cpp rename to src/libultraship/libultra/os_cache.cpp diff --git a/src/public/libultra/os_eeprom.cpp b/src/libultraship/libultra/os_eeprom.cpp similarity index 100% rename from src/public/libultra/os_eeprom.cpp rename to src/libultraship/libultra/os_eeprom.cpp diff --git a/src/public/libultra/os_mesg.cpp b/src/libultraship/libultra/os_mesg.cpp similarity index 100% rename from src/public/libultra/os_mesg.cpp rename to src/libultraship/libultra/os_mesg.cpp diff --git a/src/public/libultra/os_pi.cpp b/src/libultraship/libultra/os_pi.cpp similarity index 100% rename from src/public/libultra/os_pi.cpp rename to src/libultraship/libultra/os_pi.cpp diff --git a/src/public/libultra/os_time.cpp b/src/libultraship/libultra/os_time.cpp similarity index 100% rename from src/public/libultra/os_time.cpp rename to src/libultraship/libultra/os_time.cpp diff --git a/src/public/libultra/os_vi.cpp b/src/libultraship/libultra/os_vi.cpp similarity index 100% rename from src/public/libultra/os_vi.cpp rename to src/libultraship/libultra/os_vi.cpp diff --git a/src/public/libultra/os_vm.cpp b/src/libultraship/libultra/os_vm.cpp similarity index 100% rename from src/public/libultra/os_vm.cpp rename to src/libultraship/libultra/os_vm.cpp diff --git a/src/log/luslog.cpp b/src/libultraship/log/luslog.cpp similarity index 94% rename from src/log/luslog.cpp rename to src/libultraship/log/luslog.cpp index 358eaff..b684c5f 100644 --- a/src/log/luslog.cpp +++ b/src/libultraship/log/luslog.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "log/luslog.h" +#include "libultraship/log/luslog.h" extern "C" { void luslog(const char* file, int32_t line, int32_t logLevel, const char* msg) { diff --git a/src/window/gui/GfxDebuggerWindow.cpp b/src/libultraship/window/gui/GfxDebuggerWindow.cpp similarity index 99% rename from src/window/gui/GfxDebuggerWindow.cpp rename to src/libultraship/window/gui/GfxDebuggerWindow.cpp index 9bcce83..6849ed7 100644 --- a/src/window/gui/GfxDebuggerWindow.cpp +++ b/src/libultraship/window/gui/GfxDebuggerWindow.cpp @@ -1,13 +1,13 @@ -#include "GfxDebuggerWindow.h" +#include "libultraship/window/gui/GfxDebuggerWindow.h" #include #include -#include "Context.h" -#include "graphic/Fast3D/debug/GfxDebugger.h" +#include "ship/Context.h" +#include "fast/debug/GfxDebugger.h" #include #include #include "libultraship/bridge.h" -#include -#include +#include "fast/interpreter.h" +#include "fast/Fast3dWindow.h" #include #ifdef GFX_DEBUG_DISASSEMBLER #include diff --git a/src/ship/CMakeLists.txt b/src/ship/CMakeLists.txt new file mode 100644 index 0000000..b68f221 --- /dev/null +++ b/src/ship/CMakeLists.txt @@ -0,0 +1,94 @@ +#=================== Top-Level =================== + +file(GLOB Source_Files__TopLevel RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") + +source_group("" FILES ${Source_Files__TopLevel}) +target_sources(libultraship PRIVATE ${Source_Files__TopLevel}) + +#=================== Audio =================== + +file(GLOB Source_Files__Audio RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "audio/*.cpp") + +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + list(FILTER Source_Files__Audio EXCLUDE REGEX "audio/WasapiAudioPlayer.*") +endif() + +source_group("audio" FILES ${Source_Files__Audio}) +target_sources(libultraship PRIVATE ${Source_Files__Audio}) + +#=================== Controller =================== + +file(GLOB_RECURSE Source_Files__Controller RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "controller/*.cpp") + +source_group("controller" FILES ${Source_Files__Controller}) +target_sources(libultraship PRIVATE ${Source_Files__Controller}) + +#=================== Config =================== + +file(GLOB Source_Files__Config RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "config/*.cpp") + +source_group("config" FILES ${Source_Files__Config}) +target_sources(libultraship PRIVATE ${Source_Files__Config}) + +#=================== Debug =================== + +file(GLOB Source_Files__Debug RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "debug/*.cpp") + +source_group("debug" FILES ${Source_Files__Debug}) +target_sources(libultraship PRIVATE ${Source_Files__Debug}) + +#=================== Window =================== + +file(GLOB Source_Files__Window RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/*.cpp") + +source_group("window" FILES ${Source_Files__Window}) +target_sources(libultraship PRIVATE ${Source_Files__Window}) + +#=================== Gui =================== + +file(GLOB_RECURSE Source_Files__Window__Gui RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "window/gui/*.cpp") + +source_group("window/gui" FILES ${Source_Files__Window__Gui}) +target_sources(libultraship PRIVATE ${Source_Files__Window__Gui}) + +#=================== Utils =================== + +file(GLOB_RECURSE Source_Files__Utils RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "utils/*.cpp" "utils/*.c") + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(APPEND Source_Files__Utils ${CMAKE_CURRENT_SOURCE_DIR}/utils/AppleFolderManager.mm) +endif() + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND Source_Files__Utils ${CMAKE_CURRENT_SOURCE_DIR}/utils/macUtils.mm) +endif() + +source_group("utils" FILES ${Source_Files__Utils}) +target_sources(libultraship PRIVATE ${Source_Files__Utils}) + +#=================== Port =================== + +if (CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(Source_Files__Port + ${CMAKE_CURRENT_SOURCE_DIR}/port/mobile/MobileImpl.cpp + ) +endif() + +source_group("port" FILES ${Source_Files__Port}) +target_sources(libultraship PRIVATE ${Source_Files__Port}) + +#=================== Resource =================== + +file(GLOB Source_Files__Resource RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/*.cpp") +source_group("resource" FILES ${Source_Files__Resource}) + +file(GLOB Source_Files__Resource__Types RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/type/*.cpp") +source_group("resource/type" FILES ${Source_Files__Resource__Types}) + +file(GLOB Source_Files__Resource__Factories RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/factory/*.cpp") +source_group("resource/factory" FILES ${Source_Files__Resource__Factories}) + +file(GLOB Source_Files__Resource__Archive RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "resource/archive/*.cpp") +source_group("resource/archive" FILES ${Source_Files__Resource__Archive}) + +target_sources(libultraship PRIVATE ${Source_Files__Resource} ${Source_Files__Resource__Types} ${Source_Files__Resource__Factories} ${Source_Files__Resource__Archive}) diff --git a/src/Context.cpp b/src/ship/Context.cpp similarity index 97% rename from src/Context.cpp rename to src/ship/Context.cpp index 362e39b..70ae151 100644 --- a/src/Context.cpp +++ b/src/ship/Context.cpp @@ -1,15 +1,15 @@ -#include "Context.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/Context.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" #include #include #include #include -#include "install_config.h" -#include "graphic/Fast3D/debug/GfxDebugger.h" -#include "config/ConsoleVariable.h" -#include "controller/controldeck/ControlDeck.h" -#include "debug/CrashHandler.h" -#include "window/FileDropMgr.h" +#include "ship/install_config.h" +#include "fast/debug/GfxDebugger.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/debug/CrashHandler.h" +#include "ship/window/FileDropMgr.h" #ifdef _WIN32 #include @@ -19,7 +19,7 @@ #endif #ifdef __APPLE__ -#include "utils/AppleFolderManager.h" +#include "ship/utils/AppleFolderManager.h" #include #include #endif diff --git a/src/audio/Audio.cpp b/src/ship/audio/Audio.cpp similarity index 94% rename from src/audio/Audio.cpp rename to src/ship/audio/Audio.cpp index ed67056..febd53b 100644 --- a/src/audio/Audio.cpp +++ b/src/ship/audio/Audio.cpp @@ -1,7 +1,7 @@ -#include "Audio.h" +#include "ship/audio/Audio.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { diff --git a/src/audio/AudioPlayer.cpp b/src/ship/audio/AudioPlayer.cpp similarity index 96% rename from src/audio/AudioPlayer.cpp rename to src/ship/audio/AudioPlayer.cpp index af1c7b3..380878f 100644 --- a/src/audio/AudioPlayer.cpp +++ b/src/ship/audio/AudioPlayer.cpp @@ -1,4 +1,4 @@ -#include "AudioPlayer.h" +#include "ship/audio/AudioPlayer.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/audio/NullAudioPlayer.cpp b/src/ship/audio/NullAudioPlayer.cpp similarity index 88% rename from src/audio/NullAudioPlayer.cpp rename to src/ship/audio/NullAudioPlayer.cpp index be7f9aa..4aaf6b1 100644 --- a/src/audio/NullAudioPlayer.cpp +++ b/src/ship/audio/NullAudioPlayer.cpp @@ -1,4 +1,4 @@ -#include "NullAudioPlayer.h" +#include "ship/audio/NullAudioPlayer.h" #include namespace Ship { diff --git a/src/audio/SDLAudioPlayer.cpp b/src/ship/audio/SDLAudioPlayer.cpp similarity index 96% rename from src/audio/SDLAudioPlayer.cpp rename to src/ship/audio/SDLAudioPlayer.cpp index fce0c4a..c74c884 100644 --- a/src/audio/SDLAudioPlayer.cpp +++ b/src/ship/audio/SDLAudioPlayer.cpp @@ -1,4 +1,4 @@ -#include "SDLAudioPlayer.h" +#include "ship/audio/SDLAudioPlayer.h" #include namespace Ship { diff --git a/src/audio/WasapiAudioPlayer.cpp b/src/ship/audio/WasapiAudioPlayer.cpp similarity index 99% rename from src/audio/WasapiAudioPlayer.cpp rename to src/ship/audio/WasapiAudioPlayer.cpp index 28399a6..81a7ee9 100644 --- a/src/audio/WasapiAudioPlayer.cpp +++ b/src/ship/audio/WasapiAudioPlayer.cpp @@ -1,5 +1,5 @@ #ifdef _WIN32 -#include "WasapiAudioPlayer.h" +#include "ship/audio/WasapiAudioPlayer.h" #include // These constants are currently missing from the MinGW headers. diff --git a/src/config/Config.cpp b/src/ship/config/Config.cpp similarity index 98% rename from src/config/Config.cpp rename to src/ship/config/Config.cpp index 4ff5b9e..654113e 100644 --- a/src/config/Config.cpp +++ b/src/ship/config/Config.cpp @@ -1,15 +1,15 @@ -#include "Config.h" +#include "ship/config/Config.h" #include #include #include #include #include -#include "utils/StringHelper.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" #ifdef __APPLE__ -#include "graphic/Fast3D/backends/gfx_metal.h" +#include "fast/backends/gfx_metal.h" #endif namespace fs = std::filesystem; diff --git a/src/config/ConsoleVariable.cpp b/src/ship/config/ConsoleVariable.cpp similarity index 98% rename from src/config/ConsoleVariable.cpp rename to src/ship/config/ConsoleVariable.cpp index 530ac55..9b97138 100644 --- a/src/config/ConsoleVariable.cpp +++ b/src/ship/config/ConsoleVariable.cpp @@ -1,10 +1,10 @@ -#include "ConsoleVariable.h" +#include "ship/config/ConsoleVariable.h" #include -#include "utils/filesystemtools/DiskFile.h" -#include -#include "config/Config.h" -#include "Context.h" +#include "ship/utils/filesystemtools/DiskFile.h" +#include "ship/utils/Utils.h" +#include "ship/config/Config.h" +#include "ship/Context.h" #ifdef _MSC_VER #define strdup _strdup diff --git a/src/controller/controldeck/ControlDeck.cpp b/src/ship/controller/controldeck/ControlDeck.cpp similarity index 69% rename from src/controller/controldeck/ControlDeck.cpp rename to src/ship/controller/controldeck/ControlDeck.cpp index 6d44df4..85617b3 100644 --- a/src/controller/controldeck/ControlDeck.cpp +++ b/src/ship/controller/controldeck/ControlDeck.cpp @@ -1,11 +1,11 @@ -#include "ControlDeck.h" +#include "ship/controller/controldeck/ControlDeck.h" -#include "Context.h" -#include "controller/controldevice/controller/Controller.h" -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" +#include "ship/Context.h" +#include "ship/controller/controldevice/controller/Controller.h" +#include "ship/utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" #include -#include "controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" namespace Ship { @@ -71,8 +71,9 @@ bool ControlDeck::AllGameInputBlocked() { bool ControlDeck::GamepadGameInputBlocked() { // block controller input when using the controller to navigate imgui menus - return AllGameInputBlocked() || Context::GetInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible() && - CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0); + return AllGameInputBlocked() || + Context::GetInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible() && + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0); } bool ControlDeck::KeyboardGameInputBlocked() { @@ -118,47 +119,3 @@ std::shared_ptr ControlDeck::GetControllerDefaultMapp return mControllerDefaultMappings; } } // namespace Ship - -namespace LUS { -ControlDeck::ControlDeck(std::vector additionalBitmasks, - std::shared_ptr controllerDefaultMappings) - : Ship::ControlDeck(additionalBitmasks, controllerDefaultMappings), mPads(nullptr) { - for (int32_t i = 0; i < MAXCONTROLLERS; i++) { - mPorts.push_back(std::make_shared(i, std::make_shared(i, additionalBitmasks))); - } -} - -ControlDeck::ControlDeck(std::vector additionalBitmasks) - : ControlDeck(additionalBitmasks, nullptr) { -} - -ControlDeck::ControlDeck() : ControlDeck(std::vector()) { -} - -OSContPad* ControlDeck::GetPads() { - return mPads; -} - -void ControlDeck::WriteToPad(void* pad) { - WriteToOSContPad((OSContPad*)pad); -} - -void ControlDeck::WriteToOSContPad(OSContPad* pad) { - SDL_PumpEvents(); - Ship::WheelHandler::GetInstance()->Update(); - - if (AllGameInputBlocked()) { - return; - } - - mPads = pad; - - for (size_t i = 0; i < mPorts.size(); i++) { - const std::shared_ptr controller = mPorts[i]->GetConnectedController(); - - if (controller != nullptr) { - controller->ReadToPad(&pad[i]); - } - } -} -} // namespace LUS diff --git a/src/controller/controldeck/ControlPort.cpp b/src/ship/controller/controldeck/ControlPort.cpp similarity index 92% rename from src/controller/controldeck/ControlPort.cpp rename to src/ship/controller/controldeck/ControlPort.cpp index ac34045..8c0fd41 100644 --- a/src/controller/controldeck/ControlPort.cpp +++ b/src/ship/controller/controldeck/ControlPort.cpp @@ -1,4 +1,4 @@ -#include "ControlPort.h" +#include "ship/controller/controldeck/ControlPort.h" namespace Ship { ControlPort::ControlPort(uint8_t portIndex) : mPortIndex(portIndex), mDevice(nullptr) { diff --git a/src/controller/controldevice/ControlDevice.cpp b/src/ship/controller/controldevice/ControlDevice.cpp similarity index 72% rename from src/controller/controldevice/ControlDevice.cpp rename to src/ship/controller/controldevice/ControlDevice.cpp index d01f9ac..ec7c31b 100644 --- a/src/controller/controldevice/ControlDevice.cpp +++ b/src/ship/controller/controldevice/ControlDevice.cpp @@ -1,4 +1,4 @@ -#include "ControlDevice.h" +#include "ship/controller/controldevice/ControlDevice.h" namespace Ship { ControlDevice::ControlDevice(uint8_t portIndex) : mPortIndex(portIndex) { diff --git a/src/controller/controldevice/controller/Controller.cpp b/src/ship/controller/controldevice/controller/Controller.cpp similarity index 76% rename from src/controller/controldevice/controller/Controller.cpp rename to src/ship/controller/controldevice/controller/Controller.cpp index b471881..558e369 100644 --- a/src/controller/controldevice/controller/Controller.cpp +++ b/src/ship/controller/controldevice/controller/Controller.cpp @@ -1,14 +1,15 @@ -#include "controller/controldevice/controller/Controller.h" +#include "ship/controller/controldevice/controller/Controller.h" #include #include -#include "public/bridge/consolevariablebridge.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" #if __APPLE__ #include #else #include #endif #include -#include "utils/StringHelper.h" +#include "ship/utils/StringHelper.h" #define M_TAU 6.2831853071795864769252867665590057 // 2 * pi #define MINIMUM_RADIUS_TO_MAP_NOTCH 0.9 @@ -72,7 +73,7 @@ uint8_t Controller::GetPortIndex() { bool Controller::HasConfig() { const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - return CVarGetInteger(hasConfigCvarKey.c_str(), false); + return Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(hasConfigCvarKey.c_str(), false); } void Controller::ClearAllMappings() { @@ -112,8 +113,8 @@ void Controller::AddDefaultMappings(PhysicalDeviceType physicalDeviceType) { const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void Controller::ReloadAllMappingsFromConfig() { @@ -205,65 +206,3 @@ std::vector> Controller::GetAllMappings() { return allMappings; } } // namespace Ship - -namespace LUS { -Controller::Controller(uint8_t portIndex, std::vector additionalBitmasks) - : Ship::Controller(portIndex, additionalBitmasks) { -} - -Controller::Controller(uint8_t portIndex) : Ship::Controller(portIndex, {}) { -} - -void Controller::ReadToPad(void* pad) { - ReadToOSContPad((OSContPad*)pad); -} - -void Controller::ReadToOSContPad(OSContPad* pad) { - OSContPad padToBuffer = { 0 }; - - // Button Inputs - for (auto [bitmask, button] : mButtons) { - button->UpdatePad(padToBuffer.button); - } - - // Stick Inputs - GetLeftStick()->UpdatePad(padToBuffer.stick_x, padToBuffer.stick_y); - GetRightStick()->UpdatePad(padToBuffer.right_stick_x, padToBuffer.right_stick_y); - - // Gyro - GetGyro()->UpdatePad(padToBuffer.gyro_x, padToBuffer.gyro_y); - - mPadBuffer.push_front(padToBuffer); - if (pad != nullptr) { - auto& padFromBuffer = - mPadBuffer[std::min(mPadBuffer.size() - 1, (size_t)CVarGetInteger(CVAR_SIMULATED_INPUT_LAG, 0))]; - - pad->button |= padFromBuffer.button; - - if (pad->stick_x == 0) { - pad->stick_x = padFromBuffer.stick_x; - } - if (pad->stick_y == 0) { - pad->stick_y = padFromBuffer.stick_y; - } - - if (pad->right_stick_x == 0) { - pad->right_stick_x = padFromBuffer.right_stick_x; - } - if (pad->right_stick_y == 0) { - pad->right_stick_y = padFromBuffer.right_stick_y; - } - - if (pad->gyro_x == 0) { - pad->gyro_x = padFromBuffer.gyro_x; - } - if (pad->gyro_y == 0) { - pad->gyro_y = padFromBuffer.gyro_y; - } - } - - while (mPadBuffer.size() > 6) { - mPadBuffer.pop_back(); - } -} -} // namespace LUS diff --git a/src/controller/controldevice/controller/ControllerButton.cpp b/src/ship/controller/controldevice/controller/ControllerButton.cpp similarity index 88% rename from src/controller/controldevice/controller/ControllerButton.cpp rename to src/ship/controller/controldevice/controller/ControllerButton.cpp index e24c688..0a72ba8 100644 --- a/src/controller/controldevice/controller/ControllerButton.cpp +++ b/src/ship/controller/controldevice/controller/ControllerButton.cpp @@ -1,17 +1,17 @@ -#include "ControllerButton.h" +#include "ship/controller/controldevice/controller/ControllerButton.h" -#include "controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include #include -#include "Context.h" -#include "window/Window.h" +#include "ship/Context.h" +#include "ship/window/Window.h" namespace Ship { ControllerButton::ControllerButton(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask) @@ -113,12 +113,13 @@ void ControllerButton::SaveButtonMappingIdsToConfig() { StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str()); if (buttonMappingIdListString == "") { - CVarClear(buttonMappingIdsCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(buttonMappingIdsCvarKey.c_str()); } else { - CVarSetString(buttonMappingIdsCvarKey.c_str(), buttonMappingIdListString.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(buttonMappingIdsCvarKey.c_str(), + buttonMappingIdListString.c_str()); } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerButton::ReloadAllMappingsFromConfig() { @@ -132,7 +133,8 @@ void ControllerButton::ReloadAllMappingsFromConfig() { const std::string buttonMappingIdsCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Buttons.%sButtonMappingIds", mPortIndex + 1, GetConfigNameFromBitmask(mBitmask).c_str()); - std::stringstream buttonMappingIdsStringStream(CVarGetString(buttonMappingIdsCvarKey.c_str(), "")); + std::stringstream buttonMappingIdsStringStream( + Ship::Context::GetInstance()->GetConsoleVariables()->GetString(buttonMappingIdsCvarKey.c_str(), "")); std::string buttonMappingIdString; while (getline(buttonMappingIdsStringStream, buttonMappingIdString, ',')) { LoadButtonMappingFromConfig(buttonMappingIdString); @@ -215,8 +217,8 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi SaveButtonMappingIdsToConfig(); const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return true; } diff --git a/src/controller/controldevice/controller/ControllerGyro.cpp b/src/ship/controller/controldevice/controller/ControllerGyro.cpp similarity index 69% rename from src/controller/controldevice/controller/ControllerGyro.cpp rename to src/ship/controller/controldevice/controller/ControllerGyro.cpp index bf645af..634dc72 100644 --- a/src/controller/controldevice/controller/ControllerGyro.cpp +++ b/src/ship/controller/controldevice/controller/ControllerGyro.cpp @@ -1,8 +1,9 @@ -#include "ControllerGyro.h" +#include "ship/controller/controldevice/controller/ControllerGyro.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" -#include "controller/controldevice/controller/mapping/factories/GyroMappingFactory.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" +#include "ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h" namespace Ship { ControllerGyro::ControllerGyro(uint8_t portIndex) : mPortIndex(portIndex) { @@ -33,8 +34,8 @@ bool ControllerGyro::SetGyroMappingFromRawPress() { SaveGyroMappingIdToConfig(); const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return true; } @@ -51,12 +52,13 @@ void ControllerGyro::SaveGyroMappingIdToConfig() { StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1); if (mGyroMapping == nullptr) { - CVarClear(gyroMappingIdCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(gyroMappingIdCvarKey.c_str()); } else { - CVarSetString(gyroMappingIdCvarKey.c_str(), mGyroMapping->GetGyroMappingId().c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(gyroMappingIdCvarKey.c_str(), + mGyroMapping->GetGyroMappingId().c_str()); } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerGyro::ClearGyroMapping() { @@ -73,7 +75,7 @@ void ControllerGyro::ReloadGyroMappingFromConfig() { const std::string gyroMappingIdCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.Gyro.GyroMappingId", mPortIndex + 1); - std::string id = CVarGetString(gyroMappingIdCvarKey.c_str(), ""); + std::string id = Ship::Context::GetInstance()->GetConsoleVariables()->GetString(gyroMappingIdCvarKey.c_str(), ""); if (id == "") { mGyroMapping = nullptr; return; diff --git a/src/controller/controldevice/controller/ControllerLED.cpp b/src/ship/controller/controldevice/controller/ControllerLED.cpp similarity index 80% rename from src/controller/controldevice/controller/ControllerLED.cpp rename to src/ship/controller/controldevice/controller/ControllerLED.cpp index 00ce3eb..6c66568 100644 --- a/src/controller/controldevice/controller/ControllerLED.cpp +++ b/src/ship/controller/controldevice/controller/ControllerLED.cpp @@ -1,11 +1,12 @@ -#include "ControllerLED.h" +#include "ship/controller/controldevice/controller/ControllerLED.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include #include -#include "controller/controldevice/controller/mapping/factories/LEDMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h" namespace Ship { ControllerLED::ControllerLED(uint8_t portIndex) : mPortIndex(portIndex) { @@ -31,12 +32,13 @@ void ControllerLED::SaveLEDMappingIdsToConfig() { const std::string ledMappingIdsCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1); if (ledMappingIdsCvarKey == "") { - CVarClear(ledMappingIdsCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(ledMappingIdsCvarKey.c_str()); } else { - CVarSetString(ledMappingIdsCvarKey.c_str(), ledMappingIdListString.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(ledMappingIdsCvarKey.c_str(), + ledMappingIdListString.c_str()); } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerLED::AddLEDMapping(std::shared_ptr mapping) { @@ -100,7 +102,8 @@ void ControllerLED::ReloadAllMappingsFromConfig() { // hardcoded or provided by an otr file const std::string ledMappingIdsCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.LEDMappingIds", mPortIndex + 1); - std::stringstream ledMappingIdsStringStream(CVarGetString(ledMappingIdsCvarKey.c_str(), "")); + std::stringstream ledMappingIdsStringStream( + Ship::Context::GetInstance()->GetConsoleVariables()->GetString(ledMappingIdsCvarKey.c_str(), "")); std::string ledMappingIdString; while (getline(ledMappingIdsStringStream, ledMappingIdString, ',')) { LoadLEDMappingFromConfig(ledMappingIdString); @@ -125,8 +128,8 @@ bool ControllerLED::AddLEDMappingFromRawPress() { SaveLEDMappingIdsToConfig(); const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return true; } diff --git a/src/controller/controldevice/controller/ControllerRumble.cpp b/src/ship/controller/controldevice/controller/ControllerRumble.cpp similarity index 82% rename from src/controller/controldevice/controller/ControllerRumble.cpp rename to src/ship/controller/controldevice/controller/ControllerRumble.cpp index e0c2089..f634f13 100644 --- a/src/controller/controldevice/controller/ControllerRumble.cpp +++ b/src/ship/controller/controldevice/controller/ControllerRumble.cpp @@ -1,10 +1,11 @@ -#include "ControllerRumble.h" +#include "ship/controller/controldevice/controller/ControllerRumble.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include -#include "controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h" namespace Ship { ControllerRumble::ControllerRumble(uint8_t portIndex) : mPortIndex(portIndex) { @@ -36,12 +37,13 @@ void ControllerRumble::SaveRumbleMappingIdsToConfig() { const std::string rumbleMappingIdsCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1); if (rumbleMappingIdListString == "") { - CVarClear(rumbleMappingIdsCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(rumbleMappingIdsCvarKey.c_str()); } else { - CVarSetString(rumbleMappingIdsCvarKey.c_str(), rumbleMappingIdListString.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(rumbleMappingIdsCvarKey.c_str(), + rumbleMappingIdListString.c_str()); } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerRumble::AddRumbleMapping(std::shared_ptr mapping) { @@ -116,7 +118,8 @@ void ControllerRumble::ReloadAllMappingsFromConfig() { // hardcoded or provided by an otr file const std::string rumbleMappingIdsCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.RumbleMappingIds", mPortIndex + 1); - std::stringstream rumbleMappingIdsStringStream(CVarGetString(rumbleMappingIdsCvarKey.c_str(), "")); + std::stringstream rumbleMappingIdsStringStream( + Ship::Context::GetInstance()->GetConsoleVariables()->GetString(rumbleMappingIdsCvarKey.c_str(), "")); std::string rumbleMappingIdString; while (getline(rumbleMappingIdsStringStream, rumbleMappingIdString, ',')) { LoadRumbleMappingFromConfig(rumbleMappingIdString); @@ -141,8 +144,8 @@ bool ControllerRumble::AddRumbleMappingFromRawPress() { SaveRumbleMappingIdsToConfig(); const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return true; } diff --git a/src/controller/controldevice/controller/ControllerStick.cpp b/src/ship/controller/controldevice/controller/ControllerStick.cpp similarity index 82% rename from src/controller/controldevice/controller/ControllerStick.cpp rename to src/ship/controller/controldevice/controller/ControllerStick.cpp index 57e5494..adedfa2 100644 --- a/src/controller/controldevice/controller/ControllerStick.cpp +++ b/src/ship/controller/controldevice/controller/ControllerStick.cpp @@ -1,19 +1,19 @@ -#include "ControllerStick.h" +#include "ship/controller/controldevice/controller/ControllerStick.h" #include -#include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h" -#include "public/bridge/consolevariablebridge.h" +#include "ship/config/ConsoleVariable.h" -#include "utils/StringHelper.h" +#include "ship/utils/StringHelper.h" #include #include -#include "Context.h" -#include "window/Window.h" +#include "ship/Context.h" +#include "ship/window/Window.h" // for some reason windows isn't seeing M_PI // this is copied from my system's math.h @@ -95,13 +95,14 @@ void ControllerStick::SaveAxisDirectionMappingIdsToConfig() { CVAR_PREFIX_CONTROLLERS ".Port%d.%s.%sAxisDirectionMappingIds", mPortIndex + 1, stickIndexToConfigStickIndexName[mStickIndex].c_str(), directionToConfigDirectionName[direction].c_str()); if (axisDirectionMappingIdListString == "") { - CVarClear(axisDirectionMappingIdsCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(axisDirectionMappingIdsCvarKey.c_str()); } else { - CVarSetString(axisDirectionMappingIdsCvarKey.c_str(), axisDirectionMappingIdListString.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(axisDirectionMappingIdsCvarKey.c_str(), + axisDirectionMappingIdListString.c_str()); } } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerStick::ClearAxisDirectionMappingId(Direction direction, std::string id) { @@ -172,30 +173,30 @@ void ControllerStick::ReloadAllMappingsFromConfig() { stickIndexToConfigStickIndexName[mStickIndex].c_str(), directionToConfigDirectionName[direction].c_str()); std::stringstream axisDirectionMappingIdsStringStream( - CVarGetString(axisDirectionMappingIdsCvarKey.c_str(), "")); + Ship::Context::GetInstance()->GetConsoleVariables()->GetString(axisDirectionMappingIdsCvarKey.c_str(), "")); std::string axisDirectionMappingIdString; while (getline(axisDirectionMappingIdsStringStream, axisDirectionMappingIdString, ',')) { LoadAxisDirectionMappingFromConfig(axisDirectionMappingIdString); } } - SetSensitivity( - CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - DEFAULT_STICK_SENSITIVITY_PERCENTAGE)); + SetSensitivity(Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + DEFAULT_STICK_SENSITIVITY_PERCENTAGE)); - SetDeadzone( - CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - DEFAULT_STICK_DEADZONE_PERCENTAGE)); + SetDeadzone(Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + DEFAULT_STICK_DEADZONE_PERCENTAGE)); - SetNotchSnapAngle( - CVarGetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - 0)); + SetNotchSnapAngle(Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + 0)); } double ControllerStick::GetClosestNotch(double angle, double approximationThreshold) { @@ -310,8 +311,8 @@ bool ControllerStick::AddOrEditAxisDirectionMappingFromRawPress(Direction direct SaveAxisDirectionMappingIdsToConfig(); const std::string hasConfigCvarKey = StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.HasConfig", mPortIndex + 1); - CVarSetInteger(hasConfigCvarKey.c_str(), true); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(hasConfigCvarKey.c_str(), true); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return true; } @@ -386,11 +387,12 @@ bool ControllerStick::ProcessMouseButtonEvent(bool isPressed, MouseBtn button) { void ControllerStick::SetSensitivity(uint8_t sensitivityPercentage) { mSensitivityPercentage = sensitivityPercentage; mSensitivity = sensitivityPercentage / 100.0f; - CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - mSensitivityPercentage); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.SensitivityPercentage", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + mSensitivityPercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerStick::ResetSensitivityToDefault() { @@ -408,11 +410,12 @@ bool ControllerStick::SensitivityIsDefault() { void ControllerStick::SetDeadzone(uint8_t deadzonePercentage) { mDeadzonePercentage = deadzonePercentage; mDeadzone = MAX_AXIS_RANGE * (deadzonePercentage / 100.0f); - CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - mDeadzonePercentage); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.DeadzonePercentage", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + mDeadzonePercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerStick::ResetDeadzoneToDefault() { @@ -429,11 +432,12 @@ bool ControllerStick::DeadzoneIsDefault() { void ControllerStick::SetNotchSnapAngle(uint8_t notchSnapAngle) { mNotchSnapAngle = notchSnapAngle; - CVarSetInteger(StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1, - stickIndexToConfigStickIndexName[mStickIndex].c_str()) - .c_str(), - mNotchSnapAngle); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf(CVAR_PREFIX_CONTROLLERS ".Port%d.%s.NotchSnapAngle", mPortIndex + 1, + stickIndexToConfigStickIndexName[mStickIndex].c_str()) + .c_str(), + mNotchSnapAngle); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void ControllerStick::ResetNotchSnapAngleToDefault() { diff --git a/src/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp similarity index 89% rename from src/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp index 98caca5..24d1bb7 100644 --- a/src/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" #include #include diff --git a/src/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp similarity index 88% rename from src/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp index 0ccb6d5..b3a2c15 100644 --- a/src/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerButtonMapping.cpp @@ -1,10 +1,8 @@ -#include "ControllerButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerButtonMapping.h" #include #include -#include "public/bridge/consolevariablebridge.h" - namespace Ship { ControllerButtonMapping::ControllerButtonMapping(PhysicalDeviceType physicalDeviceType, uint8_t portIndex, CONTROLLERBUTTONS_T bitmask) diff --git a/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp similarity index 99% rename from src/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp index 986af55..35747b8 100644 --- a/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.cpp @@ -1,4 +1,4 @@ -#include "ControllerDefaultMappings.h" +#include "ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h" #include "libultraship/libultra/controller.h" namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp similarity index 92% rename from src/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp index 5a40ca0..40d7339 100644 --- a/src/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerGyroMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h" namespace Ship { ControllerGyroMapping::ControllerGyroMapping(PhysicalDeviceType physicalDeviceType, uint8_t portIndex, diff --git a/src/controller/controldevice/controller/mapping/ControllerInputMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerInputMapping.cpp similarity index 78% rename from src/controller/controldevice/controller/mapping/ControllerInputMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerInputMapping.cpp index 8169b1a..e18a08b 100644 --- a/src/controller/controldevice/controller/mapping/ControllerInputMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerInputMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerInputMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerInputMapping.h" namespace Ship { ControllerInputMapping::ControllerInputMapping(PhysicalDeviceType physicalDeviceType) diff --git a/src/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp similarity index 93% rename from src/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp index 8421afd..82fe3d2 100644 --- a/src/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerLEDMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerLEDMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerLEDMapping.h" namespace Ship { ControllerLEDMapping::ControllerLEDMapping(PhysicalDeviceType physicalDeviceType, uint8_t portIndex, diff --git a/src/controller/controldevice/controller/mapping/ControllerMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerMapping.cpp similarity index 82% rename from src/controller/controldevice/controller/mapping/ControllerMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerMapping.cpp index b7ff4a5..4fbb72a 100644 --- a/src/controller/controldevice/controller/mapping/ControllerMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerMapping.h" namespace Ship { ControllerMapping::ControllerMapping(PhysicalDeviceType physicalDeviceType) : mPhysicalDeviceType(physicalDeviceType) { diff --git a/src/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp b/src/ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp similarity index 95% rename from src/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp index aff4440..c037598 100644 --- a/src/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.cpp @@ -1,4 +1,4 @@ -#include "ControllerRumbleMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerRumbleMapping.h" namespace Ship { ControllerRumbleMapping::ControllerRumbleMapping(PhysicalDeviceType physicalDeviceType, uint8_t portIndex, diff --git a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp b/src/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp similarity index 64% rename from src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp rename to src/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp index 0cb7cef..8218801 100644 --- a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp +++ b/src/ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp @@ -1,40 +1,41 @@ -#include "AxisDirectionMappingFactory.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" -#include "Context.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" -#include "controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { std::shared_ptr AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIndex, StickIndex stickIndex, std::string id) { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + id; - const std::string mappingClass = - CVarGetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), ""); + const std::string mappingClass = Ship::Context::GetInstance()->GetConsoleVariables()->GetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), ""); if (mappingClass == "SDLAxisDirectionToAxisDirectionMapping") { - int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); - int32_t sdlControllerAxis = - CVarGetInteger(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), -1); - int32_t axisDirection = - CVarGetInteger(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), 0); + int32_t direction = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); + int32_t sdlControllerAxis = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), -1); + int32_t axisDirection = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), 0); if ((direction != LEFT && direction != RIGHT && direction != UP && direction != DOWN) || sdlControllerAxis == -1 || (axisDirection != NEGATIVE && axisDirection != POSITIVE)) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -43,15 +44,16 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn } if (mappingClass == "SDLButtonToAxisDirectionMapping") { - int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); - int32_t sdlControllerButton = - CVarGetInteger(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), -1); + int32_t direction = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); + int32_t sdlControllerButton = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), -1); if ((direction != LEFT && direction != RIGHT && direction != UP && direction != DOWN) || sdlControllerButton == -1) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -60,14 +62,15 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn } if (mappingClass == "KeyboardKeyToAxisDirectionMapping") { - int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); - int32_t scancode = - CVarGetInteger(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), 0); + int32_t direction = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); + int32_t scancode = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), 0); if (direction != LEFT && direction != RIGHT && direction != UP && direction != DOWN) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -76,13 +79,15 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn } if (mappingClass == "MouseButtonToAxisDirectionMapping") { - int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); - int mouseButton = CVarGetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); + int32_t direction = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); + int mouseButton = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); if (direction != LEFT && direction != RIGHT && direction != UP && direction != DOWN) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -91,14 +96,15 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn } if (mappingClass == "MouseWheelToAxisDirectionMapping") { - int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); - int wheelDirection = - CVarGetInteger(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), 0); + int32_t direction = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); + int wheelDirection = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), 0); if (direction != LEFT && direction != RIGHT && direction != UP && direction != DOWN) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } diff --git a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp b/src/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp similarity index 66% rename from src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp rename to src/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp index a27d1b1..2f92b36 100644 --- a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp +++ b/src/ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp @@ -1,40 +1,40 @@ -#include "ButtonMappingFactory.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include "libultraship/libultra/controller.h" -#include "Context.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h" -#include "controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h" -#include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" -#include "controller/controldevice/controller/mapping/mouse/WheelHandler.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/Context.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { std::shared_ptr ButtonMappingFactory::CreateButtonMappingFromConfig(uint8_t portIndex, std::string id) { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + id; - const std::string mappingClass = - CVarGetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), ""); - CONTROLLERBUTTONS_T bitmask = - CVarGetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), 0); + const std::string mappingClass = Ship::Context::GetInstance()->GetConsoleVariables()->GetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), ""); + CONTROLLERBUTTONS_T bitmask = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), 0); if (!bitmask) { // all button mappings need bitmasks - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } if (mappingClass == "SDLButtonToButtonMapping") { - int32_t sdlControllerButton = - CVarGetInteger(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), -1); + int32_t sdlControllerButton = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), -1); if (sdlControllerButton == -1) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -42,15 +42,15 @@ std::shared_ptr ButtonMappingFactory::CreateButtonMappi } if (mappingClass == "SDLAxisDirectionToButtonMapping") { - int32_t sdlControllerAxis = - CVarGetInteger(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), -1); - int32_t axisDirection = - CVarGetInteger(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), 0); + int32_t sdlControllerAxis = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), -1); + int32_t axisDirection = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), 0); if (sdlControllerAxis == -1 || (axisDirection != -1 && axisDirection != 1)) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } @@ -58,21 +58,22 @@ std::shared_ptr ButtonMappingFactory::CreateButtonMappi } if (mappingClass == "KeyboardKeyToButtonMapping") { - int32_t scancode = - CVarGetInteger(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), 0); + int32_t scancode = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), 0); return std::make_shared(portIndex, bitmask, static_cast(scancode)); } if (mappingClass == "MouseButtonToButtonMapping") { - int mouseButton = CVarGetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); + int mouseButton = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); return std::make_shared(portIndex, bitmask, static_cast(mouseButton)); } if (mappingClass == "MouseWheelToButtonMapping") { - int wheelDirection = - CVarGetInteger(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), 0); + int wheelDirection = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), 0); return std::make_shared(portIndex, bitmask, static_cast(wheelDirection)); diff --git a/src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp b/src/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp similarity index 62% rename from src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp rename to src/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp index 89b56b0..aafe075 100644 --- a/src/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp +++ b/src/ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.cpp @@ -1,31 +1,34 @@ -#include "GyroMappingFactory.h" -#include "controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/controller/controldevice/controller/mapping/factories/GyroMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include "libultraship/libultra/controller.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { std::shared_ptr GyroMappingFactory::CreateGyroMappingFromConfig(uint8_t portIndex, std::string id) { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + id; - const std::string mappingClass = - CVarGetString(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), ""); + const std::string mappingClass = Ship::Context::GetInstance()->GetConsoleVariables()->GetString( + StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), ""); - float sensitivity = CVarGetFloat(StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str(), 2.0f); + float sensitivity = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str(), 2.0f); if (sensitivity < 0.0f || sensitivity > 1.0f) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } if (mappingClass == "SDLGyroMapping") { - float neutralPitch = - CVarGetFloat(StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str(), 0.0f); - float neutralYaw = CVarGetFloat(StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), 0.0f); - float neutralRoll = CVarGetFloat(StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str(), 0.0f); + float neutralPitch = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str(), 0.0f); + float neutralYaw = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), 0.0f); + float neutralRoll = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str(), 0.0f); return std::make_shared(portIndex, sensitivity, neutralPitch, neutralYaw, neutralRoll); } diff --git a/src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp b/src/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp similarity index 67% rename from src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp rename to src/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp index 014a659..abb4f98 100644 --- a/src/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp +++ b/src/ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.cpp @@ -1,26 +1,27 @@ -#include "LEDMappingFactory.h" -#include "controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/controller/controldevice/controller/mapping/factories/LEDMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include "libultraship/libultra/controller.h" -#include "controller/controldeck/ControlDeck.h" -#include "Context.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/Context.h" namespace Ship { std::shared_ptr LEDMappingFactory::CreateLEDMappingFromConfig(uint8_t portIndex, std::string id) { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + id; - const std::string mappingClass = - CVarGetString(StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str(), ""); + const std::string mappingClass = Ship::Context::GetInstance()->GetConsoleVariables()->GetString( + StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str(), ""); - int32_t colorSource = CVarGetInteger(StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str(), -1); - Color_RGB8 savedColor = - CVarGetColor24(StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str(), { 0, 0, 0 }); + int32_t colorSource = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str(), -1); + Color_RGB8 savedColor = Ship::Context::GetInstance()->GetConsoleVariables()->GetColor24( + StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str(), { 0, 0, 0 }); if (colorSource != LED_COLOR_SOURCE_OFF && colorSource != LED_COLOR_SOURCE_SET && colorSource != LED_COLOR_SOURCE_GAME) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } diff --git a/src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp b/src/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp similarity index 73% rename from src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp rename to src/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp index 7bc0988..f702ba7 100644 --- a/src/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp +++ b/src/ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.cpp @@ -1,28 +1,28 @@ -#include "RumbleMappingFactory.h" -#include "controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" +#include "ship/controller/controldevice/controller/mapping/factories/RumbleMappingFactory.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" #include "libultraship/libultra/controller.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { std::shared_ptr RumbleMappingFactory::CreateRumbleMappingFromConfig(uint8_t portIndex, std::string id) { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + id; - const std::string mappingClass = - CVarGetString(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), ""); + const std::string mappingClass = Ship::Context::GetInstance()->GetConsoleVariables()->GetString( + StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), ""); - int32_t lowFrequencyIntensityPercentage = - CVarGetInteger(StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str(), -1); - int32_t highFrequencyIntensityPercentage = - CVarGetInteger(StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str(), -1); + int32_t lowFrequencyIntensityPercentage = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str(), -1); + int32_t highFrequencyIntensityPercentage = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str(), -1); if (lowFrequencyIntensityPercentage < 0 || lowFrequencyIntensityPercentage > 100 || highFrequencyIntensityPercentage < 0 || highFrequencyIntensityPercentage > 100) { // something about this mapping is invalid - CVarClear(mappingCvarKey.c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mappingCvarKey.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return nullptr; } diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp similarity index 81% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp index 1c1ddeb..c8cfb66 100644 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.cpp @@ -1,9 +1,9 @@ -#include "KeyboardKeyToAnyMapping.h" -#include "Context.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAnyMapping.h" +#include "ship/Context.h" -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "window/Window.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/window/Window.h" namespace Ship { KeyboardKeyToAnyMapping::KeyboardKeyToAnyMapping(KbScancode scancode) diff --git a/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp new file mode 100644 index 0000000..7f86d24 --- /dev/null +++ b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.cpp @@ -0,0 +1,66 @@ +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" +#include +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" + +namespace Ship { +KeyboardKeyToAxisDirectionMapping::KeyboardKeyToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, + Direction direction, KbScancode scancode) + : ControllerInputMapping(PhysicalDeviceType::Keyboard), KeyboardKeyToAnyMapping(scancode), + ControllerAxisDirectionMapping(PhysicalDeviceType::Keyboard, portIndex, stickIndex, direction) { +} + +float KeyboardKeyToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { + if (Context::GetInstance()->GetControlDeck()->KeyboardGameInputBlocked()) { + return 0.0f; + } + + return mKeyPressed ? MAX_AXIS_RANGE : 0.0f; +} + +std::string KeyboardKeyToAxisDirectionMapping::GetAxisDirectionMappingId() { + return StringHelper::Sprintf("P%d-S%d-D%d-KB%d", mPortIndex, mStickIndex, mDirection, mKeyboardScancode); +} + +void KeyboardKeyToAxisDirectionMapping::SaveToConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), + "KeyboardKeyToAxisDirectionMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), mKeyboardScancode); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +void KeyboardKeyToAxisDirectionMapping::EraseFromConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +int8_t KeyboardKeyToAxisDirectionMapping::GetMappingType() { + return MAPPING_TYPE_KEYBOARD; +} + +std::string KeyboardKeyToAxisDirectionMapping::GetPhysicalDeviceName() { + return KeyboardKeyToAnyMapping::GetPhysicalDeviceName(); +} + +std::string KeyboardKeyToAxisDirectionMapping::GetPhysicalInputName() { + return KeyboardKeyToAnyMapping::GetPhysicalInputName(); +} +} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp similarity index 52% rename from src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp index 8d28f05..6705991 100644 --- a/src/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.cpp @@ -1,9 +1,9 @@ -#include "KeyboardKeyToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" #include -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" -#include "controller/controldeck/ControlDeck.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/Context.h" namespace Ship { KeyboardKeyToButtonMapping::KeyboardKeyToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, @@ -34,21 +34,26 @@ std::string KeyboardKeyToButtonMapping::GetButtonMappingId() { void KeyboardKeyToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "KeyboardKeyToButtonMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); - CVarSetInteger(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), mKeyboardScancode); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "KeyboardKeyToButtonMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str(), mKeyboardScancode); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void KeyboardKeyToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.KeyboardScancode", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string KeyboardKeyToButtonMapping::GetPhysicalDeviceName() { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp similarity index 76% rename from src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp index 6a1fd2c..430ffea 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp @@ -1,8 +1,8 @@ -#include "MouseButtonToAnyMapping.h" -#include "Context.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h" +#include "ship/Context.h" -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" namespace Ship { MouseButtonToAnyMapping::MouseButtonToAnyMapping(MouseBtn button) diff --git a/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp new file mode 100644 index 0000000..50fa4b6 --- /dev/null +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp @@ -0,0 +1,66 @@ +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" +#include +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" + +namespace Ship { +MouseButtonToAxisDirectionMapping::MouseButtonToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, + Direction direction, MouseBtn button) + : ControllerInputMapping(PhysicalDeviceType::Mouse), MouseButtonToAnyMapping(button), + ControllerAxisDirectionMapping(PhysicalDeviceType::Mouse, portIndex, stickIndex, direction) { +} + +float MouseButtonToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { + if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { + return 0.0f; + } + + return mKeyPressed ? MAX_AXIS_RANGE : 0.0f; +} + +std::string MouseButtonToAxisDirectionMapping::GetAxisDirectionMappingId() { + return StringHelper::Sprintf("P%d-S%d-D%d-MOUSE%d", mPortIndex, mStickIndex, mDirection, mButton); +} + +void MouseButtonToAxisDirectionMapping::SaveToConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), + "MouseButtonToAxisDirectionMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +void MouseButtonToAxisDirectionMapping::EraseFromConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +int8_t MouseButtonToAxisDirectionMapping::GetMappingType() { + return MAPPING_TYPE_MOUSE; +} + +std::string MouseButtonToAxisDirectionMapping::GetPhysicalDeviceName() { + return MouseButtonToAnyMapping::GetPhysicalDeviceName(); +} + +std::string MouseButtonToAxisDirectionMapping::GetPhysicalInputName() { + return MouseButtonToAnyMapping::GetPhysicalInputName(); +} +} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp similarity index 51% rename from src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp index f8bafe5..849a25d 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp @@ -1,9 +1,9 @@ -#include "MouseButtonToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" #include -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" -#include "controller/controldeck/ControlDeck.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/Context.h" namespace Ship { MouseButtonToButtonMapping::MouseButtonToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, MouseBtn button) @@ -33,21 +33,26 @@ std::string MouseButtonToButtonMapping::GetButtonMappingId() { void MouseButtonToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseButtonToButtonMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); - CVarSetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "MouseButtonToButtonMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void MouseButtonToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string MouseButtonToButtonMapping::GetPhysicalDeviceName() { diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp similarity index 70% rename from src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp index 2295265..dcc6637 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.cpp @@ -1,8 +1,8 @@ -#include "MouseWheelToAnyMapping.h" -#include "Context.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAnyMapping.h" +#include "ship/Context.h" -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" namespace Ship { MouseWheelToAnyMapping::MouseWheelToAnyMapping(WheelDirection wheelDirection) diff --git a/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp new file mode 100644 index 0000000..c80b73a --- /dev/null +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.cpp @@ -0,0 +1,72 @@ +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToAxisDirectionMapping.h" +#include +#include +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/controller/controldeck/ControlDeck.h" + +namespace Ship { +MouseWheelToAxisDirectionMapping::MouseWheelToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, + Direction direction, WheelDirection wheelDirection) + : ControllerInputMapping(PhysicalDeviceType::Mouse), MouseWheelToAnyMapping(wheelDirection), + ControllerAxisDirectionMapping(PhysicalDeviceType::Mouse, portIndex, stickIndex, direction) { +} + +float MouseWheelToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { + if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { + return 0.0f; + } + + if (WheelHandler::GetInstance()->GetBufferedDirectionValue(mWheelDirection) > 0) { + return MAX_AXIS_RANGE; + } else { + return 0.0f; + } +} + +std::string MouseWheelToAxisDirectionMapping::GetAxisDirectionMappingId() { + return StringHelper::Sprintf("P%d-S%d-D%d-WHEEL%d", mPortIndex, mStickIndex, mDirection, mWheelDirection); +} + +void MouseWheelToAxisDirectionMapping::SaveToConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), + "MouseWheelToAxisDirectionMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), static_cast(mWheelDirection)); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +void MouseWheelToAxisDirectionMapping::EraseFromConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +int8_t MouseWheelToAxisDirectionMapping::GetMappingType() { + return MAPPING_TYPE_MOUSE; +} + +std::string MouseWheelToAxisDirectionMapping::GetPhysicalDeviceName() { + return MouseWheelToAnyMapping::GetPhysicalDeviceName(); +} + +std::string MouseWheelToAxisDirectionMapping::GetPhysicalInputName() { + return MouseWheelToAnyMapping::GetPhysicalInputName(); +} +} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp similarity index 52% rename from src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp index 3152998..d11165e 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.cpp @@ -1,10 +1,10 @@ -#include "MouseWheelToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/mouse/MouseWheelToButtonMapping.h" #include -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" -#include "WheelHandler.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { MouseWheelToButtonMapping::MouseWheelToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, @@ -34,22 +34,26 @@ std::string MouseWheelToButtonMapping::GetButtonMappingId() { void MouseWheelToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseWheelToButtonMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); - CVarSetInteger(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), - static_cast(mWheelDirection)); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "MouseWheelToButtonMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str(), static_cast(mWheelDirection)); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void MouseWheelToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.WheelDirection", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string MouseWheelToButtonMapping::GetPhysicalDeviceName() { diff --git a/src/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp b/src/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp similarity index 95% rename from src/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp rename to src/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp index f88aa65..7be72c2 100644 --- a/src/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp +++ b/src/ship/controller/controldevice/controller/mapping/mouse/WheelHandler.cpp @@ -1,5 +1,5 @@ -#include "WheelHandler.h" -#include "Context.h" +#include "ship/controller/controldevice/controller/mapping/mouse/WheelHandler.h" +#include "ship/Context.h" #include namespace Ship { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp similarity index 92% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp index 0ae82cf..d247720 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.cpp @@ -1,7 +1,7 @@ -#include "SDLAxisDirectionToAnyMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAnyMapping.h" -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" namespace Ship { SDLAxisDirectionToAnyMapping::SDLAxisDirectionToAnyMapping(int32_t sdlControllerAxis, int32_t axisDirection) diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp similarity index 58% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp index bde09eb..50ff697 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.cpp @@ -1,10 +1,10 @@ -#include "SDLAxisDirectionToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h" #include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" #define MAX_SDL_RANGE (float)INT16_MAX @@ -54,23 +54,33 @@ std::string SDLAxisDirectionToAxisDirectionMapping::GetAxisDirectionMappingId() void SDLAxisDirectionToAxisDirectionMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "SDLAxisDirectionToAxisDirectionMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); - CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); - CVarSetInteger(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), mControllerAxis); - CVarSetInteger(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), mAxisDirection); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), + "SDLAxisDirectionToAxisDirectionMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), mControllerAxis); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), mAxisDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLAxisDirectionToAxisDirectionMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } int8_t SDLAxisDirectionToAxisDirectionMapping::GetMappingType() { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp similarity index 62% rename from src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp index 5a33a3f..24d1e05 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.cpp @@ -1,10 +1,10 @@ -#include "SDLAxisDirectionToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" #include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { SDLAxisDirectionToButtonMapping::SDLAxisDirectionToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, @@ -56,21 +56,29 @@ std::string SDLAxisDirectionToButtonMapping::GetButtonMappingId() { void SDLAxisDirectionToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "SDLAxisDirectionToButtonMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); - CVarSetInteger(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), mControllerAxis); - CVarSetInteger(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), mAxisDirection); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), + "SDLAxisDirectionToButtonMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str(), mControllerAxis); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str(), mAxisDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLAxisDirectionToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.SDLControllerAxis", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirection", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string SDLAxisDirectionToButtonMapping::GetPhysicalDeviceName() { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp similarity index 93% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp index 261ff85..907764e 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.cpp @@ -1,7 +1,7 @@ -#include "SDLButtonToAnyMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAnyMapping.h" -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" namespace Ship { SDLButtonToAnyMapping::SDLButtonToAnyMapping(int32_t sdlControllerButton) diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp similarity index 53% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp index a5afb30..0c358fb 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.cpp @@ -1,10 +1,10 @@ -#include "SDLButtonToAxisDirectionMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h" #include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" #define MAX_SDL_RANGE (float)INT16_MAX @@ -38,21 +38,29 @@ std::string SDLButtonToAxisDirectionMapping::GetAxisDirectionMappingId() { void SDLButtonToAxisDirectionMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "SDLButtonToAxisDirectionMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); - CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); - CVarSetInteger(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), mControllerButton); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), + "SDLButtonToAxisDirectionMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), mControllerButton); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLButtonToAxisDirectionMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); - CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } int8_t SDLButtonToAxisDirectionMapping::GetMappingType() { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp similarity index 55% rename from src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp index 5e99b07..e0e5d2f 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.cpp @@ -1,10 +1,10 @@ -#include "SDLButtonToButtonMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h" #include -#include "utils/StringHelper.h" -#include "window/gui/IconsFontAwesome4.h" -#include "public/bridge/consolevariablebridge.h" -#include "controller/controldeck/ControlDeck.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/window/gui/IconsFontAwesome4.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldeck/ControlDeck.h" +#include "ship/Context.h" namespace Ship { SDLButtonToButtonMapping::SDLButtonToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, @@ -38,20 +38,25 @@ std::string SDLButtonToButtonMapping::GetButtonMappingId() { void SDLButtonToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "SDLButtonToButtonMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); - CVarSetInteger(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), mControllerButton); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), "SDLButtonToButtonMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str(), mControllerButton); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLButtonToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); - CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.SDLControllerButton", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string SDLButtonToButtonMapping::GetPhysicalDeviceName() { diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp similarity index 57% rename from src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp index 338a463..cd4a33f 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.cpp @@ -1,11 +1,11 @@ -#include "SDLGyroMapping.h" -#include "controller/controldevice/controller/mapping/ControllerGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLGyroMapping.h" +#include "ship/controller/controldevice/controller/mapping/ControllerGyroMapping.h" #include -#include "Context.h" +#include "ship/Context.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { SDLGyroMapping::SDLGyroMapping(uint8_t portIndex, float sensitivity, float neutralPitch, float neutralYaw, @@ -76,25 +76,35 @@ std::string SDLGyroMapping::GetGyroMappingId() { void SDLGyroMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + GetGyroMappingId(); - CVarSetString(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), "SDLGyroMapping"); - CVarSetFloat(StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str(), mSensitivity); - CVarSetFloat(StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str(), mNeutralPitch); - CVarSetFloat(StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), mNeutralYaw); - CVarSetFloat(StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str(), mNeutralRoll); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str(), "SDLGyroMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetFloat( + StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str(), mSensitivity); + Ship::Context::GetInstance()->GetConsoleVariables()->SetFloat( + StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str(), mNeutralPitch); + Ship::Context::GetInstance()->GetConsoleVariables()->SetFloat( + StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str(), mNeutralYaw); + Ship::Context::GetInstance()->GetConsoleVariables()->SetFloat( + StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str(), mNeutralRoll); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLGyroMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GyroMappings." + GetGyroMappingId(); - CVarClear(StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.GyroMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.Sensitivity", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.NeutralPitch", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.NeutralYaw", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.NeutralRoll", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string SDLGyroMapping::GetPhysicalDeviceName() { diff --git a/src/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp new file mode 100644 index 0000000..ab09a4a --- /dev/null +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.cpp @@ -0,0 +1,64 @@ +#include "ship/controller/controldevice/controller/mapping/sdl/SDLLEDMapping.h" + +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" + +namespace Ship { +SDLLEDMapping::SDLLEDMapping(uint8_t portIndex, uint8_t colorSource, Color_RGB8 savedColor) + : ControllerLEDMapping(PhysicalDeviceType::SDLGamepad, portIndex, colorSource, savedColor) { +} + +void SDLLEDMapping::SetLEDColor(Color_RGB8 color) { + if (mColorSource == LED_COLOR_SOURCE_OFF) { + color = { 0, 0, 0 }; + } + + if (mColorSource == LED_COLOR_SOURCE_SET) { + color = mSavedColor; + } + + for (const auto& [instanceId, gamepad] : + Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort( + mPortIndex)) { + if (!SDL_GameControllerHasLED(gamepad)) { + continue; + } + + SDL_JoystickSetLED(SDL_GameControllerGetJoystick(gamepad), color.r, color.g, color.b); + } +} + +std::string SDLLEDMapping::GetLEDMappingId() { + return StringHelper::Sprintf("P%d", mPortIndex); +} + +void SDLLEDMapping::SaveToConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + GetLEDMappingId(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str(), "SDLLEDMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str(), mColorSource); + Ship::Context::GetInstance()->GetConsoleVariables()->SetColor24( + StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str(), mSavedColor); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +void SDLLEDMapping::EraseFromConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".LEDMappings." + GetLEDMappingId(); + + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.LEDMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.ColorSource", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.SavedColor", mappingCvarKey.c_str()).c_str()); + + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +std::string SDLLEDMapping::GetPhysicalDeviceName() { + return "SDL Gamepad"; +} +} // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp b/src/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp similarity index 58% rename from src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp rename to src/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp index a2b749a..a34fb33 100644 --- a/src/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp +++ b/src/ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.cpp @@ -1,9 +1,9 @@ -#include "SDLRumbleMapping.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLRumbleMapping.h" -#include "public/bridge/consolevariablebridge.h" -#include "utils/StringHelper.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { SDLRumbleMapping::SDLRumbleMapping(uint8_t portIndex, uint8_t lowFrequencyIntensityPercentage, @@ -46,22 +46,28 @@ std::string SDLRumbleMapping::GetRumbleMappingId() { void SDLRumbleMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + GetRumbleMappingId(); - CVarSetString(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), "SDLRumbleMapping"); - CVarSetInteger(StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str(), - mLowFrequencyIntensityPercentage); - CVarSetInteger(StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str(), - mHighFrequencyIntensityPercentage); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString( + StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str(), "SDLRumbleMapping"); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str(), + mLowFrequencyIntensityPercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str(), + mHighFrequencyIntensityPercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } void SDLRumbleMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".RumbleMappings." + GetRumbleMappingId(); - CVarClear(StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str()); - CVarClear(StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.RumbleMappingClass", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.LowFrequencyIntensity", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.HighFrequencyIntensity", mappingCvarKey.c_str()).c_str()); - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); } std::string SDLRumbleMapping::GetPhysicalDeviceName() { diff --git a/src/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp b/src/ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp similarity index 96% rename from src/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp rename to src/ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp index 51e2efa..2f37243 100644 --- a/src/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp +++ b/src/ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.cpp @@ -1,4 +1,4 @@ -#include "ConnectedPhysicalDeviceManager.h" +#include "ship/controller/physicaldevice/ConnectedPhysicalDeviceManager.h" namespace Ship { ConnectedPhysicalDeviceManager::ConnectedPhysicalDeviceManager() { diff --git a/src/ship/controller/physicaldevice/GlobalSDLDeviceSettings.cpp b/src/ship/controller/physicaldevice/GlobalSDLDeviceSettings.cpp new file mode 100644 index 0000000..0515745 --- /dev/null +++ b/src/ship/controller/physicaldevice/GlobalSDLDeviceSettings.cpp @@ -0,0 +1,59 @@ +#include "ship/controller/physicaldevice/GlobalSDLDeviceSettings.h" + +#include +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" + +namespace Ship { +GlobalSDLDeviceSettings::GlobalSDLDeviceSettings() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; + const int32_t defaultAxisThresholdPercentage = 25; + mStickAxisThresholdPercentage = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), + defaultAxisThresholdPercentage); + mTriggerAxisThresholdPercentage = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), + defaultAxisThresholdPercentage); +} + +GlobalSDLDeviceSettings::~GlobalSDLDeviceSettings() { +} + +int32_t GlobalSDLDeviceSettings::GetStickAxisThresholdPercentage() { + return mStickAxisThresholdPercentage; +} + +void GlobalSDLDeviceSettings::SetStickAxisThresholdPercentage(int32_t stickAxisThresholdPercentage) { + mStickAxisThresholdPercentage = stickAxisThresholdPercentage; +} + +int32_t GlobalSDLDeviceSettings::GetTriggerAxisThresholdPercentage() { + return mTriggerAxisThresholdPercentage; +} + +void GlobalSDLDeviceSettings::SetTriggerAxisThresholdPercentage(int32_t triggerAxisThresholdPercentage) { + mTriggerAxisThresholdPercentage = triggerAxisThresholdPercentage; +} + +void GlobalSDLDeviceSettings::SaveToConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), + mStickAxisThresholdPercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger( + StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), + mTriggerAxisThresholdPercentage); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} + +void GlobalSDLDeviceSettings::EraseFromConfig() { + const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings"; + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable( + StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str()); + + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); +} +} // namespace Ship diff --git a/src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp b/src/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp similarity index 88% rename from src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp rename to src/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp index 9ca6c0d..2e519f8 100644 --- a/src/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp +++ b/src/ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.cpp @@ -1,7 +1,7 @@ -#include "SDLAddRemoveDeviceEventHandler.h" +#include "ship/controller/physicaldevice/SDLAddRemoveDeviceEventHandler.h" #include -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" namespace Ship { diff --git a/src/debug/Console.cpp b/src/ship/debug/Console.cpp similarity index 95% rename from src/debug/Console.cpp rename to src/ship/debug/Console.cpp index 102c989..bd69812 100644 --- a/src/debug/Console.cpp +++ b/src/ship/debug/Console.cpp @@ -1,6 +1,6 @@ -#include "Console.h" -#include "utils/StringHelper.h" -#include "Context.h" +#include "ship/debug/Console.h" +#include "ship/utils/StringHelper.h" +#include "ship/Context.h" #include namespace Ship { diff --git a/src/debug/CrashHandler.cpp b/src/ship/debug/CrashHandler.cpp similarity index 99% rename from src/debug/CrashHandler.cpp rename to src/ship/debug/CrashHandler.cpp index 86a0c9b..3181885 100644 --- a/src/debug/CrashHandler.cpp +++ b/src/ship/debug/CrashHandler.cpp @@ -1,7 +1,7 @@ #include -#include "utils/StringHelper.h" -#include "CrashHandler.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/debug/CrashHandler.h" +#include "ship/Context.h" #ifdef _WIN32 #include diff --git a/src/install_config.h.in b/src/ship/install_config.h.in similarity index 100% rename from src/install_config.h.in rename to src/ship/install_config.h.in diff --git a/src/port/mobile/MobileImpl.cpp b/src/ship/port/mobile/MobileImpl.cpp similarity index 92% rename from src/port/mobile/MobileImpl.cpp rename to src/ship/port/mobile/MobileImpl.cpp index 572168e..34391d1 100644 --- a/src/port/mobile/MobileImpl.cpp +++ b/src/ship/port/mobile/MobileImpl.cpp @@ -1,7 +1,7 @@ #if defined(__ANDROID__) || defined(__IOS__) #include "MobileImpl.h" #include -#include "public/bridge/consolevariablebridge.h" +#include "ship/public/bridge/consolevariablebridge.h" #include diff --git a/src/resource/Resource.cpp b/src/ship/resource/Resource.cpp similarity index 92% rename from src/resource/Resource.cpp rename to src/ship/resource/Resource.cpp index 60502c1..59b7082 100644 --- a/src/resource/Resource.cpp +++ b/src/ship/resource/Resource.cpp @@ -1,4 +1,4 @@ -#include "Resource.h" +#include "ship/resource/Resource.h" #include namespace Ship { diff --git a/src/resource/ResourceFactoryBinary.cpp b/src/ship/resource/ResourceFactoryBinary.cpp similarity index 93% rename from src/resource/ResourceFactoryBinary.cpp rename to src/ship/resource/ResourceFactoryBinary.cpp index bc11eae..826e786 100644 --- a/src/resource/ResourceFactoryBinary.cpp +++ b/src/ship/resource/ResourceFactoryBinary.cpp @@ -1,4 +1,4 @@ -#include "ResourceFactoryBinary.h" +#include "ship/resource/ResourceFactoryBinary.h" #include #include "spdlog/spdlog.h" diff --git a/src/resource/ResourceFactoryXML.cpp b/src/ship/resource/ResourceFactoryXML.cpp similarity index 93% rename from src/resource/ResourceFactoryXML.cpp rename to src/ship/resource/ResourceFactoryXML.cpp index bc24c31..ef892cd 100644 --- a/src/resource/ResourceFactoryXML.cpp +++ b/src/ship/resource/ResourceFactoryXML.cpp @@ -1,4 +1,4 @@ -#include "ResourceFactoryXML.h" +#include "ship/resource/ResourceFactoryXML.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/resource/ResourceLoader.cpp b/src/ship/resource/ResourceLoader.cpp similarity index 96% rename from src/resource/ResourceLoader.cpp rename to src/ship/resource/ResourceLoader.cpp index 281be98..418c158 100644 --- a/src/resource/ResourceLoader.cpp +++ b/src/ship/resource/ResourceLoader.cpp @@ -1,13 +1,13 @@ -#include "ResourceLoader.h" -#include "ResourceFactory.h" -#include "ResourceManager.h" -#include "Resource.h" -#include "File.h" -#include "Context.h" -#include "utils/binarytools/MemoryStream.h" -#include "utils/binarytools/BinaryReader.h" -#include "factory/JsonFactory.h" -#include "factory/ShaderFactory.h" +#include "ship/resource/ResourceLoader.h" +#include "ship/resource/ResourceFactory.h" +#include "ship/resource/ResourceManager.h" +#include "ship/resource/Resource.h" +#include "ship/resource/File.h" +#include "ship/Context.h" +#include "ship/utils/binarytools/MemoryStream.h" +#include "ship/utils/binarytools/BinaryReader.h" +#include "ship/resource/factory/JsonFactory.h" +#include "ship/resource/factory/ShaderFactory.h" #include #include #include "nlohmann/json.hpp" diff --git a/src/resource/ResourceManager.cpp b/src/ship/resource/ResourceManager.cpp similarity index 98% rename from src/resource/ResourceManager.cpp rename to src/ship/resource/ResourceManager.cpp index 9454b6e..c918c4f 100644 --- a/src/resource/ResourceManager.cpp +++ b/src/ship/resource/ResourceManager.cpp @@ -1,13 +1,13 @@ -#include "ResourceManager.h" +#include "ship/resource/ResourceManager.h" #include -#include "resource/File.h" -#include "resource/archive/Archive.h" +#include "ship/resource/File.h" +#include "ship/resource/archive/Archive.h" #include #include -#include "utils/StringHelper.h" -#include "utils/Utils.h" -#include "public/bridge/consolevariablebridge.h" -#include "Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/utils/Utils.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/Context.h" namespace Ship { diff --git a/src/resource/archive/Archive.cpp b/src/ship/resource/archive/Archive.cpp similarity index 90% rename from src/resource/archive/Archive.cpp rename to src/ship/resource/archive/Archive.cpp index d6493cd..c82fc94 100644 --- a/src/resource/archive/Archive.cpp +++ b/src/ship/resource/archive/Archive.cpp @@ -1,15 +1,15 @@ -#include "Archive.h" +#include "ship/resource/archive/Archive.h" #include "spdlog/spdlog.h" -#include "Context.h" -#include "resource/File.h" -#include "resource/ResourceLoader.h" -#include "resource/ResourceType.h" -#include "utils/binarytools/MemoryStream.h" -#include "utils/glob.h" -#include "utils/StrHash64.h" -#include "window/Window.h" +#include "ship/Context.h" +#include "ship/resource/File.h" +#include "ship/resource/ResourceLoader.h" +#include "ship/resource/ResourceType.h" +#include "ship/utils/binarytools/MemoryStream.h" +#include "ship/utils/glob.h" +#include "ship/utils/StrHash64.h" +#include "ship/window/Window.h" #include #include diff --git a/src/resource/archive/ArchiveManager.cpp b/src/ship/resource/archive/ArchiveManager.cpp similarity index 96% rename from src/resource/archive/ArchiveManager.cpp rename to src/ship/resource/archive/ArchiveManager.cpp index e4b97c2..2b7121c 100644 --- a/src/resource/archive/ArchiveManager.cpp +++ b/src/ship/resource/archive/ArchiveManager.cpp @@ -1,17 +1,17 @@ -#include "ArchiveManager.h" +#include "ship/resource/archive/ArchiveManager.h" #include #include "spdlog/spdlog.h" -#include "resource/archive/Archive.h" +#include "ship/resource/archive/Archive.h" #ifdef INCLUDE_MPQ_SUPPORT -#include "resource/archive/OtrArchive.h" +#include "ship/resource/archive/OtrArchive.h" #endif -#include "resource/archive/O2rArchive.h" -#include "resource/archive/FolderArchive.h" -#include "utils/StringHelper.h" -#include "utils/glob.h" -#include "utils/StrHash64.h" +#include "ship/resource/archive/O2rArchive.h" +#include "ship/resource/archive/FolderArchive.h" +#include "ship/utils/StringHelper.h" +#include "ship/utils/glob.h" +#include "ship/utils/StrHash64.h" namespace Ship { ArchiveManager::ArchiveManager() { diff --git a/src/resource/archive/FolderArchive.cpp b/src/ship/resource/archive/FolderArchive.cpp similarity index 92% rename from src/resource/archive/FolderArchive.cpp rename to src/ship/resource/archive/FolderArchive.cpp index 7753681..eab3895 100644 --- a/src/resource/archive/FolderArchive.cpp +++ b/src/ship/resource/archive/FolderArchive.cpp @@ -2,12 +2,12 @@ #undef _DLL -#include "FolderArchive.h" +#include "ship/resource/archive/FolderArchive.h" -#include "Context.h" +#include "ship/Context.h" #include "spdlog/spdlog.h" -#include "utils/filesystemtools/FileHelper.h" -#include "resource/ResourceManager.h" +#include "ship/utils/filesystemtools/FileHelper.h" +#include "ship/resource/ResourceManager.h" namespace Ship { FolderArchive::FolderArchive(const std::string& archivePath) : Archive(archivePath) { diff --git a/src/resource/archive/O2rArchive.cpp b/src/ship/resource/archive/O2rArchive.cpp similarity index 97% rename from src/resource/archive/O2rArchive.cpp rename to src/ship/resource/archive/O2rArchive.cpp index 0415f91..2361d25 100644 --- a/src/resource/archive/O2rArchive.cpp +++ b/src/ship/resource/archive/O2rArchive.cpp @@ -1,7 +1,7 @@ -#include "O2rArchive.h" +#include "ship/resource/archive/O2rArchive.h" -#include "Context.h" -#include "window/Window.h" +#include "ship/Context.h" +#include "ship/window/Window.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/resource/archive/OtrArchive.cpp b/src/ship/resource/archive/OtrArchive.cpp similarity index 94% rename from src/resource/archive/OtrArchive.cpp rename to src/ship/resource/archive/OtrArchive.cpp index 3917932..7cd3e34 100644 --- a/src/resource/archive/OtrArchive.cpp +++ b/src/ship/resource/archive/OtrArchive.cpp @@ -1,11 +1,11 @@ #ifdef INCLUDE_MPQ_SUPPORT -#include "OtrArchive.h" +#include "ship/resource/archive/OtrArchive.h" -#include "Context.h" -#include "utils/filesystemtools/FileHelper.h" -#include "resource/ResourceManager.h" -#include "resource/archive/ArchiveManager.h" +#include "ship/Context.h" +#include "ship/utils/filesystemtools/FileHelper.h" +#include "ship/resource/ResourceManager.h" +#include "ship/resource/archive/ArchiveManager.h" #include "spdlog/spdlog.h" diff --git a/src/resource/factory/BlobFactory.cpp b/src/ship/resource/factory/BlobFactory.cpp similarity index 89% rename from src/resource/factory/BlobFactory.cpp rename to src/ship/resource/factory/BlobFactory.cpp index b0c9c15..fdd471a 100644 --- a/src/resource/factory/BlobFactory.cpp +++ b/src/ship/resource/factory/BlobFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/BlobFactory.h" -#include "resource/type/Blob.h" +#include "ship/resource/factory/BlobFactory.h" +#include "ship/resource/type/Blob.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/resource/factory/JsonFactory.cpp b/src/ship/resource/factory/JsonFactory.cpp similarity index 88% rename from src/resource/factory/JsonFactory.cpp rename to src/ship/resource/factory/JsonFactory.cpp index 4ee8067..8d80c8b 100644 --- a/src/resource/factory/JsonFactory.cpp +++ b/src/ship/resource/factory/JsonFactory.cpp @@ -1,5 +1,5 @@ -#include "resource/factory/JsonFactory.h" -#include "resource/type/Json.h" +#include "ship/resource/factory/JsonFactory.h" +#include "ship/resource/type/Json.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/resource/factory/ShaderFactory.cpp b/src/ship/resource/factory/ShaderFactory.cpp similarity index 91% rename from src/resource/factory/ShaderFactory.cpp rename to src/ship/resource/factory/ShaderFactory.cpp index 543df7b..0314b7b 100644 --- a/src/resource/factory/ShaderFactory.cpp +++ b/src/ship/resource/factory/ShaderFactory.cpp @@ -1,4 +1,4 @@ -#include "resource/factory/ShaderFactory.h" +#include "ship/resource/factory/ShaderFactory.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/resource/type/Blob.cpp b/src/ship/resource/type/Blob.cpp similarity index 86% rename from src/resource/type/Blob.cpp rename to src/ship/resource/type/Blob.cpp index 7e94e95..e229836 100644 --- a/src/resource/type/Blob.cpp +++ b/src/ship/resource/type/Blob.cpp @@ -1,4 +1,4 @@ -#include "Blob.h" +#include "ship/resource/type/Blob.h" namespace Ship { Blob::Blob() : Resource(std::shared_ptr()) { diff --git a/src/resource/type/Json.cpp b/src/ship/resource/type/Json.cpp similarity index 85% rename from src/resource/type/Json.cpp rename to src/ship/resource/type/Json.cpp index ea74573..51f57da 100644 --- a/src/resource/type/Json.cpp +++ b/src/ship/resource/type/Json.cpp @@ -1,4 +1,4 @@ -#include "Json.h" +#include "ship/resource/type/Json.h" namespace Ship { Json::Json() : Resource(std::shared_ptr()) { diff --git a/src/resource/type/Shader.cpp b/src/ship/resource/type/Shader.cpp similarity index 84% rename from src/resource/type/Shader.cpp rename to src/ship/resource/type/Shader.cpp index 7c64582..3237a42 100644 --- a/src/resource/type/Shader.cpp +++ b/src/ship/resource/type/Shader.cpp @@ -1,4 +1,4 @@ -#include "Shader.h" +#include "ship/resource/type/Shader.h" namespace Ship { Shader::Shader() : Resource(std::shared_ptr()) { diff --git a/src/utils/AppleFolderManager.mm b/src/ship/utils/AppleFolderManager.mm similarity index 97% rename from src/utils/AppleFolderManager.mm rename to src/ship/utils/AppleFolderManager.mm index cba4108..ac82da3 100644 --- a/src/utils/AppleFolderManager.mm +++ b/src/ship/utils/AppleFolderManager.mm @@ -5,7 +5,7 @@ // Created by David Chavez on 28.06.22. // -#include "AppleFolderManager.h" +#include "ship/utils/AppleFolderManager.h" #import using namespace Ship; diff --git a/src/utils/StrHash64.cpp b/src/ship/utils/StrHash64.cpp similarity index 100% rename from src/utils/StrHash64.cpp rename to src/ship/utils/StrHash64.cpp diff --git a/src/utils/StringHelper.cpp b/src/ship/utils/StringHelper.cpp similarity index 99% rename from src/utils/StringHelper.cpp rename to src/ship/utils/StringHelper.cpp index b88161a..974aa18 100644 --- a/src/utils/StringHelper.cpp +++ b/src/ship/utils/StringHelper.cpp @@ -1,4 +1,4 @@ -#include "StringHelper.h" +#include "ship/utils/StringHelper.h" #if (_MSC_VER) #pragma optimize("2", on) diff --git a/src/utils/Utils.cpp b/src/ship/utils/Utils.cpp similarity index 98% rename from src/utils/Utils.cpp rename to src/ship/utils/Utils.cpp index 64441a1..4c0e423 100644 --- a/src/utils/Utils.cpp +++ b/src/ship/utils/Utils.cpp @@ -1,4 +1,4 @@ -#include "Utils.h" +#include "ship/utils/Utils.h" #include #include diff --git a/src/utils/binarytools/BinaryReader.cpp b/src/ship/utils/binarytools/BinaryReader.cpp similarity index 97% rename from src/utils/binarytools/BinaryReader.cpp rename to src/ship/utils/binarytools/BinaryReader.cpp index 0361388..92b5bf4 100644 --- a/src/utils/binarytools/BinaryReader.cpp +++ b/src/ship/utils/binarytools/BinaryReader.cpp @@ -1,5 +1,5 @@ -#include "BinaryReader.h" -#include "MemoryStream.h" +#include "ship/utils/binarytools/BinaryReader.h" +#include "ship/utils/binarytools/MemoryStream.h" #include #include diff --git a/src/utils/binarytools/BinaryWriter.cpp b/src/ship/utils/binarytools/BinaryWriter.cpp similarity index 97% rename from src/utils/binarytools/BinaryWriter.cpp rename to src/ship/utils/binarytools/BinaryWriter.cpp index d507275..9bcb0e0 100644 --- a/src/utils/binarytools/BinaryWriter.cpp +++ b/src/ship/utils/binarytools/BinaryWriter.cpp @@ -1,5 +1,5 @@ -#include "BinaryWriter.h" -#include "MemoryStream.h" +#include "ship/utils/binarytools/BinaryWriter.h" +#include "ship/utils/binarytools/MemoryStream.h" Ship::BinaryWriter::BinaryWriter() { mStream = std::make_shared(); diff --git a/src/utils/binarytools/MemoryStream.cpp b/src/ship/utils/binarytools/MemoryStream.cpp similarity index 97% rename from src/utils/binarytools/MemoryStream.cpp rename to src/ship/utils/binarytools/MemoryStream.cpp index 702bfdd..60a6d39 100644 --- a/src/utils/binarytools/MemoryStream.cpp +++ b/src/ship/utils/binarytools/MemoryStream.cpp @@ -1,4 +1,4 @@ -#include "MemoryStream.h" +#include "ship/utils/binarytools/MemoryStream.h" #include #ifndef _MSC_VER diff --git a/src/utils/binarytools/Stream.cpp b/src/ship/utils/binarytools/Stream.cpp similarity index 61% rename from src/utils/binarytools/Stream.cpp rename to src/ship/utils/binarytools/Stream.cpp index bc8da32..f9d509d 100644 --- a/src/utils/binarytools/Stream.cpp +++ b/src/ship/utils/binarytools/Stream.cpp @@ -1,4 +1,4 @@ -#include "Stream.h" +#include "ship/utils/binarytools/Stream.h" uint64_t Ship::Stream::GetBaseAddress() { return mBaseAddress; diff --git a/src/utils/glob.c b/src/ship/utils/glob.c similarity index 99% rename from src/utils/glob.c rename to src/ship/utils/glob.c index a3e1029..6665158 100644 --- a/src/utils/glob.c +++ b/src/ship/utils/glob.c @@ -1,4 +1,4 @@ -#include "glob.h" +#include "ship/utils/glob.h" #include // This has been borrowed from the dual MIT/GPL licensed glob module from the Linux kernel under the MIT license. diff --git a/src/utils/macUtils.mm b/src/ship/utils/macUtils.mm similarity index 96% rename from src/utils/macUtils.mm rename to src/ship/utils/macUtils.mm index b569d47..fe1add9 100644 --- a/src/utils/macUtils.mm +++ b/src/ship/utils/macUtils.mm @@ -1,6 +1,6 @@ // macUtils.mm #ifdef __APPLE__ -#import "macUtils.h" +#import "ship/utils/macUtils.h" #import #import diff --git a/src/utils/stox.cpp b/src/ship/utils/stox.cpp similarity index 98% rename from src/utils/stox.cpp rename to src/ship/utils/stox.cpp index b123082..31a9ae7 100644 --- a/src/utils/stox.cpp +++ b/src/ship/utils/stox.cpp @@ -1,5 +1,5 @@ #include -#include "stox.h" +#include "ship/utils/stox.h" #include namespace Ship { diff --git a/src/window/FileDropMgr.cpp b/src/ship/window/FileDropMgr.cpp similarity index 97% rename from src/window/FileDropMgr.cpp rename to src/ship/window/FileDropMgr.cpp index 6d807da..a401d19 100644 --- a/src/window/FileDropMgr.cpp +++ b/src/ship/window/FileDropMgr.cpp @@ -1,4 +1,4 @@ -#include "FileDropMgr.h" +#include "ship/window/FileDropMgr.h" #include #include #include @@ -9,8 +9,8 @@ #include #include #endif -#include "Context.h" -#include "Window.h" +#include "ship/Context.h" +#include "ship/window/Window.h" #ifdef __unix__ #include #include diff --git a/src/window/Window.cpp b/src/ship/window/Window.cpp similarity index 92% rename from src/window/Window.cpp rename to src/ship/window/Window.cpp index acc8e8b..f5001ef 100644 --- a/src/window/Window.cpp +++ b/src/ship/window/Window.cpp @@ -1,14 +1,13 @@ -#include "window/Window.h" +#include "ship/window/Window.h" #include #include #include -#include "public/bridge/consolevariablebridge.h" -#include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" -#include "Context.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" +#include "ship/Context.h" +#include "ship/controller/controldeck/ControlDeck.h" #ifdef __APPLE__ -#include "utils/AppleFolderManager.h" +#include "ship/utils/AppleFolderManager.h" #endif namespace Ship { diff --git a/src/window/gui/ConsoleWindow.cpp b/src/ship/window/gui/ConsoleWindow.cpp similarity index 95% rename from src/window/gui/ConsoleWindow.cpp rename to src/ship/window/gui/ConsoleWindow.cpp index 75510e5..b7f5036 100644 --- a/src/window/gui/ConsoleWindow.cpp +++ b/src/ship/window/gui/ConsoleWindow.cpp @@ -1,10 +1,10 @@ -#include "ConsoleWindow.h" +#include "ship/window/gui/ConsoleWindow.h" -#include "public/bridge/consolevariablebridge.h" -#include "window/Window.h" -#include "Context.h" -#include "utils/StringHelper.h" -#include "utils/Utils.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/window/Window.h" +#include "ship/Context.h" +#include "ship/utils/StringHelper.h" +#include "ship/utils/Utils.h" #include namespace Ship { @@ -203,9 +203,9 @@ int32_t ConsoleWindow::SetCommand(std::shared_ptr console, const std::v int vType = CheckVarType(args[2]); if (vType == VARTYPE_STRING) { - CVarSetString(args[1].c_str(), args[2].c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(args[1].c_str(), args[2].c_str()); } else if (vType == VARTYPE_FLOAT) { - CVarSetFloat((char*)args[1].c_str(), std::stof(args[2])); + Ship::Context::GetInstance()->GetConsoleVariables()->SetFloat((char*)args[1].c_str(), std::stof(args[2])); } else if (vType == VARTYPE_RGBA) { uint32_t val = std::stoul(&args[2].c_str()[1], nullptr, 16); Color_RGBA8 clr; @@ -213,12 +213,12 @@ int32_t ConsoleWindow::SetCommand(std::shared_ptr console, const std::v clr.g = val >> 16; clr.b = val >> 8; clr.a = val & 0xFF; - CVarSetColor((char*)args[1].c_str(), clr); + Ship::Context::GetInstance()->GetConsoleVariables()->SetColor((char*)args[1].c_str(), clr); } else { - CVarSetInteger(args[1].c_str(), std::stoi(args[2])); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(args[1].c_str(), std::stoi(args[2])); } - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); return 0; } @@ -233,7 +233,7 @@ int32_t ConsoleWindow::GetCommand(std::shared_ptr console, const std::v return 1; } - auto cvar = CVarGet(args[1].c_str()); + auto cvar = Ship::Context::GetInstance()->GetConsoleVariables()->Get(args[1].c_str()); if (cvar != nullptr) { if (cvar->Type == ConsoleVariableType::Integer) { @@ -327,7 +327,9 @@ void ConsoleWindow::UpdateElement() { } for (auto [key, var] : mBindingToggle) { if (ImGui::IsKeyPressed(key)) { - Dispatch("set " + var + " " + std::to_string(!static_cast(CVarGetInteger(var.c_str(), 0)))); + Dispatch("set " + var + " " + + std::to_string(!static_cast( + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(var.c_str(), 0)))); } } } @@ -389,7 +391,7 @@ void ConsoleWindow::DrawElement() { ClearLogs(mCurrentChannel); } - if (CVarGetInteger("gSinkEnabled", 0)) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger("gSinkEnabled", 0)) { ImGui::SameLine(); ImGui::SetNextItemWidth(150); if (ImGui::BeginCombo("##channel", mCurrentChannel.c_str())) { diff --git a/src/window/gui/GameOverlay.cpp b/src/ship/window/gui/GameOverlay.cpp similarity index 93% rename from src/window/gui/GameOverlay.cpp rename to src/ship/window/gui/GameOverlay.cpp index e4e47f5..8819c39 100644 --- a/src/window/gui/GameOverlay.cpp +++ b/src/ship/window/gui/GameOverlay.cpp @@ -1,14 +1,14 @@ -#include "GameOverlay.h" +#include "ship/window/gui/GameOverlay.h" -#include "public/bridge/consolevariablebridge.h" -#include "resource/File.h" -#include "window/gui/resource/Font.h" -#include "window/gui/resource/FontFactory.h" -#include "resource/archive/Archive.h" -#include "resource/ResourceManager.h" -#include "Context.h" -#include "window/Window.h" -#include "utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/resource/File.h" +#include "ship/window/gui/resource/Font.h" +#include "ship/window/gui/resource/FontFactory.h" +#include "ship/resource/archive/Archive.h" +#include "ship/resource/ResourceManager.h" +#include "ship/Context.h" +#include "ship/window/Window.h" +#include "ship/utils/StringHelper.h" namespace Ship { GameOverlay::GameOverlay() { @@ -169,7 +169,7 @@ void GameOverlay::SetCurrentFont(const std::string& name) { } mCurrentFont = name; - CVarSetString(CVAR_GAME_OVERLAY_FONT, name.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetString(CVAR_GAME_OVERLAY_FONT, name.c_str()); Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } @@ -204,7 +204,7 @@ void GameOverlay::Draw() { if (overlay.Type == OverlayType::TEXT) { const char* text = overlay.Value.c_str(); - const auto var = CVarGet(text); + const auto var = Ship::Context::GetInstance()->GetConsoleVariables()->Get(text); ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); switch (var->Type) { diff --git a/src/window/gui/Gui.cpp b/src/ship/window/gui/Gui.cpp similarity index 91% rename from src/window/gui/Gui.cpp rename to src/ship/window/gui/Gui.cpp index 85e649f..51b7357 100644 --- a/src/window/gui/Gui.cpp +++ b/src/ship/window/gui/Gui.cpp @@ -1,30 +1,30 @@ #define NOMINMAX -#include "Gui.h" +#include "ship/window/gui/Gui.h" #include #include #include #include -#include "config/Config.h" -#include "Context.h" -#include "public/bridge/consolevariablebridge.h" -#include "resource/type/Texture.h" -#include "resource/File.h" +#include "ship/config/Config.h" +#include "ship/Context.h" +#include "ship/config/ConsoleVariable.h" +#include "fast/resource/type/Texture.h" +#include "ship/resource/File.h" #include -#include "window/gui/Fonts.h" -#include "window/gui/resource/GuiTextureFactory.h" -#include "graphic/Fast3D/backends/gfx_rendering_api.h" +#include "ship/window/gui/Fonts.h" +#include "ship/window/gui/resource/GuiTextureFactory.h" +#include "fast/backends/gfx_rendering_api.h" -#include "window/gui/GfxDebuggerWindow.h" -#include "graphic/Fast3D/interpreter.h" -#include "graphic/Fast3D/Fast3dWindow.h" +#include "libultraship/window/gui/GfxDebuggerWindow.h" +#include "fast/interpreter.h" +#include "fast/Fast3dWindow.h" #ifdef __APPLE__ #include #include -#include "graphic/Fast3D/backends/gfx_metal.h" +#include "fast/backends/gfx_metal.h" #include #include #else @@ -43,7 +43,7 @@ #endif #if defined(ENABLE_DX11) || defined(ENABLE_DX12) -#include +#include #include #include @@ -141,11 +141,13 @@ void Gui::Init(GuiWindowInitData windowImpl) { mImGuiIo->IniFilename = strcpy(new char[imguiIniPath.length() + 1], imguiIniPath.c_str()); mImGuiIo->LogFilename = strcpy(new char[imguiLogPath.length() + 1], imguiLogPath.c_str()); - if (SupportsViewports() && CVarGetInteger(CVAR_ENABLE_MULTI_VIEWPORTS, 1)) { + if (SupportsViewports() && + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_ENABLE_MULTI_VIEWPORTS, 1)) { mImGuiIo->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; } - if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && GetMenuOrMenubarVisible()) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && + GetMenuOrMenubarVisible()) { mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; } else { mImGuiIo->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad; @@ -323,7 +325,8 @@ void Gui::BlockGamepadNavigation() { } void Gui::UnblockGamepadNavigation() { - if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && GetMenuOrMenubarVisible()) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && + GetMenuOrMenubarVisible()) { mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; } } @@ -388,11 +391,14 @@ void Gui::ImGuiWMNewFrame() { void Gui::ApplyResolutionChanges() { ImVec2 size = ImGui::GetContentRegionAvail(); - const float aspectRatioX = CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", 16.0f); - const float aspectRatioY = CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", 9.0f); - const uint32_t verticalPixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", 480); - const bool verticalResolutionToggle = - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); + const float aspectRatioX = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", 16.0f); + const float aspectRatioY = Ship::Context::GetInstance()->GetConsoleVariables()->GetFloat( + CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", 9.0f); + const uint32_t verticalPixelCount = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", 480); + const bool verticalResolutionToggle = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); const bool aspectRatioIsEnabled = (aspectRatioX > 0.0f) && (aspectRatioY > 0.0f); @@ -442,10 +448,13 @@ void Gui::ApplyResolutionChanges() { } int16_t Gui::GetIntegerScaleFactor() { - if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { - int16_t factor = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1); + if (!Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { + int16_t factor = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1); - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1)) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1)) { // Screen bounds take priority over whatever Factor is set to. // The same comparison as below, but checked against the configured factor @@ -485,7 +494,8 @@ int16_t Gui::GetIntegerScaleFactor() { } // Add screen bounds offset, if set. - factor += CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + factor += Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); if (factor < 1) { factor = 1; @@ -534,7 +544,8 @@ void Gui::DrawMenu() { ImGui::DockSpace(dockId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_NoDockingInCentralNode); if (ImGui::IsKeyPressed(TOGGLE_BTN, false) || ImGui::IsKeyPressed(ImGuiKey_Escape, false) || - (ImGui::IsKeyPressed(TOGGLE_PAD_BTN, false) && CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0))) { + (ImGui::IsKeyPressed(TOGGLE_PAD_BTN, false) && + Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0))) { if ((ImGui::IsKeyPressed(ImGuiKey_Escape, false) || ImGui::IsKeyPressed(TOGGLE_PAD_BTN, false)) && GetMenu()) { GetMenu()->ToggleVisibility(); } else if ((ImGui::IsKeyPressed(TOGGLE_BTN, false) || ImGui::IsKeyPressed(TOGGLE_PAD_BTN, false)) && @@ -549,7 +560,8 @@ void Gui::DrawMenu() { auto wnd = std::dynamic_pointer_cast(Context::GetInstance()->GetWindow()); mCursorVisibleTicks = mCursorVisibleSeconds * wnd->GetTargetFps(); } - if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && GetMenuOrMenubarVisible()) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && + GetMenuOrMenubarVisible()) { mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; } else { mImGuiIo->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad; @@ -656,11 +668,12 @@ void Gui::CalculateGameViewport() { mInterpreter.lock()->mGameWindowViewport.width = (int16_t)size.x; mInterpreter.lock()->mGameWindowViewport.height = (int16_t)size.y; - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) { + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", + 0)) { ApplyResolutionChanges(); } - switch (CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { + switch (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_LOW_RES_MODE, 0)) { case 1: { // N64 Mode mInterpreter.lock()->mCurDimensions.width = 320; mInterpreter.lock()->mCurDimensions.height = 240; @@ -704,13 +717,17 @@ void Gui::DrawGame() { ImVec2 mainPos = ImGui::GetWindowPos(); ImVec2 size = ImGui::GetContentRegionAvail(); ImVec2 pos = ImVec2(0, 0); - if (CVarGetInteger(CVAR_LOW_RES_MODE, 0) == 1) { // N64 Mode takes priority + if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_LOW_RES_MODE, 0) == + 1) { // N64 Mode takes priority const float sw = size.y * 320.0f / 240.0f; pos = ImVec2(floor(size.x / 2 - sw / 2), 0); size = ImVec2(sw, size.y); - } else if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) { - if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { - if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { + } else if (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) { + if (!Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { + if (!Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { float sWdth = size.y * mInterpreter.lock()->mCurDimensions.width / mInterpreter.lock()->mCurDimensions.height; float sHght = @@ -778,7 +795,7 @@ void Gui::DrawFloatingWindows() { void Gui::CheckSaveCvars() { if (mNeedsConsoleVariableSave) { - CVarSave(); + Ship::Context::GetInstance()->GetConsoleVariables()->Save(); mNeedsConsoleVariableSave = false; } } diff --git a/src/window/gui/GuiElement.cpp b/src/ship/window/gui/GuiElement.cpp similarity index 95% rename from src/window/gui/GuiElement.cpp rename to src/ship/window/gui/GuiElement.cpp index 3334e93..3602f1c 100644 --- a/src/window/gui/GuiElement.cpp +++ b/src/ship/window/gui/GuiElement.cpp @@ -1,4 +1,4 @@ -#include "GuiElement.h" +#include "ship/window/gui/GuiElement.h" #include "libultraship/libultraship.h" diff --git a/src/window/gui/GuiMenuBar.cpp b/src/ship/window/gui/GuiMenuBar.cpp similarity index 58% rename from src/window/gui/GuiMenuBar.cpp rename to src/ship/window/gui/GuiMenuBar.cpp index a74c5da..8bc5d7a 100644 --- a/src/window/gui/GuiMenuBar.cpp +++ b/src/ship/window/gui/GuiMenuBar.cpp @@ -1,11 +1,12 @@ -#include "window/gui/GuiMenuBar.h" +#include "ship/window/gui/GuiMenuBar.h" #include "libultraship/libultraship.h" namespace Ship { GuiMenuBar::GuiMenuBar(const std::string& visibilityConsoleVariable, bool isVisible) : GuiElement(isVisible), mVisibilityConsoleVariable(visibilityConsoleVariable) { if (!mVisibilityConsoleVariable.empty()) { - mIsVisible = CVarGetInteger(mVisibilityConsoleVariable.c_str(), mIsVisible); + mIsVisible = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(mVisibilityConsoleVariable.c_str(), + mIsVisible); SyncVisibilityConsoleVariable(); } } @@ -28,12 +29,14 @@ void GuiMenuBar::SyncVisibilityConsoleVariable() { return; } - bool shouldSave = CVarGetInteger(mVisibilityConsoleVariable.c_str(), 0) != IsVisible(); + bool shouldSave = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + mVisibilityConsoleVariable.c_str(), 0) != IsVisible(); if (IsVisible()) { - CVarSetInteger(mVisibilityConsoleVariable.c_str(), IsVisible()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(mVisibilityConsoleVariable.c_str(), + IsVisible()); } else { - CVarClear(mVisibilityConsoleVariable.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mVisibilityConsoleVariable.c_str()); } if (shouldSave) { diff --git a/src/window/gui/GuiWindow.cpp b/src/ship/window/gui/GuiWindow.cpp similarity index 90% rename from src/window/gui/GuiWindow.cpp rename to src/ship/window/gui/GuiWindow.cpp index 7b4ca04..555891e 100644 --- a/src/window/gui/GuiWindow.cpp +++ b/src/ship/window/gui/GuiWindow.cpp @@ -1,4 +1,4 @@ -#include "GuiWindow.h" +#include "ship/window/gui/GuiWindow.h" #include "libultraship/libultraship.h" @@ -8,7 +8,8 @@ GuiWindow::GuiWindow(const std::string& consoleVariable, bool isVisible, const s : GuiElement(isVisible), mName(name), mVisibilityConsoleVariable(consoleVariable), mOriginalSize(originalSize), mWindowFlags(windowFlags) { if (!mVisibilityConsoleVariable.empty()) { - mIsVisible = CVarGetInteger(mVisibilityConsoleVariable.c_str(), mIsVisible); + mIsVisible = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(mVisibilityConsoleVariable.c_str(), + mIsVisible); SyncVisibilityConsoleVariable(); } } @@ -44,12 +45,14 @@ void GuiWindow::SyncVisibilityConsoleVariable() { return; } - bool shouldSave = CVarGetInteger(mVisibilityConsoleVariable.c_str(), 0) != IsVisible(); + bool shouldSave = Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger( + mVisibilityConsoleVariable.c_str(), 0) != IsVisible(); if (IsVisible()) { - CVarSetInteger(mVisibilityConsoleVariable.c_str(), IsVisible()); + Ship::Context::GetInstance()->GetConsoleVariables()->SetInteger(mVisibilityConsoleVariable.c_str(), + IsVisible()); } else { - CVarClear(mVisibilityConsoleVariable.c_str()); + Ship::Context::GetInstance()->GetConsoleVariables()->ClearVariable(mVisibilityConsoleVariable.c_str()); } if (shouldSave) { diff --git a/src/window/gui/InputEditorWindow.cpp b/src/ship/window/gui/InputEditorWindow.cpp similarity index 99% rename from src/window/gui/InputEditorWindow.cpp rename to src/ship/window/gui/InputEditorWindow.cpp index 8827b61..7ef4c33 100644 --- a/src/window/gui/InputEditorWindow.cpp +++ b/src/ship/window/gui/InputEditorWindow.cpp @@ -1,10 +1,10 @@ -#include "InputEditorWindow.h" -#include "Context.h" -#include "Gui.h" -#include "utils/StringHelper.h" -#include "public/bridge/consolevariablebridge.h" -#include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" -#include "controller/controldeck/ControlDeck.h" +#include "ship/window/gui/InputEditorWindow.h" +#include "ship/Context.h" +#include "ship/window/gui/Gui.h" +#include "ship/utils/StringHelper.h" +#include "ship/config/ConsoleVariable.h" +#include "ship/controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" +#include "ship/controller/controldeck/ControlDeck.h" #define SCALE_IMGUI_SIZE(value) ((value / 13.0f) * ImGui::GetFontSize()) diff --git a/src/window/gui/StatsWindow.cpp b/src/ship/window/gui/StatsWindow.cpp similarity index 91% rename from src/window/gui/StatsWindow.cpp rename to src/ship/window/gui/StatsWindow.cpp index 7b169d1..1ba595c 100644 --- a/src/window/gui/StatsWindow.cpp +++ b/src/ship/window/gui/StatsWindow.cpp @@ -1,6 +1,5 @@ -#include "StatsWindow.h" +#include "ship/window/gui/StatsWindow.h" #include -#include "public/bridge/consolevariablebridge.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/window/gui/resource/Font.cpp b/src/ship/window/gui/resource/Font.cpp similarity index 87% rename from src/window/gui/resource/Font.cpp rename to src/ship/window/gui/resource/Font.cpp index 03eb60b..4f35dfc 100644 --- a/src/window/gui/resource/Font.cpp +++ b/src/ship/window/gui/resource/Font.cpp @@ -1,4 +1,4 @@ -#include "Font.h" +#include "ship/window/gui/resource/Font.h" namespace Ship { Font::Font() : Resource(std::shared_ptr()) { diff --git a/src/window/gui/resource/FontFactory.cpp b/src/ship/window/gui/resource/FontFactory.cpp similarity index 87% rename from src/window/gui/resource/FontFactory.cpp rename to src/ship/window/gui/resource/FontFactory.cpp index 00f01fc..c7bfda5 100644 --- a/src/window/gui/resource/FontFactory.cpp +++ b/src/ship/window/gui/resource/FontFactory.cpp @@ -1,5 +1,5 @@ -#include "window/gui/resource/FontFactory.h" -#include "window/gui/resource/Font.h" +#include "ship/window/gui/resource/FontFactory.h" +#include "ship/window/gui/resource/Font.h" #include "spdlog/spdlog.h" namespace Ship { diff --git a/src/window/gui/resource/GuiTexture.cpp b/src/ship/window/gui/resource/GuiTexture.cpp similarity index 87% rename from src/window/gui/resource/GuiTexture.cpp rename to src/ship/window/gui/resource/GuiTexture.cpp index 6ae9851..2a4da26 100644 --- a/src/window/gui/resource/GuiTexture.cpp +++ b/src/ship/window/gui/resource/GuiTexture.cpp @@ -1,4 +1,4 @@ -#include "GuiTexture.h" +#include "ship/window/gui/resource/GuiTexture.h" namespace Ship { GuiTexture::GuiTexture() : Resource(std::shared_ptr()) { diff --git a/src/window/gui/resource/GuiTextureFactory.cpp b/src/ship/window/gui/resource/GuiTextureFactory.cpp similarity index 90% rename from src/window/gui/resource/GuiTextureFactory.cpp rename to src/ship/window/gui/resource/GuiTextureFactory.cpp index 56726a0..5c7918b 100644 --- a/src/window/gui/resource/GuiTextureFactory.cpp +++ b/src/ship/window/gui/resource/GuiTextureFactory.cpp @@ -1,5 +1,5 @@ -#include "window/gui/resource/GuiTextureFactory.h" -#include "window/gui/resource/GuiTexture.h" +#include "ship/window/gui/resource/GuiTextureFactory.h" +#include "ship/window/gui/resource/GuiTexture.h" #include "spdlog/spdlog.h" namespace Ship {