summaryrefslogtreecommitdiff
path: root/src/citra
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/citra.cpp39
-rw-r--r--src/citra/config.cpp31
-rw-r--r--src/citra/config.h3
-rw-r--r--src/citra/default_ini.h1
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp25
-rw-r--r--src/citra/emu_window/emu_window_sdl2.h5
-rw-r--r--src/citra/resource.h10
7 files changed, 60 insertions, 54 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 128b9a16d..7b387e258 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,51 @@
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"
25#include "common/logging/backend.h" 24#include "common/logging/backend.h"
26#include "common/logging/filter.h" 25#include "common/logging/filter.h"
26#include "common/logging/log.h"
27#include "common/scm_rev.h" 27#include "common/scm_rev.h"
28#include "common/scope_exit.h" 28#include "common/scope_exit.h"
29#include "common/string_util.h" 29#include "common/string_util.h"
30 30
31#include "core/settings.h"
32#include "core/system.h"
33#include "core/core.h" 31#include "core/core.h"
34#include "core/gdbstub/gdbstub.h" 32#include "core/gdbstub/gdbstub.h"
35#include "core/loader/loader.h" 33#include "core/loader/loader.h"
34#include "core/settings.h"
35#include "core/system.h"
36 36
37#include "citra/config.h" 37#include "citra/config.h"
38#include "citra/emu_window/emu_window_sdl2.h" 38#include "citra/emu_window/emu_window_sdl2.h"
39 39
40#include "video_core/video_core.h" 40#include "video_core/video_core.h"
41 41
42 42static void PrintHelp(const char* argv0) {
43static void PrintHelp(const char *argv0) 43 std::cout << "Usage: " << argv0
44{ 44 << " [options] <filename>\n"
45 std::cout << "Usage: " << argv0 << " [options] <filename>\n"
46 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" 45 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
47 "-h, --help Display this help and exit\n" 46 "-h, --help Display this help and exit\n"
48 "-v, --version Output version information and exit\n"; 47 "-v, --version Output version information and exit\n";
49} 48}
50 49
51static void PrintVersion() 50static void PrintVersion() {
52{
53 std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl; 51 std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl;
54} 52}
55 53
56/// Application entry point 54/// Application entry point
57int main(int argc, char **argv) { 55int main(int argc, char** argv) {
58 Config config; 56 Config config;
59 int option_index = 0; 57 int option_index = 0;
60 bool use_gdbstub = Settings::values.use_gdbstub; 58 bool use_gdbstub = Settings::values.use_gdbstub;
61 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port); 59 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
62 char *endarg; 60 char* endarg;
63#ifdef _WIN32 61#ifdef _WIN32
64 int argc_w; 62 int argc_w;
65 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w); 63 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
@@ -71,12 +69,10 @@ int main(int argc, char **argv) {
71#endif 69#endif
72 std::string boot_filename; 70 std::string boot_filename;
73 71
74 static struct option long_options[] = { 72 static struct option long_options[] = {{"gdbport", required_argument, 0, 'g'},
75 { "gdbport", required_argument, 0, 'g' }, 73 {"help", no_argument, 0, 'h'},
76 { "help", no_argument, 0, 'h' }, 74 {"version", no_argument, 0, 'v'},
77 { "version", no_argument, 0, 'v' }, 75 {0, 0, 0, 0}};
78 { 0, 0, 0, 0 }
79 };
80 76
81 while (optind < argc) { 77 while (optind < argc) {
82 char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index); 78 char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index);
@@ -86,7 +82,8 @@ int main(int argc, char **argv) {
86 errno = 0; 82 errno = 0;
87 gdb_port = strtoul(optarg, &endarg, 0); 83 gdb_port = strtoul(optarg, &endarg, 0);
88 use_gdbstub = true; 84 use_gdbstub = true;
89 if (endarg == optarg) errno = EINVAL; 85 if (endarg == optarg)
86 errno = EINVAL;
90 if (errno != 0) { 87 if (errno != 0) {
91 perror("--gdbport"); 88 perror("--gdbport");
92 exit(1); 89 exit(1);
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 1a09f0e55..77679bd88 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -45,15 +45,13 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) {
45 45
46static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { 46static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
47 // directly mapped keys 47 // directly mapped keys
48 SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, 48 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, 49 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, 50 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, 51 SDL_SCANCODE_L,
52 SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L,
53 52
54 // indirectly mapped keys 53 // indirectly mapped keys
55 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, 54 SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D,
56 SDL_SCANCODE_D,
57}; 55};
58 56
59void Config::ReadValues() { 57void Config::ReadValues() {
@@ -62,7 +60,8 @@ void Config::ReadValues() {
62 Settings::values.input_mappings[Settings::NativeInput::All[i]] = 60 Settings::values.input_mappings[Settings::NativeInput::All[i]] =
63 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); 61 sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
64 } 62 }
65 Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); 63 Settings::values.pad_circle_modifier_scale =
64 (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5);
66 65
67 // Core 66 // Core
68 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); 67 Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true);
@@ -71,19 +70,22 @@ void Config::ReadValues() {
71 // Renderer 70 // Renderer
72 Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true); 71 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); 72 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); 73 Settings::values.use_scaled_resolution =
74 sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false);
75 Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false); 75 Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false);
76 76
77 Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 1.0); 77 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); 78 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); 79 Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0);
80 80
81 // Audio 81 // Audio
82 Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); 82 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); 83 Settings::values.enable_audio_stretching =
84 sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true);
84 85
85 // Data Storage 86 // Data Storage
86 Settings::values.use_virtual_sd = sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); 87 Settings::values.use_virtual_sd =
88 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
87 89
88 // System 90 // System
89 Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", false); 91 Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", false);
@@ -94,7 +96,8 @@ void Config::ReadValues() {
94 96
95 // Debugging 97 // Debugging
96 Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false); 98 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)); 99 Settings::values.gdbstub_port =
100 static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689));
98} 101}
99 102
100void Config::Reload() { 103void Config::Reload() {
diff --git a/src/citra/config.h b/src/citra/config.h
index 52a478146..8bd2b294b 100644
--- a/src/citra/config.h
+++ b/src/citra/config.h
@@ -13,8 +13,9 @@ class Config {
13 std::unique_ptr<INIReader> sdl2_config; 13 std::unique_ptr<INIReader> sdl2_config;
14 std::string sdl2_config_loc; 14 std::string sdl2_config_loc;
15 15
16 bool LoadINI(const std::string& default_contents="", bool retry=true); 16 bool LoadINI(const std::string& default_contents = "", bool retry = true);
17 void ReadValues(); 17 void ReadValues();
18
18public: 19public:
19 Config(); 20 Config();
20 21
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..12f3e2c71 100644
--- a/src/citra/emu_window/emu_window_sdl2.cpp
+++ b/src/citra/emu_window/emu_window_sdl2.cpp
@@ -16,8 +16,8 @@
16#include "common/scm_rev.h" 16#include "common/scm_rev.h"
17#include "common/string_util.h" 17#include "common/string_util.h"
18 18
19#include "core/settings.h"
20#include "core/hle/service/hid/hid.h" 19#include "core/hle/service/hid/hid.h"
20#include "core/settings.h"
21 21
22#include "citra/emu_window/emu_window_sdl2.h" 22#include "citra/emu_window/emu_window_sdl2.h"
23 23
@@ -40,9 +40,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
40 40
41void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { 41void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
42 if (state == SDL_PRESSED) { 42 if (state == SDL_PRESSED) {
43 KeyMap::PressKey(*this, { key, keyboard_id }); 43 KeyMap::PressKey(*this, {key, keyboard_id});
44 } else if (state == SDL_RELEASED) { 44 } else if (state == SDL_RELEASED) {
45 KeyMap::ReleaseKey(*this, { key, keyboard_id }); 45 KeyMap::ReleaseKey(*this, {key, keyboard_id});
46 } 46 }
47} 47}
48 48
@@ -55,7 +55,8 @@ void EmuWindow_SDL2::OnResize() {
55 55
56 SDL_GetWindowSize(render_window, &width, &height); 56 SDL_GetWindowSize(render_window, &width, &height);
57 57
58 NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); 58 NotifyFramebufferLayoutChanged(
59 EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height));
59} 60}
60 61
61EmuWindow_SDL2::EmuWindow_SDL2() { 62EmuWindow_SDL2::EmuWindow_SDL2() {
@@ -80,12 +81,13 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
80 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); 81 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
81 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); 82 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
82 83
83 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); 84 std::string window_title =
84 render_window = SDL_CreateWindow(window_title.c_str(), 85 Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
86 render_window = SDL_CreateWindow(
87 window_title.c_str(),
85 SDL_WINDOWPOS_UNDEFINED, // x position 88 SDL_WINDOWPOS_UNDEFINED, // x position
86 SDL_WINDOWPOS_UNDEFINED, // y position 89 SDL_WINDOWPOS_UNDEFINED, // y position
87 VideoCore::kScreenTopWidth, 90 VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight,
88 VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight,
89 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); 91 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
90 92
91 if (render_window == nullptr) { 93 if (render_window == nullptr) {
@@ -171,10 +173,13 @@ void EmuWindow_SDL2::DoneCurrent() {
171void EmuWindow_SDL2::ReloadSetKeymaps() { 173void EmuWindow_SDL2::ReloadSetKeymaps() {
172 KeyMap::ClearKeyMapping(keyboard_id); 174 KeyMap::ClearKeyMapping(keyboard_id);
173 for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { 175 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]); 176 KeyMap::SetKeyMapping(
177 {Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id},
178 KeyMap::mapping_targets[i]);
175 } 179 }
176} 180}
177 181
178void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) { 182void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(
183 const std::pair<unsigned, unsigned>& minimal_size) {
179 SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); 184 SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second);
180} 185}
diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h
index 77279f022..693dfb14b 100644
--- a/src/citra/emu_window/emu_window_sdl2.h
+++ b/src/citra/emu_window/emu_window_sdl2.h
@@ -47,7 +47,8 @@ private:
47 void OnResize(); 47 void OnResize();
48 48
49 /// Called when a configuration change affects the minimal size of the window 49 /// Called when a configuration change affects the minimal size of the window
50 void OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) override; 50 void
51 OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) override;
51 52
52 /// Is the window still open? 53 /// Is the window still open?
53 bool is_open = true; 54 bool is_open = true;
@@ -55,7 +56,7 @@ private:
55 /// Internal SDL2 render window 56 /// Internal SDL2 render window
56 SDL_Window* render_window; 57 SDL_Window* render_window;
57 58
58 using SDL_GLContext = void *; 59 using SDL_GLContext = void*;
59 /// The OpenGL context associated with the window 60 /// The OpenGL context associated with the window
60 SDL_GLContext gl_context; 61 SDL_GLContext gl_context;
61 62
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