diff options
Diffstat (limited to 'src/citra')
| -rw-r--r-- | src/citra/citra.cpp | 44 | ||||
| -rw-r--r-- | src/citra/config.cpp | 41 | ||||
| -rw-r--r-- | src/citra/config.h | 4 | ||||
| -rw-r--r-- | src/citra/default_ini.h | 1 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 34 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.h | 6 | ||||
| -rw-r--r-- | src/citra/resource.h | 10 |
7 files changed, 66 insertions, 74 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 128b9a16d..e47375f88 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -2,10 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <string> -#include <thread> #include <iostream> #include <memory> +#include <string> +#include <thread> // This needs to be included before getopt.h because the latter #defines symbols used by it #include "common/microprofile.h" @@ -13,53 +13,48 @@ #ifdef _MSC_VER #include <getopt.h> #else -#include <unistd.h> #include <getopt.h> +#include <unistd.h> #endif #ifdef _WIN32 #include <Windows.h> #endif -#include "common/logging/log.h" +#include "citra/config.h" +#include "citra/emu_window/emu_window_sdl2.h" #include "common/logging/backend.h" #include "common/logging/filter.h" +#include "common/logging/log.h" #include "common/scm_rev.h" #include "common/scope_exit.h" #include "common/string_util.h" - -#include "core/settings.h" -#include "core/system.h" #include "core/core.h" #include "core/gdbstub/gdbstub.h" #include "core/loader/loader.h" - -#include "citra/config.h" -#include "citra/emu_window/emu_window_sdl2.h" - +#include "core/settings.h" +#include "core/system.h" #include "video_core/video_core.h" - -static void PrintHelp(const char *argv0) -{ - std::cout << "Usage: " << argv0 << " [options] <filename>\n" +static void PrintHelp(const char* argv0) { + std::cout << "Usage: " << argv0 + << " [options] <filename>\n" "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" "-h, --help Display this help and exit\n" "-v, --version Output version information and exit\n"; } -static void PrintVersion() -{ +static void PrintVersion() { std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl; } /// Application entry point -int main(int argc, char **argv) { +int main(int argc, char** argv) { Config config; int option_index = 0; bool use_gdbstub = Settings::values.use_gdbstub; u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port); - char *endarg; + char* endarg; #ifdef _WIN32 int argc_w; auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w); @@ -72,10 +67,10 @@ int main(int argc, char **argv) { std::string boot_filename; static struct option long_options[] = { - { "gdbport", required_argument, 0, 'g' }, - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'v' }, - { 0, 0, 0, 0 } + {"gdbport", required_argument, 0, 'g'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0}, }; while (optind < argc) { @@ -86,7 +81,8 @@ int main(int argc, char **argv) { errno = 0; gdb_port = strtoul(optarg, &endarg, 0); use_gdbstub = true; - if (endarg == optarg) errno = EINVAL; + if (endarg == optarg) + errno = EINVAL; if (errno != 0) { perror("--gdbport"); exit(1); diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 1a09f0e55..05eabfa3d 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -3,19 +3,13 @@ // Refer to the license.txt file included. #include <memory> - -#include <inih/cpp/INIReader.h> - #include <SDL.h> - +#include <inih/cpp/INIReader.h> #include "citra/default_ini.h" - #include "common/file_util.h" #include "common/logging/log.h" - -#include "core/settings.h" - #include "config.h" +#include "core/settings.h" Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. @@ -45,15 +39,13 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { // directly mapped keys - SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, - SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_1, SDL_SCANCODE_2, - SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, - SDL_SCANCODE_T, SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, - SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L, + SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_Q, SDL_SCANCODE_W, + SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, SDL_SCANCODE_T, + SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, + SDL_SCANCODE_L, // indirectly mapped keys - SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, - SDL_SCANCODE_D, + SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D, }; void Config::ReadValues() { @@ -62,7 +54,8 @@ void Config::ReadValues() { Settings::values.input_mappings[Settings::NativeInput::All[i]] = sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); } - Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); + Settings::values.pad_circle_modifier_scale = + (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); // Core Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); @@ -71,19 +64,22 @@ void Config::ReadValues() { // Renderer Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true); Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true); - Settings::values.use_scaled_resolution = sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false); + Settings::values.use_scaled_resolution = + sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false); Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false); - Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 1.0); + Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 1.0); Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 1.0); - Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0); + Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0); // Audio Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); - Settings::values.enable_audio_stretching = sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true); + Settings::values.enable_audio_stretching = + sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true); // Data Storage - Settings::values.use_virtual_sd = sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); + Settings::values.use_virtual_sd = + sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); // System Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", false); @@ -94,7 +90,8 @@ void Config::ReadValues() { // Debugging Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false); - Settings::values.gdbstub_port = static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); + Settings::values.gdbstub_port = + static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); } void Config::Reload() { diff --git a/src/citra/config.h b/src/citra/config.h index 52a478146..b1c31f59c 100644 --- a/src/citra/config.h +++ b/src/citra/config.h @@ -6,15 +6,15 @@ #include <memory> #include <string> - #include <inih/cpp/INIReader.h> class Config { std::unique_ptr<INIReader> sdl2_config; std::string sdl2_config_loc; - bool LoadINI(const std::string& default_contents="", bool retry=true); + bool LoadINI(const std::string& default_contents = "", bool retry = true); void ReadValues(); + public: Config(); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 788174508..0b49e0230 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -104,5 +104,4 @@ log_filter = *:Info use_gdbstub=false gdbstub_port=24689 )"; - } diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index da12307b7..7df054208 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp @@ -5,22 +5,16 @@ #include <algorithm> #include <cstdlib> #include <string> - #define SDL_MAIN_HANDLED #include <SDL.h> - #include <glad/glad.h> - +#include "citra/emu_window/emu_window_sdl2.h" #include "common/key_map.h" #include "common/logging/log.h" #include "common/scm_rev.h" #include "common/string_util.h" - -#include "core/settings.h" #include "core/hle/service/hid/hid.h" - -#include "citra/emu_window/emu_window_sdl2.h" - +#include "core/settings.h" #include "video_core/video_core.h" void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { @@ -40,9 +34,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { if (state == SDL_PRESSED) { - KeyMap::PressKey(*this, { key, keyboard_id }); + KeyMap::PressKey(*this, {key, keyboard_id}); } else if (state == SDL_RELEASED) { - KeyMap::ReleaseKey(*this, { key, keyboard_id }); + KeyMap::ReleaseKey(*this, {key, keyboard_id}); } } @@ -55,7 +49,8 @@ void EmuWindow_SDL2::OnResize() { SDL_GetWindowSize(render_window, &width, &height); - NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); + NotifyFramebufferLayoutChanged( + EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); } EmuWindow_SDL2::EmuWindow_SDL2() { @@ -80,12 +75,13 @@ EmuWindow_SDL2::EmuWindow_SDL2() { SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); - std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); - render_window = SDL_CreateWindow(window_title.c_str(), + std::string window_title = + Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); + render_window = SDL_CreateWindow( + window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, // x position SDL_WINDOWPOS_UNDEFINED, // y position - VideoCore::kScreenTopWidth, - VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight, + VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); if (render_window == nullptr) { @@ -171,10 +167,14 @@ void EmuWindow_SDL2::DoneCurrent() { void EmuWindow_SDL2::ReloadSetKeymaps() { KeyMap::ClearKeyMapping(keyboard_id); for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { - KeyMap::SetKeyMapping({ Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id }, KeyMap::mapping_targets[i]); + KeyMap::SetKeyMapping( + {Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id}, + KeyMap::mapping_targets[i]); } } -void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) { +void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest( + const std::pair<unsigned, unsigned>& minimal_size) { + SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); } diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h index 77279f022..e4d14ef12 100644 --- a/src/citra/emu_window/emu_window_sdl2.h +++ b/src/citra/emu_window/emu_window_sdl2.h @@ -5,7 +5,6 @@ #pragma once #include <utility> - #include "common/emu_window.h" struct SDL_Window; @@ -47,7 +46,8 @@ private: void OnResize(); /// Called when a configuration change affects the minimal size of the window - void OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) override; + void OnMinimalClientAreaChangeRequest( + const std::pair<unsigned, unsigned>& minimal_size) override; /// Is the window still open? bool is_open = true; @@ -55,7 +55,7 @@ private: /// Internal SDL2 render window SDL_Window* render_window; - using SDL_GLContext = void *; + using SDL_GLContext = void*; /// The OpenGL context associated with the window SDL_GLContext gl_context; diff --git a/src/citra/resource.h b/src/citra/resource.h index 127896424..df8e459e4 100644 --- a/src/citra/resource.h +++ b/src/citra/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by pcafe.rc // -#define IDI_ICON3 103 +#define IDI_ICON3 103 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif |
