summaryrefslogtreecommitdiffstats
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/config.cpp178
-rw-r--r--src/yuzu_cmd/default_ini.h17
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp72
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h11
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp1
5 files changed, 41 insertions, 238 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 33241ea98..8e9c7d211 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -24,7 +24,6 @@
#include "common/settings.h"
#include "core/hle/service/acc/profile_manager.h"
#include "input_common/main.h"
-#include "input_common/udp/client.h"
#include "yuzu_cmd/config.h"
#include "yuzu_cmd/default_ini.h"
@@ -84,163 +83,6 @@ static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs>
},
}};
-static const std::array<int, Settings::NativeMouseButton::NumMouseButtons> default_mouse_buttons = {
- SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_APOSTROPHE,
- SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS,
-};
-
-static const std::array<int, 0x8A> keyboard_keys = {
- 0,
- 0,
- 0,
- 0,
- SDL_SCANCODE_A,
- SDL_SCANCODE_B,
- SDL_SCANCODE_C,
- SDL_SCANCODE_D,
- SDL_SCANCODE_E,
- SDL_SCANCODE_F,
- SDL_SCANCODE_G,
- SDL_SCANCODE_H,
- SDL_SCANCODE_I,
- SDL_SCANCODE_J,
- SDL_SCANCODE_K,
- SDL_SCANCODE_L,
- SDL_SCANCODE_M,
- SDL_SCANCODE_N,
- SDL_SCANCODE_O,
- SDL_SCANCODE_P,
- SDL_SCANCODE_Q,
- SDL_SCANCODE_R,
- SDL_SCANCODE_S,
- SDL_SCANCODE_T,
- SDL_SCANCODE_U,
- SDL_SCANCODE_V,
- SDL_SCANCODE_W,
- SDL_SCANCODE_X,
- SDL_SCANCODE_Y,
- SDL_SCANCODE_Z,
- SDL_SCANCODE_1,
- SDL_SCANCODE_2,
- SDL_SCANCODE_3,
- SDL_SCANCODE_4,
- SDL_SCANCODE_5,
- SDL_SCANCODE_6,
- SDL_SCANCODE_7,
- SDL_SCANCODE_8,
- SDL_SCANCODE_9,
- SDL_SCANCODE_0,
- SDL_SCANCODE_RETURN,
- SDL_SCANCODE_ESCAPE,
- SDL_SCANCODE_BACKSPACE,
- SDL_SCANCODE_TAB,
- SDL_SCANCODE_SPACE,
- SDL_SCANCODE_MINUS,
- SDL_SCANCODE_EQUALS,
- SDL_SCANCODE_LEFTBRACKET,
- SDL_SCANCODE_RIGHTBRACKET,
- SDL_SCANCODE_BACKSLASH,
- 0,
- SDL_SCANCODE_SEMICOLON,
- SDL_SCANCODE_APOSTROPHE,
- SDL_SCANCODE_GRAVE,
- SDL_SCANCODE_COMMA,
- SDL_SCANCODE_PERIOD,
- SDL_SCANCODE_SLASH,
- SDL_SCANCODE_CAPSLOCK,
-
- SDL_SCANCODE_F1,
- SDL_SCANCODE_F2,
- SDL_SCANCODE_F3,
- SDL_SCANCODE_F4,
- SDL_SCANCODE_F5,
- SDL_SCANCODE_F6,
- SDL_SCANCODE_F7,
- SDL_SCANCODE_F8,
- SDL_SCANCODE_F9,
- SDL_SCANCODE_F10,
- SDL_SCANCODE_F11,
- SDL_SCANCODE_F12,
-
- 0,
- SDL_SCANCODE_SCROLLLOCK,
- SDL_SCANCODE_PAUSE,
- SDL_SCANCODE_INSERT,
- SDL_SCANCODE_HOME,
- SDL_SCANCODE_PAGEUP,
- SDL_SCANCODE_DELETE,
- SDL_SCANCODE_END,
- SDL_SCANCODE_PAGEDOWN,
- SDL_SCANCODE_RIGHT,
- SDL_SCANCODE_LEFT,
- SDL_SCANCODE_DOWN,
- SDL_SCANCODE_UP,
-
- SDL_SCANCODE_NUMLOCKCLEAR,
- SDL_SCANCODE_KP_DIVIDE,
- SDL_SCANCODE_KP_MULTIPLY,
- SDL_SCANCODE_KP_MINUS,
- SDL_SCANCODE_KP_PLUS,
- SDL_SCANCODE_KP_ENTER,
- SDL_SCANCODE_KP_1,
- SDL_SCANCODE_KP_2,
- SDL_SCANCODE_KP_3,
- SDL_SCANCODE_KP_4,
- SDL_SCANCODE_KP_5,
- SDL_SCANCODE_KP_6,
- SDL_SCANCODE_KP_7,
- SDL_SCANCODE_KP_8,
- SDL_SCANCODE_KP_9,
- SDL_SCANCODE_KP_0,
- SDL_SCANCODE_KP_PERIOD,
-
- 0,
- 0,
- SDL_SCANCODE_POWER,
- SDL_SCANCODE_KP_EQUALS,
-
- SDL_SCANCODE_F13,
- SDL_SCANCODE_F14,
- SDL_SCANCODE_F15,
- SDL_SCANCODE_F16,
- SDL_SCANCODE_F17,
- SDL_SCANCODE_F18,
- SDL_SCANCODE_F19,
- SDL_SCANCODE_F20,
- SDL_SCANCODE_F21,
- SDL_SCANCODE_F22,
- SDL_SCANCODE_F23,
- SDL_SCANCODE_F24,
-
- 0,
- SDL_SCANCODE_HELP,
- SDL_SCANCODE_MENU,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- SDL_SCANCODE_KP_COMMA,
- SDL_SCANCODE_KP_LEFTPAREN,
- SDL_SCANCODE_KP_RIGHTPAREN,
- 0,
- 0,
- 0,
- 0,
-};
-
-static const std::array<int, 8> keyboard_mods{
- SDL_SCANCODE_LCTRL, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI,
- SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI,
-};
-
template <>
void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) {
setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault());
@@ -284,16 +126,6 @@ void Config::ReadValues() {
}
ReadSetting("ControlsGeneral", Settings::values.mouse_enabled);
- for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
- std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
- Settings::values.mouse_buttons[i] = sdl2_config->Get(
- "ControlsGeneral", std::string("mouse_") + Settings::NativeMouseButton::mapping[i],
- default_param);
- if (Settings::values.mouse_buttons[i].empty())
- Settings::values.mouse_buttons[i] = default_param;
- }
-
- ReadSetting("ControlsGeneral", Settings::values.motion_device);
ReadSetting("ControlsGeneral", Settings::values.touch_device);
@@ -363,21 +195,11 @@ void Config::ReadValues() {
Settings::TouchFromButtonMap{"default", {}});
num_touch_from_button_maps = 1;
}
- ReadSetting("ControlsGeneral", Settings::values.use_touch_from_button);
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
ReadSetting("ControlsGeneral", Settings::values.udp_input_servers);
- std::transform(keyboard_keys.begin(), keyboard_keys.end(),
- Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
- std::transform(keyboard_mods.begin(), keyboard_mods.end(),
- Settings::values.keyboard_keys.begin() +
- Settings::NativeKeyboard::LeftControlKey,
- InputCommon::GenerateKeyboardParam);
- std::transform(keyboard_mods.begin(), keyboard_mods.end(),
- Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
-
// Data Storage
ReadSetting("Data Storage", Settings::values.use_virtual_sd);
FS::SetYuzuPath(FS::YuzuPath::NANDDir,
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index ecdc271a8..6d613bf7a 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -84,23 +84,10 @@ enable_accurate_vibrations=
# 0: Disabled, 1 (default): Enabled
motion_enabled =
-# for motion input, the following devices are available:
-# - "motion_emu" (default) for emulating motion input from mouse input. Required parameters:
-# - "update_period": update period in milliseconds (default to 100)
-# - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01)
-# - "cemuhookudp" reads motion input from a udp server that uses cemuhook's udp protocol
-motion_device=
-
-# for touch input, the following devices are available:
-# - "emu_window" (default) for emulating touch input from mouse input to the emulation window. No parameters required
-# - "cemuhookudp" reads touch input from a udp server that uses cemuhook's udp protocol
-# - "min_x", "min_y", "max_x", "max_y": defines the udp device's touch screen coordinate system
+# Defines the udp device's touch screen coordinate system for cemuhookudp devices
+# - "min_x", "min_y", "max_x", "max_y"
touch_device=
-# Whether to enable or disable touch input from button
-# 0 (default): Disabled, 1: Enabled
-use_touch_from_button=
-
# for mapping buttons to touch inputs.
#touch_from_button_map=1
#touch_from_button_maps_0_name=default
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index 87fce0c23..57f807826 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -9,10 +9,10 @@
#include "common/settings.h"
#include "core/core.h"
#include "core/perf_stats.h"
-#include "input_common/keyboard.h"
+#include "input_common/drivers/keyboard.h"
+#include "input_common/drivers/mouse.h"
+#include "input_common/drivers/touch_screen.h"
#include "input_common/main.h"
-#include "input_common/mouse/mouse_input.h"
-#include "input_common/sdl/sdl.h"
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
#include "yuzu_cmd/yuzu_icon.h"
@@ -32,42 +32,32 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
}
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
- TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0);
-
- input_subsystem->GetMouse()->MouseMove(x, y, 0, 0);
+ input_subsystem->GetMouse()->MouseMove(x, y, 0, 0, 0, 0);
}
-MouseInput::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
+InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
switch (button) {
case SDL_BUTTON_LEFT:
- return MouseInput::MouseButton::Left;
+ return InputCommon::MouseButton::Left;
case SDL_BUTTON_RIGHT:
- return MouseInput::MouseButton::Right;
+ return InputCommon::MouseButton::Right;
case SDL_BUTTON_MIDDLE:
- return MouseInput::MouseButton::Wheel;
+ return InputCommon::MouseButton::Wheel;
case SDL_BUTTON_X1:
- return MouseInput::MouseButton::Backward;
+ return InputCommon::MouseButton::Backward;
case SDL_BUTTON_X2:
- return MouseInput::MouseButton::Forward;
+ return InputCommon::MouseButton::Forward;
default:
- return MouseInput::MouseButton::Undefined;
+ return InputCommon::MouseButton::Undefined;
}
}
void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
const auto mouse_button = SDLButtonToMouseButton(button);
- if (button == SDL_BUTTON_LEFT) {
- if (state == SDL_PRESSED) {
- TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0);
- } else {
- TouchReleased(0);
- }
+ if (state == SDL_PRESSED) {
+ input_subsystem->GetMouse()->PressButton(x, y, 0, 0, mouse_button);
} else {
- if (state == SDL_PRESSED) {
- input_subsystem->GetMouse()->PressButton(x, y, mouse_button);
- } else {
- input_subsystem->GetMouse()->ReleaseButton(mouse_button);
- }
+ input_subsystem->GetMouse()->ReleaseButton(mouse_button);
}
}
@@ -82,29 +72,35 @@ std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, flo
static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))};
}
-void EmuWindow_SDL2::OnFingerDown(float x, float y) {
- // TODO(NeatNit): keep track of multitouch using the fingerID and a dictionary of some kind
- // This isn't critical because the best we can do when we have that is to average them, like the
- // 3DS does
-
+void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) {
+ int width, height;
+ SDL_GetWindowSize(render_window, &width, &height);
const auto [px, py] = TouchToPixelPos(x, y);
- TouchPressed(px, py, 0);
+ const float fx = px * 1.0f / width;
+ const float fy = py * 1.0f / height;
+
+ input_subsystem->GetTouchScreen()->TouchPressed(fx, fy, id);
}
-void EmuWindow_SDL2::OnFingerMotion(float x, float y) {
+void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) {
+ int width, height;
+ SDL_GetWindowSize(render_window, &width, &height);
const auto [px, py] = TouchToPixelPos(x, y);
- TouchMoved(px, py, 0);
+ const float fx = px * 1.0f / width;
+ const float fy = py * 1.0f / height;
+
+ input_subsystem->GetTouchScreen()->TouchMoved(fx, fy, id);
}
void EmuWindow_SDL2::OnFingerUp() {
- TouchReleased(0);
+ input_subsystem->GetTouchScreen()->TouchReleased(0);
}
void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
if (state == SDL_PRESSED) {
- input_subsystem->GetKeyboard()->PressKey(key);
+ input_subsystem->GetKeyboard()->PressKey(static_cast<std::size_t>(key));
} else if (state == SDL_RELEASED) {
- input_subsystem->GetKeyboard()->ReleaseKey(key);
+ input_subsystem->GetKeyboard()->ReleaseKey(static_cast<std::size_t>(key));
}
}
@@ -205,10 +201,12 @@ void EmuWindow_SDL2::WaitEvent() {
}
break;
case SDL_FINGERDOWN:
- OnFingerDown(event.tfinger.x, event.tfinger.y);
+ OnFingerDown(event.tfinger.x, event.tfinger.y,
+ static_cast<std::size_t>(event.tfinger.touchId));
break;
case SDL_FINGERMOTION:
- OnFingerMotion(event.tfinger.x, event.tfinger.y);
+ OnFingerMotion(event.tfinger.x, event.tfinger.y,
+ static_cast<std::size_t>(event.tfinger.touchId));
break;
case SDL_FINGERUP:
OnFingerUp();
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index 4810f8775..0af002693 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -16,11 +16,8 @@ class System;
namespace InputCommon {
class InputSubsystem;
-}
-
-namespace MouseInput {
enum class MouseButton;
-}
+} // namespace InputCommon
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
public:
@@ -47,7 +44,7 @@ protected:
void OnMouseMotion(s32 x, s32 y);
/// Converts a SDL mouse button into MouseInput mouse button
- MouseInput::MouseButton SDLButtonToMouseButton(u32 button) const;
+ InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const;
/// Called by WaitEvent when a mouse button is pressed or released
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
@@ -56,10 +53,10 @@ protected:
std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
/// Called by WaitEvent when a finger starts touching the touchscreen
- void OnFingerDown(float x, float y);
+ void OnFingerDown(float x, float y, std::size_t id);
/// Called by WaitEvent when a finger moves while touching the touchscreen
- void OnFingerMotion(float x, float y);
+ void OnFingerMotion(float x, float y, std::size_t id);
/// Called by WaitEvent when a finger stops touching the touchscreen
void OnFingerUp();
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
index a075ad08a..70db865ec 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
@@ -17,7 +17,6 @@
#include "common/settings.h"
#include "common/string_util.h"
#include "core/core.h"
-#include "input_common/keyboard.h"
#include "input_common/main.h"
#include "video_core/renderer_base.h"
#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h"