diff options
Diffstat (limited to 'src/citra')
| -rw-r--r-- | src/citra/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/citra/citra.cpp | 42 | ||||
| -rw-r--r-- | src/citra/config.cpp | 39 | ||||
| -rw-r--r-- | src/citra/config.h | 6 | ||||
| -rw-r--r-- | src/citra/default_ini.h | 4 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 41 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.h | 2 |
7 files changed, 78 insertions, 63 deletions
diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 713f49193..918687312 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt | |||
| @@ -16,6 +16,11 @@ create_directory_groups(${SRCS} ${HEADERS}) | |||
| 16 | add_executable(citra ${SRCS} ${HEADERS}) | 16 | add_executable(citra ${SRCS} ${HEADERS}) |
| 17 | target_link_libraries(citra core common video_core) | 17 | target_link_libraries(citra core common video_core) |
| 18 | target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih) | 18 | target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih) |
| 19 | if (MSVC) | ||
| 20 | target_link_libraries(citra getopt) | ||
| 21 | endif() | ||
| 19 | target_link_libraries(citra ${PLATFORM_LIBRARIES}) | 22 | target_link_libraries(citra ${PLATFORM_LIBRARIES}) |
| 20 | 23 | ||
| 21 | #install(TARGETS citra RUNTIME DESTINATION ${bindir}) | 24 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD|NetBSD") |
| 25 | install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") | ||
| 26 | endif() \ No newline at end of file | ||
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index ce8d7dd25..182646f4c 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp | |||
| @@ -2,13 +2,20 @@ | |||
| 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> | ||
| 5 | #include <thread> | 6 | #include <thread> |
| 7 | #include <iostream> | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <getopt.h> | ||
| 11 | #else | ||
| 12 | #include <unistd.h> | ||
| 13 | #include <getopt.h> | ||
| 14 | #endif | ||
| 6 | 15 | ||
| 7 | #include "common/logging/log.h" | 16 | #include "common/logging/log.h" |
| 8 | #include "common/logging/text_formatter.h" | ||
| 9 | #include "common/logging/backend.h" | 17 | #include "common/logging/backend.h" |
| 10 | #include "common/logging/filter.h" | 18 | #include "common/logging/filter.h" |
| 11 | #include "common/scope_exit.h" | ||
| 12 | 19 | ||
| 13 | #include "core/settings.h" | 20 | #include "core/settings.h" |
| 14 | #include "core/system.h" | 21 | #include "core/system.h" |
| @@ -20,12 +27,39 @@ | |||
| 20 | 27 | ||
| 21 | #include "video_core/video_core.h" | 28 | #include "video_core/video_core.h" |
| 22 | 29 | ||
| 30 | |||
| 31 | static void PrintHelp() | ||
| 32 | { | ||
| 33 | std::cout << "Usage: citra <filename>" << std::endl; | ||
| 34 | } | ||
| 35 | |||
| 23 | /// Application entry point | 36 | /// Application entry point |
| 24 | int main(int argc, char **argv) { | 37 | int main(int argc, char **argv) { |
| 38 | int option_index = 0; | ||
| 39 | std::string boot_filename; | ||
| 40 | static struct option long_options[] = { | ||
| 41 | { "help", no_argument, 0, 'h' }, | ||
| 42 | { 0, 0, 0, 0 } | ||
| 43 | }; | ||
| 44 | |||
| 45 | while (optind < argc) { | ||
| 46 | char arg = getopt_long(argc, argv, ":h", long_options, &option_index); | ||
| 47 | if (arg != -1) { | ||
| 48 | switch (arg) { | ||
| 49 | case 'h': | ||
| 50 | PrintHelp(); | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | } else { | ||
| 54 | boot_filename = argv[optind]; | ||
| 55 | optind++; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 25 | Log::Filter log_filter(Log::Level::Debug); | 59 | Log::Filter log_filter(Log::Level::Debug); |
| 26 | Log::SetFilter(&log_filter); | 60 | Log::SetFilter(&log_filter); |
| 27 | 61 | ||
| 28 | if (argc < 2) { | 62 | if (boot_filename.empty()) { |
| 29 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); | 63 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); |
| 30 | return -1; | 64 | return -1; |
| 31 | } | 65 | } |
| @@ -33,7 +67,7 @@ int main(int argc, char **argv) { | |||
| 33 | Config config; | 67 | Config config; |
| 34 | log_filter.ParseFilterString(Settings::values.log_filter); | 68 | log_filter.ParseFilterString(Settings::values.log_filter); |
| 35 | 69 | ||
| 36 | std::string boot_filename = argv[1]; | 70 | |
| 37 | EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; | 71 | EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; |
| 38 | 72 | ||
| 39 | VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer; | 73 | VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer; |
diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 1378567c1..2c1407a6f 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp | |||
| @@ -2,7 +2,9 @@ | |||
| 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 | #define GLFW_INCLUDE_NONE | ||
| 5 | #include <GLFW/glfw3.h> | 6 | #include <GLFW/glfw3.h> |
| 7 | #include <inih/cpp/INIReader.h> | ||
| 6 | 8 | ||
| 7 | #include "citra/default_ini.h" | 9 | #include "citra/default_ini.h" |
| 8 | 10 | ||
| @@ -10,7 +12,6 @@ | |||
| 10 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 11 | 13 | ||
| 12 | #include "core/settings.h" | 14 | #include "core/settings.h" |
| 13 | #include "core/core.h" | ||
| 14 | 15 | ||
| 15 | #include "config.h" | 16 | #include "config.h" |
| 16 | 17 | ||
| @@ -39,31 +40,21 @@ bool Config::LoadINI(INIReader* config, const char* location, const std::string& | |||
| 39 | return true; | 40 | return true; |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 43 | static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { | ||
| 44 | GLFW_KEY_A, GLFW_KEY_S, GLFW_KEY_Z, GLFW_KEY_X, | ||
| 45 | GLFW_KEY_Q, GLFW_KEY_W, GLFW_KEY_1, GLFW_KEY_2, | ||
| 46 | GLFW_KEY_M, GLFW_KEY_N, GLFW_KEY_B, | ||
| 47 | GLFW_KEY_T, GLFW_KEY_G, GLFW_KEY_F, GLFW_KEY_H, | ||
| 48 | GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT, | ||
| 49 | GLFW_KEY_I, GLFW_KEY_K, GLFW_KEY_J, GLFW_KEY_L | ||
| 50 | }; | ||
| 51 | |||
| 42 | void Config::ReadValues() { | 52 | void Config::ReadValues() { |
| 43 | // Controls | 53 | // Controls |
| 44 | Settings::values.pad_a_key = glfw_config->GetInteger("Controls", "pad_a", GLFW_KEY_A); | 54 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { |
| 45 | Settings::values.pad_b_key = glfw_config->GetInteger("Controls", "pad_b", GLFW_KEY_S); | 55 | Settings::values.input_mappings[Settings::NativeInput::All[i]] = |
| 46 | Settings::values.pad_x_key = glfw_config->GetInteger("Controls", "pad_x", GLFW_KEY_Z); | 56 | glfw_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); |
| 47 | Settings::values.pad_y_key = glfw_config->GetInteger("Controls", "pad_y", GLFW_KEY_X); | 57 | } |
| 48 | Settings::values.pad_l_key = glfw_config->GetInteger("Controls", "pad_l", GLFW_KEY_Q); | ||
| 49 | Settings::values.pad_r_key = glfw_config->GetInteger("Controls", "pad_r", GLFW_KEY_W); | ||
| 50 | Settings::values.pad_zl_key = glfw_config->GetInteger("Controls", "pad_zl", GLFW_KEY_1); | ||
| 51 | Settings::values.pad_zr_key = glfw_config->GetInteger("Controls", "pad_zr", GLFW_KEY_2); | ||
| 52 | Settings::values.pad_start_key = glfw_config->GetInteger("Controls", "pad_start", GLFW_KEY_M); | ||
| 53 | Settings::values.pad_select_key = glfw_config->GetInteger("Controls", "pad_select", GLFW_KEY_N); | ||
| 54 | Settings::values.pad_home_key = glfw_config->GetInteger("Controls", "pad_home", GLFW_KEY_B); | ||
| 55 | Settings::values.pad_dup_key = glfw_config->GetInteger("Controls", "pad_dup", GLFW_KEY_T); | ||
| 56 | Settings::values.pad_ddown_key = glfw_config->GetInteger("Controls", "pad_ddown", GLFW_KEY_G); | ||
| 57 | Settings::values.pad_dleft_key = glfw_config->GetInteger("Controls", "pad_dleft", GLFW_KEY_F); | ||
| 58 | Settings::values.pad_dright_key = glfw_config->GetInteger("Controls", "pad_dright", GLFW_KEY_H); | ||
| 59 | Settings::values.pad_sup_key = glfw_config->GetInteger("Controls", "pad_sup", GLFW_KEY_UP); | ||
| 60 | Settings::values.pad_sdown_key = glfw_config->GetInteger("Controls", "pad_sdown", GLFW_KEY_DOWN); | ||
| 61 | Settings::values.pad_sleft_key = glfw_config->GetInteger("Controls", "pad_sleft", GLFW_KEY_LEFT); | ||
| 62 | Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT); | ||
| 63 | Settings::values.pad_cup_key = glfw_config->GetInteger("Controls", "pad_cup", GLFW_KEY_I); | ||
| 64 | Settings::values.pad_cdown_key = glfw_config->GetInteger("Controls", "pad_cdown", GLFW_KEY_K); | ||
| 65 | Settings::values.pad_cleft_key = glfw_config->GetInteger("Controls", "pad_cleft", GLFW_KEY_J); | ||
| 66 | Settings::values.pad_cright_key = glfw_config->GetInteger("Controls", "pad_cright", GLFW_KEY_L); | ||
| 67 | 58 | ||
| 68 | // Core | 59 | // Core |
| 69 | Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0); | 60 | Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0); |
diff --git a/src/citra/config.h b/src/citra/config.h index 0eb176c7d..c326ec669 100644 --- a/src/citra/config.h +++ b/src/citra/config.h | |||
| @@ -4,11 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <map> | 7 | #include <string> |
| 8 | 8 | ||
| 9 | #include <inih/cpp/INIReader.h> | 9 | class INIReader; |
| 10 | |||
| 11 | #include "common/common_types.h" | ||
| 12 | 10 | ||
| 13 | class Config { | 11 | class Config { |
| 14 | INIReader* glfw_config; | 12 | INIReader* glfw_config; |
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index fd5a90d56..1925bece8 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h | |||
| @@ -33,10 +33,6 @@ pad_cleft = | |||
| 33 | pad_cright = | 33 | pad_cright = |
| 34 | 34 | ||
| 35 | [Core] | 35 | [Core] |
| 36 | # The refresh rate for the GPU | ||
| 37 | # Defaults to 30 | ||
| 38 | gpu_refresh_rate = | ||
| 39 | |||
| 40 | # The applied frameskip amount. Must be a power of two. | 36 | # The applied frameskip amount. Must be a power of two. |
| 41 | # 0 (default): No frameskip, 1: x2 frameskip, 2: x4 frameskip, 3: x8 frameskip, etc. | 37 | # 0 (default): No frameskip, 1: x2 frameskip, 2: x4 frameskip, 3: x8 frameskip, etc. |
| 42 | frame_skip = | 38 | frame_skip = |
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 341b48d2a..6d6656b5a 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp | |||
| @@ -2,13 +2,25 @@ | |||
| 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 <algorithm> | ||
| 6 | #include <cstdlib> | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | // Let’s use our own GL header, instead of one from GLFW. | ||
| 10 | #include "video_core/renderer_opengl/generated/gl_3_2_core.h" | ||
| 11 | #define GLFW_INCLUDE_NONE | ||
| 5 | #include <GLFW/glfw3.h> | 12 | #include <GLFW/glfw3.h> |
| 6 | 13 | ||
| 14 | #include "common/assert.h" | ||
| 15 | #include "common/key_map.h" | ||
| 7 | #include "common/logging/log.h" | 16 | #include "common/logging/log.h" |
| 17 | #include "common/scm_rev.h" | ||
| 18 | #include "common/string_util.h" | ||
| 8 | 19 | ||
| 9 | #include "video_core/video_core.h" | 20 | #include "video_core/video_core.h" |
| 10 | 21 | ||
| 11 | #include "core/settings.h" | 22 | #include "core/settings.h" |
| 23 | #include "core/hle/service/hid/hid.h" | ||
| 12 | 24 | ||
| 13 | #include "citra/emu_window/emu_window_glfw.h" | 25 | #include "citra/emu_window/emu_window_glfw.h" |
| 14 | 26 | ||
| @@ -138,32 +150,9 @@ void EmuWindow_GLFW::DoneCurrent() { | |||
| 138 | } | 150 | } |
| 139 | 151 | ||
| 140 | void EmuWindow_GLFW::ReloadSetKeymaps() { | 152 | void EmuWindow_GLFW::ReloadSetKeymaps() { |
| 141 | KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, Service::HID::PAD_A); | 153 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { |
| 142 | KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, Service::HID::PAD_B); | 154 | KeyMap::SetKeyMapping({Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id}, Service::HID::pad_mapping[i]); |
| 143 | KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, Service::HID::PAD_SELECT); | 155 | } |
| 144 | KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, Service::HID::PAD_START); | ||
| 145 | KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, Service::HID::PAD_RIGHT); | ||
| 146 | KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, Service::HID::PAD_LEFT); | ||
| 147 | KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, Service::HID::PAD_UP); | ||
| 148 | KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, Service::HID::PAD_DOWN); | ||
| 149 | KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, Service::HID::PAD_R); | ||
| 150 | KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, Service::HID::PAD_L); | ||
| 151 | KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, Service::HID::PAD_X); | ||
| 152 | KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, Service::HID::PAD_Y); | ||
| 153 | |||
| 154 | KeyMap::SetKeyMapping({Settings::values.pad_zl_key, keyboard_id}, Service::HID::PAD_ZL); | ||
| 155 | KeyMap::SetKeyMapping({Settings::values.pad_zr_key, keyboard_id}, Service::HID::PAD_ZR); | ||
| 156 | |||
| 157 | // KeyMap::SetKeyMapping({Settings::values.pad_touch_key, keyboard_id}, Service::HID::PAD_TOUCH); | ||
| 158 | |||
| 159 | KeyMap::SetKeyMapping({Settings::values.pad_cright_key, keyboard_id}, Service::HID::PAD_C_RIGHT); | ||
| 160 | KeyMap::SetKeyMapping({Settings::values.pad_cleft_key, keyboard_id}, Service::HID::PAD_C_LEFT); | ||
| 161 | KeyMap::SetKeyMapping({Settings::values.pad_cup_key, keyboard_id}, Service::HID::PAD_C_UP); | ||
| 162 | KeyMap::SetKeyMapping({Settings::values.pad_cdown_key, keyboard_id}, Service::HID::PAD_C_DOWN); | ||
| 163 | KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, Service::HID::PAD_CIRCLE_RIGHT); | ||
| 164 | KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, Service::HID::PAD_CIRCLE_LEFT); | ||
| 165 | KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, Service::HID::PAD_CIRCLE_UP); | ||
| 166 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, Service::HID::PAD_CIRCLE_DOWN); | ||
| 167 | } | 156 | } |
| 168 | 157 | ||
| 169 | void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { | 158 | void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { |
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h index 16c109b79..7ccd5e6aa 100644 --- a/src/citra/emu_window/emu_window_glfw.h +++ b/src/citra/emu_window/emu_window_glfw.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <utility> | ||
| 8 | |||
| 7 | #include "common/emu_window.h" | 9 | #include "common/emu_window.h" |
| 8 | 10 | ||
| 9 | struct GLFWwindow; | 11 | struct GLFWwindow; |