summaryrefslogtreecommitdiffstats
path: root/src/citra
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra')
-rw-r--r--src/citra/CMakeLists.txt2
-rw-r--r--src/citra/citra.cpp20
-rw-r--r--src/citra/config.cpp60
-rw-r--r--src/citra/default_ini.h85
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp25
-rw-r--r--src/citra/emu_window/emu_window_sdl2.h6
6 files changed, 132 insertions, 66 deletions
diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt
index ecb5d2dfe..47231ba71 100644
--- a/src/citra/CMakeLists.txt
+++ b/src/citra/CMakeLists.txt
@@ -18,7 +18,7 @@ create_directory_groups(${SRCS} ${HEADERS})
include_directories(${SDL2_INCLUDE_DIR})
add_executable(citra ${SRCS} ${HEADERS})
-target_link_libraries(citra core video_core audio_core common)
+target_link_libraries(citra core video_core audio_core common input_common)
target_link_libraries(citra ${SDL2_LIBRARY} ${OPENGL_gl_LIBRARY} inih glad)
if (MSVC)
target_link_libraries(citra getopt)
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 99c096ac7..76f5caeb1 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -141,6 +141,26 @@ int main(int argc, char** argv) {
case Core::System::ResultStatus::ErrorLoader:
LOG_CRITICAL(Frontend, "Failed to load ROM!");
return -1;
+ case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
+ LOG_CRITICAL(Frontend, "The game that you are trying to load must be decrypted before "
+ "being used with Citra. \n\n For more information on dumping and "
+ "decrypting games, please refer to: "
+ "https://citra-emu.org/wiki/Dumping-Game-Cartridges");
+ return -1;
+ case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
+ LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
+ return -1;
+ case Core::System::ResultStatus::ErrorNotInitialized:
+ LOG_CRITICAL(Frontend, "CPUCore not initialized");
+ return -1;
+ case Core::System::ResultStatus::ErrorSystemMode:
+ LOG_CRITICAL(Frontend, "Failed to determine system mode!");
+ return -1;
+ case Core::System::ResultStatus::ErrorVideoCore:
+ LOG_CRITICAL(Frontend, "VideoCore not initialized");
+ return -1;
+ case Core::System::ResultStatus::Success:
+ break; // Expected case
}
while (emu_window->IsOpen()) {
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 2314e3f95..a4162e9ad 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -8,8 +8,10 @@
#include "citra/default_ini.h"
#include "common/file_util.h"
#include "common/logging/log.h"
+#include "common/param_package.h"
#include "config.h"
#include "core/settings.h"
+#include "input_common/main.h"
Config::Config() {
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
@@ -37,25 +39,40 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) {
return true;
}
-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,
-
- // indirectly mapped keys
- SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D,
+static const std::array<int, Settings::NativeButton::NumButtons> default_buttons = {
+ SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_T,
+ SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_Q, SDL_SCANCODE_W,
+ SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_B,
};
+static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{
+ {
+ SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D,
+ },
+ {
+ SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L, SDL_SCANCODE_D,
+ },
+}};
+
void Config::ReadValues() {
// Controls
- for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
- Settings::values.input_mappings[Settings::NativeInput::All[i]] =
- sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
+ for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
+ std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
+ Settings::values.buttons[i] =
+ sdl2_config->Get("Controls", Settings::NativeButton::mapping[i], default_param);
+ if (Settings::values.buttons[i].empty())
+ Settings::values.buttons[i] = default_param;
+ }
+
+ for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
+ std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
+ default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
+ default_analogs[i][3], default_analogs[i][4], 0.5f);
+ Settings::values.analogs[i] =
+ sdl2_config->Get("Controls", Settings::NativeAnalog::mapping[i], default_param);
+ if (Settings::values.analogs[i].empty())
+ Settings::values.analogs[i] = default_param;
}
- 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);
@@ -110,6 +127,21 @@ void Config::ReadValues() {
Settings::values.region_value =
sdl2_config->GetInteger("System", "region_value", Settings::REGION_VALUE_AUTO_SELECT);
+ // Camera
+ using namespace Service::CAM;
+ Settings::values.camera_name[OuterRightCamera] =
+ sdl2_config->Get("Camera", "camera_outer_right_name", "blank");
+ Settings::values.camera_config[OuterRightCamera] =
+ sdl2_config->Get("Camera", "camera_outer_right_config", "");
+ Settings::values.camera_name[InnerCamera] =
+ sdl2_config->Get("Camera", "camera_inner_name", "blank");
+ Settings::values.camera_config[InnerCamera] =
+ sdl2_config->Get("Camera", "camera_inner_config", "");
+ Settings::values.camera_name[OuterLeftCamera] =
+ sdl2_config->Get("Camera", "camera_outer_left_name", "blank");
+ Settings::values.camera_config[OuterLeftCamera] =
+ sdl2_config->Get("Camera", "camera_outer_left_config", "");
+
// Miscellaneous
Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Info");
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index fd9a9273a..084372df4 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -8,34 +8,47 @@ namespace DefaultINI {
const char* sdl2_config_file = R"(
[Controls]
-pad_start =
-pad_select =
-pad_home =
-pad_dup =
-pad_ddown =
-pad_dleft =
-pad_dright =
-pad_a =
-pad_b =
-pad_x =
-pad_y =
-pad_l =
-pad_r =
-pad_zl =
-pad_zr =
-pad_cup =
-pad_cdown =
-pad_cleft =
-pad_cright =
-pad_circle_up =
-pad_circle_down =
-pad_circle_left =
-pad_circle_right =
-pad_circle_modifier =
-
-# The applied modifier scale to circle pad.
-# Must be in range of 0.0-1.0. Defaults to 0.5
-pad_circle_modifier_scale =
+# The input devices and parameters for each 3DS native input
+# It should be in the format of "engine:[engine_name],[param1]:[value1],[param2]:[value2]..."
+# Escape characters $0 (for ':'), $1 (for ',') and $2 (for '$') can be used in values
+
+# for button input, the following devices are avaible:
+# - "keyboard" (default) for keyboard input. Required parameters:
+# - "code": the code of the key to bind
+# - "sdl" for joystick input using SDL. Required parameters:
+# - "joystick": the index of the joystick to bind
+# - "button"(optional): the index of the button to bind
+# - "hat"(optional): the index of the hat to bind as direction buttons
+# - "direction"(only used for hat): the direction name of the hat to bind. Can be "up", "down", "left" or "right"
+button_a=
+button_b=
+button_x=
+button_y=
+button_up=
+button_down=
+button_left=
+button_right=
+button_l=
+button_r=
+button_start=
+button_select=
+button_zl=
+button_zr=
+button_home=
+
+# for analog input, the following devices are avaible:
+# - "analog_from_button" (default) for emulating analog input from direction buttons. Required parameters:
+# - "up", "down", "left", "right": sub-devices for each direction.
+# Should be in the format as a button input devices using escape characters, for example, "engine$0keyboard$1code$00"
+# - "modifier": sub-devices as a modifier.
+# - "modifier_scale": a float number representing the applied modifier scale to the analog input.
+# Must be in range of 0.0-1.0. Defaults to 0.5
+# - "sdl" for joystick input using SDL. Required parameters:
+# - "joystick": the index of the joystick to bind
+# - "axis_x": the index of the axis to bind as x-axis (default to 0)
+# - "axis_y": the index of the axis to bind as y-axis (default to 1)
+circle_pad=
+c_stick=
[Core]
# Whether to use the Just-In-Time (JIT) compiler for CPU emulation
@@ -124,6 +137,22 @@ is_new_3ds =
# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
region_value =
+[Camera]
+# Which camera engine to use for the right outer camera
+# blank (default): a dummy camera that always returns black image
+camera_outer_right_name =
+
+# A config string for the right outer camera. Its meaning is defined by the camera engine
+camera_outer_right_config =
+
+# ... for the left outer camera
+camera_outer_left_name =
+camera_outer_left_config =
+
+# ... for the inner camera
+camera_inner_name =
+camera_inner_config =
+
[Miscellaneous]
# A filter which removes logs below a certain logging level.
# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp
index 81a3abe3f..6bc0b0d00 100644
--- a/src/citra/emu_window/emu_window_sdl2.cpp
+++ b/src/citra/emu_window/emu_window_sdl2.cpp
@@ -12,9 +12,9 @@
#include "common/logging/log.h"
#include "common/scm_rev.h"
#include "common/string_util.h"
-#include "core/frontend/key_map.h"
-#include "core/hle/service/hid/hid.h"
#include "core/settings.h"
+#include "input_common/keyboard.h"
+#include "input_common/main.h"
#include "video_core/video_core.h"
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
@@ -40,9 +40,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});
+ InputCommon::GetKeyboard()->PressKey(key);
} else if (state == SDL_RELEASED) {
- KeyMap::ReleaseKey(*this, {key, keyboard_id});
+ InputCommon::GetKeyboard()->ReleaseKey(key);
}
}
@@ -57,9 +57,8 @@ void EmuWindow_SDL2::OnResize() {
}
EmuWindow_SDL2::EmuWindow_SDL2() {
- keyboard_id = KeyMap::NewDeviceId();
+ InputCommon::Init();
- ReloadSetKeymaps();
motion_emu = std::make_unique<Motion::MotionEmu>(*this);
SDL_SetMainReady();
@@ -79,8 +78,8 @@ 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);
+ std::string window_title = Common::StringFromFormat("Citra %s| %s-%s ", Common::g_build_name,
+ Common::g_scm_branch, Common::g_scm_desc);
render_window = SDL_CreateWindow(
window_title.c_str(),
SDL_WINDOWPOS_UNDEFINED, // x position
@@ -117,6 +116,7 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
SDL_GL_DeleteContext(gl_context);
SDL_Quit();
motion_emu = nullptr;
+ InputCommon::Shutdown();
}
void EmuWindow_SDL2::SwapBuffers() {
@@ -169,15 +169,6 @@ void EmuWindow_SDL2::DoneCurrent() {
SDL_GL_MakeCurrent(render_window, nullptr);
}
-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]);
- }
-}
-
void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(
const std::pair<unsigned, unsigned>& minimal_size) {
diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h
index b1cbf16d7..1ce2991f7 100644
--- a/src/citra/emu_window/emu_window_sdl2.h
+++ b/src/citra/emu_window/emu_window_sdl2.h
@@ -31,9 +31,6 @@ public:
/// Whether the window is still open, and a close request hasn't yet been sent
bool IsOpen() const;
- /// Load keymap from configuration
- void ReloadSetKeymaps() override;
-
private:
/// Called by PollEvents when a key is pressed or released.
void OnKeyEvent(int key, u8 state);
@@ -61,9 +58,6 @@ private:
/// The OpenGL context associated with the window
SDL_GLContext gl_context;
- /// Device id of keyboard for use with KeyMap
- int keyboard_id;
-
/// Motion sensors emulation
std::unique_ptr<Motion::MotionEmu> motion_emu;
};