Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #8867 from iwubcode/freelook_controller
Make Free Look a proper controller, move to separate UI
- Loading branch information
Showing
45 changed files
with
852 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright 2020 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "Core/Config/FreeLookSettings.h" | ||
| #include "Core/FreeLookConfig.h" | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "Common/Config/Config.h" | ||
|
|
||
| namespace Config | ||
| { | ||
| // Configuration Information | ||
| const Info<bool> FREE_LOOK_ENABLED{{System::FreeLook, "General", "Enabled"}, false}; | ||
|
|
||
| // FreeLook.Controller1 | ||
| const Info<FreeLook::ControlType> FL1_CONTROL_TYPE{{System::FreeLook, "Camera1", "ControlType"}, | ||
| FreeLook::ControlType::SixAxis}; | ||
|
|
||
| } // namespace Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2020 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Common/Config/Config.h" | ||
|
|
||
| namespace FreeLook | ||
| { | ||
| enum class ControlType : int; | ||
| } | ||
|
|
||
| namespace Config | ||
| { | ||
| // Configuration Information | ||
|
|
||
| extern const Info<bool> FREE_LOOK_ENABLED; | ||
|
|
||
| // FreeLook.Controller1 | ||
| extern const Info<FreeLook::ControlType> FL1_CONTROL_TYPE; | ||
|
|
||
| } // namespace Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright 2020 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "Core/FreeLookConfig.h" | ||
| #include "Core/Config/FreeLookSettings.h" | ||
| #include "Core/ConfigManager.h" | ||
| #include "Core/Core.h" | ||
|
|
||
| namespace FreeLook | ||
| { | ||
| static Config s_config; | ||
| static Config s_active_config; | ||
| static bool s_has_registered_callback = false; | ||
|
|
||
| Config& GetConfig() | ||
| { | ||
| return s_config; | ||
| } | ||
|
|
||
| const Config& GetActiveConfig() | ||
| { | ||
| return s_active_config; | ||
| } | ||
|
|
||
| void UpdateActiveConfig() | ||
| { | ||
| s_active_config = s_config; | ||
| } | ||
|
|
||
| Config::Config() | ||
| { | ||
| camera_config.control_type = ControlType::SixAxis; | ||
| enabled = false; | ||
| } | ||
|
|
||
| void Config::Refresh() | ||
| { | ||
| if (!s_has_registered_callback) | ||
| { | ||
| ::Config::AddConfigChangedCallback([] { Core::RunAsCPUThread([] { s_config.Refresh(); }); }); | ||
| s_has_registered_callback = true; | ||
| } | ||
|
|
||
| camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE); | ||
| enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED); | ||
| } | ||
| } // namespace FreeLook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright 2020 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| // IMPORTANT: UI etc should modify the value returned by FreeLook::GetConfig(). | ||
| // Free Look code should read from the value returned by FreeLook::GetActiveConfig(). | ||
| // The reason for this is to get rid of race conditions etc when the | ||
| // configuration changes in the middle of a frame. | ||
|
|
||
| #pragma once | ||
|
|
||
| namespace FreeLook | ||
| { | ||
| enum class ControlType : int | ||
| { | ||
| SixAxis, | ||
| FPS, | ||
| Orbital | ||
| }; | ||
|
|
||
| struct CameraConfig | ||
| { | ||
| ControlType control_type; | ||
| }; | ||
|
|
||
| // NEVER inherit from this class. | ||
| struct Config final | ||
| { | ||
| Config(); | ||
| void Refresh(); | ||
|
|
||
| CameraConfig camera_config; | ||
| bool enabled; | ||
| }; | ||
|
|
||
| Config& GetConfig(); | ||
| const Config& GetActiveConfig(); | ||
|
|
||
| // Called every frame. | ||
| void UpdateActiveConfig(); | ||
| } // namespace FreeLook |
Oops, something went wrong.