summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/config.cpp3
-rw-r--r--src/yuzu_cmd/default_ini.h40
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp48
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h10
-rw-r--r--src/yuzu_cmd/yuzu.cpp55
5 files changed, 93 insertions, 63 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 527017282..9c34cdc6e 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -176,6 +176,9 @@ void Config::ReadValues() {
176 Settings::values.debug_pad_analogs[i] = default_param; 176 Settings::values.debug_pad_analogs[i] = default_param;
177 } 177 }
178 178
179 ReadSetting("ControlsGeneral", Settings::values.enable_raw_input);
180 ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver);
181 ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard);
179 ReadSetting("ControlsGeneral", Settings::values.vibration_enabled); 182 ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
180 ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations); 183 ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);
181 ReadSetting("ControlsGeneral", Settings::values.motion_enabled); 184 ReadSetting("ControlsGeneral", Settings::values.motion_enabled);
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index 6fcf04e1b..cf3cc4c4e 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -5,8 +5,8 @@
5 5
6namespace DefaultINI { 6namespace DefaultINI {
7 7
8const char* sdl2_config_file = R"( 8const char* sdl2_config_file =
9 9 R"(
10[ControlsP0] 10[ControlsP0]
11# The input devices and parameters for each Switch native input 11# The input devices and parameters for each Switch native input
12# The config section determines the player number where the config will be applied on. For example "ControlsP0", "ControlsP1", ... 12# The config section determines the player number where the config will be applied on. For example "ControlsP0", "ControlsP1", ...
@@ -14,6 +14,7 @@ const char* sdl2_config_file = R"(
14# Escape characters $0 (for ':'), $1 (for ',') and $2 (for '$') can be used in values 14# Escape characters $0 (for ':'), $1 (for ',') and $2 (for '$') can be used in values
15 15
16# Indicates if this player should be connected at boot 16# Indicates if this player should be connected at boot
17# 0 (default): Disabled, 1: Enabled
17connected= 18connected=
18 19
19# for button input, the following devices are available: 20# for button input, the following devices are available:
@@ -94,6 +95,18 @@ motionright=
94# 0 (default): Disabled, 1: Enabled 95# 0 (default): Disabled, 1: Enabled
95debug_pad_enabled = 96debug_pad_enabled =
96 97
98# Enable sdl raw input. Allows to configure up to 8 xinput controllers.
99# 0 (default): Disabled, 1: Enabled
100enable_raw_input =
101
102# Enable yuzu joycon driver instead of SDL drive.
103# 0: Disabled, 1 (default): Enabled
104enable_joycon_driver =
105
106# Emulates an analog input from buttons. Allowing to dial any angle.
107# 0 (default): Disabled, 1: Enabled
108emulate_analog_keyboard =
109
97# Whether to enable or disable vibration 110# Whether to enable or disable vibration
98# 0: Disabled, 1 (default): Enabled 111# 0: Disabled, 1 (default): Enabled
99vibration_enabled= 112vibration_enabled=
@@ -143,6 +156,8 @@ mouse_enabled =
143# 0 (default): Disabled, 1: Enabled 156# 0 (default): Disabled, 1: Enabled
144keyboard_enabled = 157keyboard_enabled =
145 158
159)"
160 R"(
146[Core] 161[Core]
147# Whether to use multi-core for CPU emulation 162# Whether to use multi-core for CPU emulation
148# 0: Disabled, 1 (default): Enabled 163# 0: Disabled, 1 (default): Enabled
@@ -242,6 +257,8 @@ cpuopt_unsafe_fastmem_check =
242# 0: Disabled, 1 (default): Enabled 257# 0: Disabled, 1 (default): Enabled
243cpuopt_unsafe_ignore_global_monitor = 258cpuopt_unsafe_ignore_global_monitor =
244 259
260)"
261 R"(
245[Renderer] 262[Renderer]
246# Which backend API to use. 263# Which backend API to use.
247# 0: OpenGL, 1 (default): Vulkan 264# 0: OpenGL, 1 (default): Vulkan
@@ -269,11 +286,14 @@ vulkan_device =
269# 0: 0.5x (360p/540p) [EXPERIMENTAL] 286# 0: 0.5x (360p/540p) [EXPERIMENTAL]
270# 1: 0.75x (540p/810p) [EXPERIMENTAL] 287# 1: 0.75x (540p/810p) [EXPERIMENTAL]
271# 2 (default): 1x (720p/1080p) 288# 2 (default): 1x (720p/1080p)
272# 3: 2x (1440p/2160p) 289# 3: 1.5x (1080p/1620p) [EXPERIMENTAL]
273# 4: 3x (2160p/3240p) 290# 4: 2x (1440p/2160p)
274# 5: 4x (2880p/4320p) 291# 5: 3x (2160p/3240p)
275# 6: 5x (3600p/5400p) 292# 6: 4x (2880p/4320p)
276# 7: 6x (4320p/6480p) 293# 7: 5x (3600p/5400p)
294# 8: 6x (4320p/6480p)
295# 9: 7x (5040p/7560p)
296# 10: 8x (5760/8640p)
277resolution_setup = 297resolution_setup =
278 298
279# Pixel filter to use when up- or down-sampling rendered frames. 299# Pixel filter to use when up- or down-sampling rendered frames.
@@ -282,11 +302,11 @@ resolution_setup =
282# 2: Bicubic 302# 2: Bicubic
283# 3: Gaussian 303# 3: Gaussian
284# 4: ScaleForce 304# 4: ScaleForce
285# 5: AMD FidelityFX™️ Super Resolution [Vulkan Only] 305# 5: AMD FidelityFX™️ Super Resolution
286scaling_filter = 306scaling_filter =
287 307
288# Anti-Aliasing (AA) 308# Anti-Aliasing (AA)
289# 0 (default): None, 1: FXAA 309# 0 (default): None, 1: FXAA, 2: SMAA
290anti_aliasing = 310anti_aliasing =
291 311
292# Whether to use fullscreen or borderless window mode 312# Whether to use fullscreen or borderless window mode
@@ -360,6 +380,8 @@ bg_red =
360bg_blue = 380bg_blue =
361bg_green = 381bg_green =
362 382
383)"
384 R"(
363[Audio] 385[Audio]
364# Which audio output engine to use. 386# Which audio output engine to use.
365# auto (default): Auto-select 387# auto (default): Auto-select
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index 31f28a507..5450b8c38 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -18,11 +18,11 @@
18 18
19EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_) 19EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_)
20 : input_subsystem{input_subsystem_}, system{system_} { 20 : input_subsystem{input_subsystem_}, system{system_} {
21 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { 21 input_subsystem->Initialize();
22 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) {
22 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); 23 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
23 exit(1); 24 exit(1);
24 } 25 }
25 input_subsystem->Initialize();
26 SDL_SetMainReady(); 26 SDL_SetMainReady();
27} 27}
28 28
@@ -32,10 +32,6 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
32 SDL_Quit(); 32 SDL_Quit();
33} 33}
34 34
35void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
36 input_subsystem->GetMouse()->MouseMove(x, y, 0, 0, 0, 0);
37}
38
39InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const { 35InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
40 switch (button) { 36 switch (button) {
41 case SDL_BUTTON_LEFT: 37 case SDL_BUTTON_LEFT:
@@ -53,44 +49,36 @@ InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) cons
53 } 49 }
54} 50}
55 51
52std::pair<float, float> EmuWindow_SDL2::MouseToTouchPos(s32 touch_x, s32 touch_y) const {
53 int w, h;
54 SDL_GetWindowSize(render_window, &w, &h);
55 const float fx = static_cast<float>(touch_x) / w;
56 const float fy = static_cast<float>(touch_y) / h;
57
58 return {std::clamp<float>(fx, 0.0f, 1.0f), std::clamp<float>(fy, 0.0f, 1.0f)};
59}
60
56void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { 61void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
57 const auto mouse_button = SDLButtonToMouseButton(button); 62 const auto mouse_button = SDLButtonToMouseButton(button);
58 if (state == SDL_PRESSED) { 63 if (state == SDL_PRESSED) {
59 input_subsystem->GetMouse()->PressButton(x, y, 0, 0, mouse_button); 64 const auto [touch_x, touch_y] = MouseToTouchPos(x, y);
65 input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, mouse_button);
60 } else { 66 } else {
61 input_subsystem->GetMouse()->ReleaseButton(mouse_button); 67 input_subsystem->GetMouse()->ReleaseButton(mouse_button);
62 } 68 }
63} 69}
64 70
65std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, float touch_y) const { 71void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
66 int w, h; 72 const auto [touch_x, touch_y] = MouseToTouchPos(x, y);
67 SDL_GetWindowSize(render_window, &w, &h); 73 input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, 0, 0);
68
69 touch_x *= w;
70 touch_y *= h;
71
72 return {static_cast<unsigned>(std::max(std::round(touch_x), 0.0f)),
73 static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))};
74} 74}
75 75
76void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) { 76void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) {
77 int width, height; 77 input_subsystem->GetTouchScreen()->TouchPressed(x, y, id);
78 SDL_GetWindowSize(render_window, &width, &height);
79 const auto [px, py] = TouchToPixelPos(x, y);
80 const float fx = px * 1.0f / width;
81 const float fy = py * 1.0f / height;
82
83 input_subsystem->GetTouchScreen()->TouchPressed(fx, fy, id);
84} 78}
85 79
86void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) { 80void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) {
87 int width, height; 81 input_subsystem->GetTouchScreen()->TouchMoved(x, y, id);
88 SDL_GetWindowSize(render_window, &width, &height);
89 const auto [px, py] = TouchToPixelPos(x, y);
90 const float fx = px * 1.0f / width;
91 const float fy = py * 1.0f / height;
92
93 input_subsystem->GetTouchScreen()->TouchMoved(fx, fy, id);
94} 82}
95 83
96void EmuWindow_SDL2::OnFingerUp() { 84void EmuWindow_SDL2::OnFingerUp() {
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index 25c23e2a5..d9b453dee 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -38,17 +38,17 @@ protected:
38 /// Called by WaitEvent when a key is pressed or released. 38 /// Called by WaitEvent when a key is pressed or released.
39 void OnKeyEvent(int key, u8 state); 39 void OnKeyEvent(int key, u8 state);
40 40
41 /// Called by WaitEvent when the mouse moves.
42 void OnMouseMotion(s32 x, s32 y);
43
44 /// Converts a SDL mouse button into MouseInput mouse button 41 /// Converts a SDL mouse button into MouseInput mouse button
45 InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const; 42 InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const;
46 43
44 /// Translates pixel position to float position
45 std::pair<float, float> MouseToTouchPos(s32 touch_x, s32 touch_y) const;
46
47 /// Called by WaitEvent when a mouse button is pressed or released 47 /// Called by WaitEvent when a mouse button is pressed or released
48 void OnMouseButton(u32 button, u8 state, s32 x, s32 y); 48 void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
49 49
50 /// Translates pixel position (0..1) to pixel positions 50 /// Called by WaitEvent when the mouse moves.
51 std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const; 51 void OnMouseMotion(s32 x, s32 y);
52 52
53 /// Called by WaitEvent when a finger starts touching the touchscreen 53 /// Called by WaitEvent when a finger starts touching the touchscreen
54 void OnFingerDown(float x, float y, std::size_t id); 54 void OnFingerDown(float x, float y, std::size_t id);
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 91133569d..d1f7b1d49 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -62,13 +62,15 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
62static void PrintHelp(const char* argv0) { 62static void PrintHelp(const char* argv0) {
63 std::cout << "Usage: " << argv0 63 std::cout << "Usage: " << argv0
64 << " [options] <filename>\n" 64 << " [options] <filename>\n"
65 "-m, --multiplayer=nick:password@address:port" 65 "-c, --config Load the specified configuration file\n"
66 " Nickname, password, address and port for multiplayer\n"
67 "-f, --fullscreen Start in fullscreen mode\n" 66 "-f, --fullscreen Start in fullscreen mode\n"
67 "-g, --game File path of the game to load\n"
68 "-h, --help Display this help and exit\n" 68 "-h, --help Display this help and exit\n"
69 "-v, --version Output version information and exit\n" 69 "-m, --multiplayer=nick:password@address:port"
70 " Nickname, password, address and port for multiplayer\n"
70 "-p, --program Pass following string as arguments to executable\n" 71 "-p, --program Pass following string as arguments to executable\n"
71 "-c, --config Load the specified configuration file\n"; 72 "-u, --user Select a specific user profile from 0 to 7\n"
73 "-v, --version Output version information and exit\n";
72} 74}
73 75
74static void PrintVersion() { 76static void PrintVersion() {
@@ -199,6 +201,7 @@ int main(int argc, char** argv) {
199 std::string filepath; 201 std::string filepath;
200 std::optional<std::string> config_path; 202 std::optional<std::string> config_path;
201 std::string program_args; 203 std::string program_args;
204 std::optional<int> selected_user;
202 205
203 bool use_multiplayer = false; 206 bool use_multiplayer = false;
204 bool fullscreen = false; 207 bool fullscreen = false;
@@ -209,12 +212,14 @@ int main(int argc, char** argv) {
209 212
210 static struct option long_options[] = { 213 static struct option long_options[] = {
211 // clang-format off 214 // clang-format off
212 {"multiplayer", required_argument, 0, 'm'}, 215 {"config", required_argument, 0, 'c'},
213 {"fullscreen", no_argument, 0, 'f'}, 216 {"fullscreen", no_argument, 0, 'f'},
214 {"help", no_argument, 0, 'h'}, 217 {"help", no_argument, 0, 'h'},
215 {"version", no_argument, 0, 'v'}, 218 {"game", required_argument, 0, 'g'},
219 {"multiplayer", required_argument, 0, 'm'},
216 {"program", optional_argument, 0, 'p'}, 220 {"program", optional_argument, 0, 'p'},
217 {"config", required_argument, 0, 'c'}, 221 {"user", required_argument, 0, 'u'},
222 {"version", no_argument, 0, 'v'},
218 {0, 0, 0, 0}, 223 {0, 0, 0, 0},
219 // clang-format on 224 // clang-format on
220 }; 225 };
@@ -223,6 +228,21 @@ int main(int argc, char** argv) {
223 int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index); 228 int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index);
224 if (arg != -1) { 229 if (arg != -1) {
225 switch (static_cast<char>(arg)) { 230 switch (static_cast<char>(arg)) {
231 case 'c':
232 config_path = optarg;
233 break;
234 case 'f':
235 fullscreen = true;
236 LOG_INFO(Frontend, "Starting in fullscreen mode...");
237 break;
238 case 'h':
239 PrintHelp(argv[0]);
240 return 0;
241 case 'g': {
242 const std::string str_arg(optarg);
243 filepath = str_arg;
244 break;
245 }
226 case 'm': { 246 case 'm': {
227 use_multiplayer = true; 247 use_multiplayer = true;
228 const std::string str_arg(optarg); 248 const std::string str_arg(optarg);
@@ -255,23 +275,16 @@ int main(int argc, char** argv) {
255 } 275 }
256 break; 276 break;
257 } 277 }
258 case 'f': 278 case 'p':
259 fullscreen = true; 279 program_args = argv[optind];
260 LOG_INFO(Frontend, "Starting in fullscreen mode..."); 280 ++optind;
261 break; 281 break;
262 case 'h': 282 case 'u':
263 PrintHelp(argv[0]); 283 selected_user = atoi(optarg);
264 return 0; 284 return 0;
265 case 'v': 285 case 'v':
266 PrintVersion(); 286 PrintVersion();
267 return 0; 287 return 0;
268 case 'p':
269 program_args = argv[optind];
270 ++optind;
271 break;
272 case 'c':
273 config_path = optarg;
274 break;
275 } 288 }
276 } else { 289 } else {
277#ifdef _WIN32 290#ifdef _WIN32
@@ -295,6 +308,10 @@ int main(int argc, char** argv) {
295 Settings::values.program_args = program_args; 308 Settings::values.program_args = program_args;
296 } 309 }
297 310
311 if (selected_user.has_value()) {
312 Settings::values.current_user = std::clamp(*selected_user, 0, 7);
313 }
314
298#ifdef _WIN32 315#ifdef _WIN32
299 LocalFree(argv_w); 316 LocalFree(argv_w);
300#endif 317#endif