summaryrefslogtreecommitdiff
path: root/src/citra
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2016-09-21 11:29:48 -0700
committerGravatar GitHub2016-09-21 11:29:48 -0700
commitd5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch)
tree8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/citra
parentREADME: Specify master branch for Travis CI badge (diff)
parentFix Travis clang-format check (diff)
downloadyuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz
yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/citra.cpp44
-rw-r--r--src/citra/config.cpp41
-rw-r--r--src/citra/config.h4
-rw-r--r--src/citra/default_ini.h1
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp34
-rw-r--r--src/citra/emu_window/emu_window_sdl2.h6
-rw-r--r--src/citra/resource.h10
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 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <string>
6#include <thread>
7#include <iostream> 5#include <iostream>
8#include <memory> 6#include <memory>
7#include <string>
8#include <thread>
9 9
10// This needs to be included before getopt.h because the latter #defines symbols used by it 10// This needs to be included before getopt.h because the latter #defines symbols used by it
11#include "common/microprofile.h" 11#include "common/microprofile.h"
@@ -13,53 +13,48 @@
13#ifdef _MSC_VER 13#ifdef _MSC_VER
14#include <getopt.h> 14#include <getopt.h>
15#else 15#else
16#include <unistd.h>
17#include <getopt.h> 16#include <getopt.h>
17#include <unistd.h>
18#endif 18#endif
19 19
20#ifdef _WIN32 20#ifdef _WIN32
21#include <Windows.h> 21#include <Windows.h>
22#endif 22#endif
23 23
24#include "common/logging/log.h" 24#include "citra/config.h"
25#include "citra/emu_window/emu_window_sdl2.h"
25#include "common/logging/backend.h" 26#include "common/logging/backend.h"
26#include "common/logging/filter.h" 27#include "common/logging/filter.h"
28#include "common/logging/log.h"
27#include "common/scm_rev.h" 29#include "common/scm_rev.h"
28#include "common/scope_exit.h" 30#include "common/scope_exit.h"
29#include "common/string_util.h" 31#include "common/string_util.h"
30
31#include "core/settings.h"
32#include "core/system.h"
33#include "core/core.h" 32#include "core/core.h"
34#include "core/gdbstub/gdbstub.h" 33#include "core/gdbstub/gdbstub.h"
35#include "core/loader/loader.h" 34#include "core/loader/loader.h"
36 35#include "core/settings.h"
37#include "citra/config.h" 36#include "core/system.h"
38#include "citra/emu_window/emu_window_sdl2.h"
39
40#include "video_core/video_core.h" 37#include "video_core/video_core.h"
41 38
42 39static void PrintHelp(const char* argv0) {
43static void PrintHelp(const char *argv0) 40 std::cout << "Usage: " << argv0
44{ 41 << " [options] <filename>\n"
45 std::cout << "Usage: " << argv0 << " [options] <filename>\n"
46 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" 42 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
47 "-h, --help Display this help and exit\n" 43 "-h, --help Display this help and exit\n"
48 "-v, --version Output version information and exit\n"; 44 "-v, --version Output version information and exit\n";
49} 45}
50 46
51static void PrintVersion() 47static void PrintVersion() {
52{
53 std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl; 48 std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl;
54} 49}
55 50
56/// Application entry point 51/// Application entry point
57int main(int argc, char **argv) { 52int main(int argc, char** argv) {
58 Config config; 53 Config config;
59 int option_index = 0; 54 int option_index = 0;
60 bool use_gdbstub = Settings::values.use_gdbstub; 55 bool use_gdbstub = Settings::values.use_gdbstub;
61 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port); 56 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
62 char *endarg; 57 char* endarg;
63#ifdef _WIN32 58#ifdef _WIN32
64 int argc_w; 59 int argc_w;
65 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w); 60 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
@@ -72,10 +67,10 @@ int main(int argc, char **argv) {
72 std::string boot_filename; 67 std::string boot_filename;
73 68
74 static struct option long_options[] = { 69 static struct option long_options[] = {
75 { "gdbport", required_argument, 0, 'g' }, 70 {"gdbport", required_argument, 0, 'g'},
76 { "help", no_argument, 0, 'h' }, 71 {"help", no_argument, 0, 'h'},
77 { "version", no_argument, 0, 'v' }, 72 {"version", no_argument, 0, 'v'},
78 { 0, 0, 0, 0 } 73 {0, 0, 0, 0},
79 }; 74 };
80 75
81 while (optind < argc) { 76 while (optind < argc) {
@@ -86,7 +81,8 @@ int main(int argc, char **argv) {
86 errno = 0; 81 errno = 0;
87 gdb_port = strtoul(optarg, &endarg, 0); 82 gdb_port = strtoul(optarg, &endarg, 0);
88 use_gdbstub = true; 83 use_gdbstub = true;
89 if (endarg == optarg) errno = EINVAL; 84 if (endarg == optarg)
85 errno = EINVAL;
90 if (errno != 0) { 86 if (errno != 0) {
91 perror("--gdbport"); 87 perror("--gdbport");
92 exit(1); 88 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 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory> 5#include <memory>
6
7#include <inih/cpp/INIReader.h>
8
9#include <SDL.h> 6#include <SDL.h>
10 7#include <inih/cpp/INIReader.h>
11#include "citra/default_ini.h" 8#include "citra/default_ini.h"
12
13#include "common/file_util.h" 9#include "common/file_util.h"
14#include "common/logging/log.h" 10#include "common/logging/log.h"
15
16#include "core/settings.h"
17
18#include "config.h" 11#include "config.h"
12#include "core/settings.h"
19 13
20Config::Config() { 14Config::Config() {
21 // TODO: Don't hardcode the path; let the frontend decide where to put the config files. 15 // 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) {
45 39
46static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { 40static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
47 // directly mapped keys 41 // directly mapped keys
48 SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, 42 SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_Q, SDL_SCANCODE_W,
49 SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_1, SDL_SCANCODE_2, 43 SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, SDL_SCANCODE_T,
50 SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, 44 SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J,
51 SDL_SCANCODE_T, SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, 45 SDL_SCANCODE_L,
52 SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L,
53 46
54 // indirectly mapped keys 47 // indirectly mapped keys
55 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, 48 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D,
56 SDL_SCANCODE_D,
57}; 49};
58 50
59void Config::ReadValues() { 51void Config::ReadValues() {
@@ -62,7 +54,8 @@ void Config::ReadValues() {
62 Settings::values.input_mappings[Settings::NativeInput::All[i]] = 54 Settings::values.input_mappings[Settings::NativeInput::All[i]] =
63 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); 55 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
64 } 56 }
65 Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); 57 Settings::values.pad_circle_modifier_scale =
58 (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5);
66 59
67 // Core 60 // Core
68 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); 61 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true);
@@ -71,19 +64,22 @@ void Config::ReadValues() {
71 // Renderer 64 // Renderer
72 Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true); 65 Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true);
73 Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true); 66 Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true);
74 Settings::values.use_scaled_resolution = sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false); 67 Settings::values.use_scaled_resolution =
68 sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false);
75 Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false); 69 Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false);
76 70
77 Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 1.0); 71 Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 1.0);
78 Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 1.0); 72 Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 1.0);
79 Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0); 73 Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0);
80 74
81 // Audio 75 // Audio
82 Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); 76 Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto");
83 Settings::values.enable_audio_stretching = sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true); 77 Settings::values.enable_audio_stretching =
78 sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true);
84 79
85 // Data Storage 80 // Data Storage
86 Settings::values.use_virtual_sd = sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); 81 Settings::values.use_virtual_sd =
82 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
87 83
88 // System 84 // System
89 Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", false); 85 Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", false);
@@ -94,7 +90,8 @@ void Config::ReadValues() {
94 90
95 // Debugging 91 // Debugging
96 Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false); 92 Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false);
97 Settings::values.gdbstub_port = static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); 93 Settings::values.gdbstub_port =
94 static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689));
98} 95}
99 96
100void Config::Reload() { 97void 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 @@
6 6
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9
10#include <inih/cpp/INIReader.h> 9#include <inih/cpp/INIReader.h>
11 10
12class Config { 11class Config {
13 std::unique_ptr<INIReader> sdl2_config; 12 std::unique_ptr<INIReader> sdl2_config;
14 std::string sdl2_config_loc; 13 std::string sdl2_config_loc;
15 14
16 bool LoadINI(const std::string& default_contents="", bool retry=true); 15 bool LoadINI(const std::string& default_contents = "", bool retry = true);
17 void ReadValues(); 16 void ReadValues();
17
18public: 18public:
19 Config(); 19 Config();
20 20
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
104use_gdbstub=false 104use_gdbstub=false
105gdbstub_port=24689 105gdbstub_port=24689
106)"; 106)";
107
108} 107}
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 @@
5#include <algorithm> 5#include <algorithm>
6#include <cstdlib> 6#include <cstdlib>
7#include <string> 7#include <string>
8
9#define SDL_MAIN_HANDLED 8#define SDL_MAIN_HANDLED
10#include <SDL.h> 9#include <SDL.h>
11
12#include <glad/glad.h> 10#include <glad/glad.h>
13 11#include "citra/emu_window/emu_window_sdl2.h"
14#include "common/key_map.h" 12#include "common/key_map.h"
15#include "common/logging/log.h" 13#include "common/logging/log.h"
16#include "common/scm_rev.h" 14#include "common/scm_rev.h"
17#include "common/string_util.h" 15#include "common/string_util.h"
18
19#include "core/settings.h"
20#include "core/hle/service/hid/hid.h" 16#include "core/hle/service/hid/hid.h"
21 17#include "core/settings.h"
22#include "citra/emu_window/emu_window_sdl2.h"
23
24#include "video_core/video_core.h" 18#include "video_core/video_core.h"
25 19
26void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { 20void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
@@ -40,9 +34,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
40 34
41void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { 35void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
42 if (state == SDL_PRESSED) { 36 if (state == SDL_PRESSED) {
43 KeyMap::PressKey(*this, { key, keyboard_id }); 37 KeyMap::PressKey(*this, {key, keyboard_id});
44 } else if (state == SDL_RELEASED) { 38 } else if (state == SDL_RELEASED) {
45 KeyMap::ReleaseKey(*this, { key, keyboard_id }); 39 KeyMap::ReleaseKey(*this, {key, keyboard_id});
46 } 40 }
47} 41}
48 42
@@ -55,7 +49,8 @@ void EmuWindow_SDL2::OnResize() {
55 49
56 SDL_GetWindowSize(render_window, &width, &height); 50 SDL_GetWindowSize(render_window, &width, &height);
57 51
58 NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); 52 NotifyFramebufferLayoutChanged(
53 EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height));
59} 54}
60 55
61EmuWindow_SDL2::EmuWindow_SDL2() { 56EmuWindow_SDL2::EmuWindow_SDL2() {
@@ -80,12 +75,13 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
80 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); 75 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
81 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); 76 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
82 77
83 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); 78 std::string window_title =
84 render_window = SDL_CreateWindow(window_title.c_str(), 79 Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
80 render_window = SDL_CreateWindow(
81 window_title.c_str(),
85 SDL_WINDOWPOS_UNDEFINED, // x position 82 SDL_WINDOWPOS_UNDEFINED, // x position
86 SDL_WINDOWPOS_UNDEFINED, // y position 83 SDL_WINDOWPOS_UNDEFINED, // y position
87 VideoCore::kScreenTopWidth, 84 VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight,
88 VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight,
89 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); 85 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
90 86
91 if (render_window == nullptr) { 87 if (render_window == nullptr) {
@@ -171,10 +167,14 @@ void EmuWindow_SDL2::DoneCurrent() {
171void EmuWindow_SDL2::ReloadSetKeymaps() { 167void EmuWindow_SDL2::ReloadSetKeymaps() {
172 KeyMap::ClearKeyMapping(keyboard_id); 168 KeyMap::ClearKeyMapping(keyboard_id);
173 for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { 169 for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
174 KeyMap::SetKeyMapping({ Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id }, KeyMap::mapping_targets[i]); 170 KeyMap::SetKeyMapping(
171 {Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id},
172 KeyMap::mapping_targets[i]);
175 } 173 }
176} 174}
177 175
178void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) { 176void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(
177 const std::pair<unsigned, unsigned>& minimal_size) {
178
179 SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); 179 SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second);
180} 180}
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 @@
5#pragma once 5#pragma once
6 6
7#include <utility> 7#include <utility>
8
9#include "common/emu_window.h" 8#include "common/emu_window.h"
10 9
11struct SDL_Window; 10struct SDL_Window;
@@ -47,7 +46,8 @@ private:
47 void OnResize(); 46 void OnResize();
48 47
49 /// Called when a configuration change affects the minimal size of the window 48 /// Called when a configuration change affects the minimal size of the window
50 void OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) override; 49 void OnMinimalClientAreaChangeRequest(
50 const std::pair<unsigned, unsigned>& minimal_size) override;
51 51
52 /// Is the window still open? 52 /// Is the window still open?
53 bool is_open = true; 53 bool is_open = true;
@@ -55,7 +55,7 @@ private:
55 /// Internal SDL2 render window 55 /// Internal SDL2 render window
56 SDL_Window* render_window; 56 SDL_Window* render_window;
57 57
58 using SDL_GLContext = void *; 58 using SDL_GLContext = void*;
59 /// The OpenGL context associated with the window 59 /// The OpenGL context associated with the window
60 SDL_GLContext gl_context; 60 SDL_GLContext gl_context;
61 61
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 @@
2// Microsoft Visual C++ generated include file. 2// Microsoft Visual C++ generated include file.
3// Used by pcafe.rc 3// Used by pcafe.rc
4// 4//
5#define IDI_ICON3 103 5#define IDI_ICON3 103
6 6
7// Next default values for new objects 7// Next default values for new objects
8// 8//
9#ifdef APSTUDIO_INVOKED 9#ifdef APSTUDIO_INVOKED
10#ifndef APSTUDIO_READONLY_SYMBOLS 10#ifndef APSTUDIO_READONLY_SYMBOLS
11#define _APS_NEXT_RESOURCE_VALUE 105 11#define _APS_NEXT_RESOURCE_VALUE 105
12#define _APS_NEXT_COMMAND_VALUE 40001 12#define _APS_NEXT_COMMAND_VALUE 40001
13#define _APS_NEXT_CONTROL_VALUE 1001 13#define _APS_NEXT_CONTROL_VALUE 1001
14#define _APS_NEXT_SYMED_VALUE 101 14#define _APS_NEXT_SYMED_VALUE 101
15#endif 15#endif
16#endif 16#endif