diff options
| author | 2021-12-18 13:57:14 +0800 | |
|---|---|---|
| committer | 2021-12-18 13:57:14 +0800 | |
| commit | e49184e6069a9d791d2df3c1958f5c4b1187e124 (patch) | |
| tree | b776caf722e0be0e680f67b0ad0842628162ef1c /src/yuzu_cmd | |
| parent | Implement convert legacy to generic (diff) | |
| parent | Merge pull request #7570 from ameerj/favorites-expanded (diff) | |
| download | yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.gz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.xz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.zip | |
Merge branch 'yuzu-emu:master' into convert_legacy
Diffstat (limited to 'src/yuzu_cmd')
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 178 | ||||
| -rw-r--r-- | src/yuzu_cmd/default_ini.h | 17 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 72 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 11 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp | 1 |
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 @@ | |||
| 24 | #include "common/settings.h" | 24 | #include "common/settings.h" |
| 25 | #include "core/hle/service/acc/profile_manager.h" | 25 | #include "core/hle/service/acc/profile_manager.h" |
| 26 | #include "input_common/main.h" | 26 | #include "input_common/main.h" |
| 27 | #include "input_common/udp/client.h" | ||
| 28 | #include "yuzu_cmd/config.h" | 27 | #include "yuzu_cmd/config.h" |
| 29 | #include "yuzu_cmd/default_ini.h" | 28 | #include "yuzu_cmd/default_ini.h" |
| 30 | 29 | ||
| @@ -84,163 +83,6 @@ static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> | |||
| 84 | }, | 83 | }, |
| 85 | }}; | 84 | }}; |
| 86 | 85 | ||
| 87 | static const std::array<int, Settings::NativeMouseButton::NumMouseButtons> default_mouse_buttons = { | ||
| 88 | SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_APOSTROPHE, | ||
| 89 | SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, | ||
| 90 | }; | ||
| 91 | |||
| 92 | static const std::array<int, 0x8A> keyboard_keys = { | ||
| 93 | 0, | ||
| 94 | 0, | ||
| 95 | 0, | ||
| 96 | 0, | ||
| 97 | SDL_SCANCODE_A, | ||
| 98 | SDL_SCANCODE_B, | ||
| 99 | SDL_SCANCODE_C, | ||
| 100 | SDL_SCANCODE_D, | ||
| 101 | SDL_SCANCODE_E, | ||
| 102 | SDL_SCANCODE_F, | ||
| 103 | SDL_SCANCODE_G, | ||
| 104 | SDL_SCANCODE_H, | ||
| 105 | SDL_SCANCODE_I, | ||
| 106 | SDL_SCANCODE_J, | ||
| 107 | SDL_SCANCODE_K, | ||
| 108 | SDL_SCANCODE_L, | ||
| 109 | SDL_SCANCODE_M, | ||
| 110 | SDL_SCANCODE_N, | ||
| 111 | SDL_SCANCODE_O, | ||
| 112 | SDL_SCANCODE_P, | ||
| 113 | SDL_SCANCODE_Q, | ||
| 114 | SDL_SCANCODE_R, | ||
| 115 | SDL_SCANCODE_S, | ||
| 116 | SDL_SCANCODE_T, | ||
| 117 | SDL_SCANCODE_U, | ||
| 118 | SDL_SCANCODE_V, | ||
| 119 | SDL_SCANCODE_W, | ||
| 120 | SDL_SCANCODE_X, | ||
| 121 | SDL_SCANCODE_Y, | ||
| 122 | SDL_SCANCODE_Z, | ||
| 123 | SDL_SCANCODE_1, | ||
| 124 | SDL_SCANCODE_2, | ||
| 125 | SDL_SCANCODE_3, | ||
| 126 | SDL_SCANCODE_4, | ||
| 127 | SDL_SCANCODE_5, | ||
| 128 | SDL_SCANCODE_6, | ||
| 129 | SDL_SCANCODE_7, | ||
| 130 | SDL_SCANCODE_8, | ||
| 131 | SDL_SCANCODE_9, | ||
| 132 | SDL_SCANCODE_0, | ||
| 133 | SDL_SCANCODE_RETURN, | ||
| 134 | SDL_SCANCODE_ESCAPE, | ||
| 135 | SDL_SCANCODE_BACKSPACE, | ||
| 136 | SDL_SCANCODE_TAB, | ||
| 137 | SDL_SCANCODE_SPACE, | ||
| 138 | SDL_SCANCODE_MINUS, | ||
| 139 | SDL_SCANCODE_EQUALS, | ||
| 140 | SDL_SCANCODE_LEFTBRACKET, | ||
| 141 | SDL_SCANCODE_RIGHTBRACKET, | ||
| 142 | SDL_SCANCODE_BACKSLASH, | ||
| 143 | 0, | ||
| 144 | SDL_SCANCODE_SEMICOLON, | ||
| 145 | SDL_SCANCODE_APOSTROPHE, | ||
| 146 | SDL_SCANCODE_GRAVE, | ||
| 147 | SDL_SCANCODE_COMMA, | ||
| 148 | SDL_SCANCODE_PERIOD, | ||
| 149 | SDL_SCANCODE_SLASH, | ||
| 150 | SDL_SCANCODE_CAPSLOCK, | ||
| 151 | |||
| 152 | SDL_SCANCODE_F1, | ||
| 153 | SDL_SCANCODE_F2, | ||
| 154 | SDL_SCANCODE_F3, | ||
| 155 | SDL_SCANCODE_F4, | ||
| 156 | SDL_SCANCODE_F5, | ||
| 157 | SDL_SCANCODE_F6, | ||
| 158 | SDL_SCANCODE_F7, | ||
| 159 | SDL_SCANCODE_F8, | ||
| 160 | SDL_SCANCODE_F9, | ||
| 161 | SDL_SCANCODE_F10, | ||
| 162 | SDL_SCANCODE_F11, | ||
| 163 | SDL_SCANCODE_F12, | ||
| 164 | |||
| 165 | 0, | ||
| 166 | SDL_SCANCODE_SCROLLLOCK, | ||
| 167 | SDL_SCANCODE_PAUSE, | ||
| 168 | SDL_SCANCODE_INSERT, | ||
| 169 | SDL_SCANCODE_HOME, | ||
| 170 | SDL_SCANCODE_PAGEUP, | ||
| 171 | SDL_SCANCODE_DELETE, | ||
| 172 | SDL_SCANCODE_END, | ||
| 173 | SDL_SCANCODE_PAGEDOWN, | ||
| 174 | SDL_SCANCODE_RIGHT, | ||
| 175 | SDL_SCANCODE_LEFT, | ||
| 176 | SDL_SCANCODE_DOWN, | ||
| 177 | SDL_SCANCODE_UP, | ||
| 178 | |||
| 179 | SDL_SCANCODE_NUMLOCKCLEAR, | ||
| 180 | SDL_SCANCODE_KP_DIVIDE, | ||
| 181 | SDL_SCANCODE_KP_MULTIPLY, | ||
| 182 | SDL_SCANCODE_KP_MINUS, | ||
| 183 | SDL_SCANCODE_KP_PLUS, | ||
| 184 | SDL_SCANCODE_KP_ENTER, | ||
| 185 | SDL_SCANCODE_KP_1, | ||
| 186 | SDL_SCANCODE_KP_2, | ||
| 187 | SDL_SCANCODE_KP_3, | ||
| 188 | SDL_SCANCODE_KP_4, | ||
| 189 | SDL_SCANCODE_KP_5, | ||
| 190 | SDL_SCANCODE_KP_6, | ||
| 191 | SDL_SCANCODE_KP_7, | ||
| 192 | SDL_SCANCODE_KP_8, | ||
| 193 | SDL_SCANCODE_KP_9, | ||
| 194 | SDL_SCANCODE_KP_0, | ||
| 195 | SDL_SCANCODE_KP_PERIOD, | ||
| 196 | |||
| 197 | 0, | ||
| 198 | 0, | ||
| 199 | SDL_SCANCODE_POWER, | ||
| 200 | SDL_SCANCODE_KP_EQUALS, | ||
| 201 | |||
| 202 | SDL_SCANCODE_F13, | ||
| 203 | SDL_SCANCODE_F14, | ||
| 204 | SDL_SCANCODE_F15, | ||
| 205 | SDL_SCANCODE_F16, | ||
| 206 | SDL_SCANCODE_F17, | ||
| 207 | SDL_SCANCODE_F18, | ||
| 208 | SDL_SCANCODE_F19, | ||
| 209 | SDL_SCANCODE_F20, | ||
| 210 | SDL_SCANCODE_F21, | ||
| 211 | SDL_SCANCODE_F22, | ||
| 212 | SDL_SCANCODE_F23, | ||
| 213 | SDL_SCANCODE_F24, | ||
| 214 | |||
| 215 | 0, | ||
| 216 | SDL_SCANCODE_HELP, | ||
| 217 | SDL_SCANCODE_MENU, | ||
| 218 | 0, | ||
| 219 | 0, | ||
| 220 | 0, | ||
| 221 | 0, | ||
| 222 | 0, | ||
| 223 | 0, | ||
| 224 | 0, | ||
| 225 | 0, | ||
| 226 | 0, | ||
| 227 | 0, | ||
| 228 | 0, | ||
| 229 | 0, | ||
| 230 | SDL_SCANCODE_KP_COMMA, | ||
| 231 | SDL_SCANCODE_KP_LEFTPAREN, | ||
| 232 | SDL_SCANCODE_KP_RIGHTPAREN, | ||
| 233 | 0, | ||
| 234 | 0, | ||
| 235 | 0, | ||
| 236 | 0, | ||
| 237 | }; | ||
| 238 | |||
| 239 | static const std::array<int, 8> keyboard_mods{ | ||
| 240 | SDL_SCANCODE_LCTRL, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI, | ||
| 241 | SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI, | ||
| 242 | }; | ||
| 243 | |||
| 244 | template <> | 86 | template <> |
| 245 | void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) { | 87 | void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) { |
| 246 | setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault()); | 88 | setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault()); |
| @@ -284,16 +126,6 @@ void Config::ReadValues() { | |||
| 284 | } | 126 | } |
| 285 | 127 | ||
| 286 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); | 128 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); |
| 287 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 288 | std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 289 | Settings::values.mouse_buttons[i] = sdl2_config->Get( | ||
| 290 | "ControlsGeneral", std::string("mouse_") + Settings::NativeMouseButton::mapping[i], | ||
| 291 | default_param); | ||
| 292 | if (Settings::values.mouse_buttons[i].empty()) | ||
| 293 | Settings::values.mouse_buttons[i] = default_param; | ||
| 294 | } | ||
| 295 | |||
| 296 | ReadSetting("ControlsGeneral", Settings::values.motion_device); | ||
| 297 | 129 | ||
| 298 | ReadSetting("ControlsGeneral", Settings::values.touch_device); | 130 | ReadSetting("ControlsGeneral", Settings::values.touch_device); |
| 299 | 131 | ||
| @@ -363,21 +195,11 @@ void Config::ReadValues() { | |||
| 363 | Settings::TouchFromButtonMap{"default", {}}); | 195 | Settings::TouchFromButtonMap{"default", {}}); |
| 364 | num_touch_from_button_maps = 1; | 196 | num_touch_from_button_maps = 1; |
| 365 | } | 197 | } |
| 366 | ReadSetting("ControlsGeneral", Settings::values.use_touch_from_button); | ||
| 367 | Settings::values.touch_from_button_map_index = std::clamp( | 198 | Settings::values.touch_from_button_map_index = std::clamp( |
| 368 | Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1); | 199 | Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1); |
| 369 | 200 | ||
| 370 | ReadSetting("ControlsGeneral", Settings::values.udp_input_servers); | 201 | ReadSetting("ControlsGeneral", Settings::values.udp_input_servers); |
| 371 | 202 | ||
| 372 | std::transform(keyboard_keys.begin(), keyboard_keys.end(), | ||
| 373 | Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); | ||
| 374 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 375 | Settings::values.keyboard_keys.begin() + | ||
| 376 | Settings::NativeKeyboard::LeftControlKey, | ||
| 377 | InputCommon::GenerateKeyboardParam); | ||
| 378 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 379 | Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); | ||
| 380 | |||
| 381 | // Data Storage | 203 | // Data Storage |
| 382 | ReadSetting("Data Storage", Settings::values.use_virtual_sd); | 204 | ReadSetting("Data Storage", Settings::values.use_virtual_sd); |
| 383 | FS::SetYuzuPath(FS::YuzuPath::NANDDir, | 205 | 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= | |||
| 84 | # 0: Disabled, 1 (default): Enabled | 84 | # 0: Disabled, 1 (default): Enabled |
| 85 | motion_enabled = | 85 | motion_enabled = |
| 86 | 86 | ||
| 87 | # for motion input, the following devices are available: | 87 | # Defines the udp device's touch screen coordinate system for cemuhookudp devices |
| 88 | # - "motion_emu" (default) for emulating motion input from mouse input. Required parameters: | 88 | # - "min_x", "min_y", "max_x", "max_y" |
| 89 | # - "update_period": update period in milliseconds (default to 100) | ||
| 90 | # - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01) | ||
| 91 | # - "cemuhookudp" reads motion input from a udp server that uses cemuhook's udp protocol | ||
| 92 | motion_device= | ||
| 93 | |||
| 94 | # for touch input, the following devices are available: | ||
| 95 | # - "emu_window" (default) for emulating touch input from mouse input to the emulation window. No parameters required | ||
| 96 | # - "cemuhookudp" reads touch input from a udp server that uses cemuhook's udp protocol | ||
| 97 | # - "min_x", "min_y", "max_x", "max_y": defines the udp device's touch screen coordinate system | ||
| 98 | touch_device= | 89 | touch_device= |
| 99 | 90 | ||
| 100 | # Whether to enable or disable touch input from button | ||
| 101 | # 0 (default): Disabled, 1: Enabled | ||
| 102 | use_touch_from_button= | ||
| 103 | |||
| 104 | # for mapping buttons to touch inputs. | 91 | # for mapping buttons to touch inputs. |
| 105 | #touch_from_button_map=1 | 92 | #touch_from_button_map=1 |
| 106 | #touch_from_button_maps_0_name=default | 93 | #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 @@ | |||
| 9 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/perf_stats.h" | 11 | #include "core/perf_stats.h" |
| 12 | #include "input_common/keyboard.h" | 12 | #include "input_common/drivers/keyboard.h" |
| 13 | #include "input_common/drivers/mouse.h" | ||
| 14 | #include "input_common/drivers/touch_screen.h" | ||
| 13 | #include "input_common/main.h" | 15 | #include "input_common/main.h" |
| 14 | #include "input_common/mouse/mouse_input.h" | ||
| 15 | #include "input_common/sdl/sdl.h" | ||
| 16 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" | 16 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" |
| 17 | #include "yuzu_cmd/yuzu_icon.h" | 17 | #include "yuzu_cmd/yuzu_icon.h" |
| 18 | 18 | ||
| @@ -32,42 +32,32 @@ EmuWindow_SDL2::~EmuWindow_SDL2() { | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | 34 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { |
| 35 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0); | 35 | input_subsystem->GetMouse()->MouseMove(x, y, 0, 0, 0, 0); |
| 36 | |||
| 37 | input_subsystem->GetMouse()->MouseMove(x, y, 0, 0); | ||
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | MouseInput::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const { | 38 | InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const { |
| 41 | switch (button) { | 39 | switch (button) { |
| 42 | case SDL_BUTTON_LEFT: | 40 | case SDL_BUTTON_LEFT: |
| 43 | return MouseInput::MouseButton::Left; | 41 | return InputCommon::MouseButton::Left; |
| 44 | case SDL_BUTTON_RIGHT: | 42 | case SDL_BUTTON_RIGHT: |
| 45 | return MouseInput::MouseButton::Right; | 43 | return InputCommon::MouseButton::Right; |
| 46 | case SDL_BUTTON_MIDDLE: | 44 | case SDL_BUTTON_MIDDLE: |
| 47 | return MouseInput::MouseButton::Wheel; | 45 | return InputCommon::MouseButton::Wheel; |
| 48 | case SDL_BUTTON_X1: | 46 | case SDL_BUTTON_X1: |
| 49 | return MouseInput::MouseButton::Backward; | 47 | return InputCommon::MouseButton::Backward; |
| 50 | case SDL_BUTTON_X2: | 48 | case SDL_BUTTON_X2: |
| 51 | return MouseInput::MouseButton::Forward; | 49 | return InputCommon::MouseButton::Forward; |
| 52 | default: | 50 | default: |
| 53 | return MouseInput::MouseButton::Undefined; | 51 | return InputCommon::MouseButton::Undefined; |
| 54 | } | 52 | } |
| 55 | } | 53 | } |
| 56 | 54 | ||
| 57 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | 55 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { |
| 58 | const auto mouse_button = SDLButtonToMouseButton(button); | 56 | const auto mouse_button = SDLButtonToMouseButton(button); |
| 59 | if (button == SDL_BUTTON_LEFT) { | 57 | if (state == SDL_PRESSED) { |
| 60 | if (state == SDL_PRESSED) { | 58 | input_subsystem->GetMouse()->PressButton(x, y, 0, 0, mouse_button); |
| 61 | TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0); | ||
| 62 | } else { | ||
| 63 | TouchReleased(0); | ||
| 64 | } | ||
| 65 | } else { | 59 | } else { |
| 66 | if (state == SDL_PRESSED) { | 60 | input_subsystem->GetMouse()->ReleaseButton(mouse_button); |
| 67 | input_subsystem->GetMouse()->PressButton(x, y, mouse_button); | ||
| 68 | } else { | ||
| 69 | input_subsystem->GetMouse()->ReleaseButton(mouse_button); | ||
| 70 | } | ||
| 71 | } | 61 | } |
| 72 | } | 62 | } |
| 73 | 63 | ||
| @@ -82,29 +72,35 @@ std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, flo | |||
| 82 | static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))}; | 72 | static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))}; |
| 83 | } | 73 | } |
| 84 | 74 | ||
| 85 | void EmuWindow_SDL2::OnFingerDown(float x, float y) { | 75 | void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) { |
| 86 | // TODO(NeatNit): keep track of multitouch using the fingerID and a dictionary of some kind | 76 | int width, height; |
| 87 | // This isn't critical because the best we can do when we have that is to average them, like the | 77 | SDL_GetWindowSize(render_window, &width, &height); |
| 88 | // 3DS does | ||
| 89 | |||
| 90 | const auto [px, py] = TouchToPixelPos(x, y); | 78 | const auto [px, py] = TouchToPixelPos(x, y); |
| 91 | TouchPressed(px, py, 0); | 79 | const float fx = px * 1.0f / width; |
| 80 | const float fy = py * 1.0f / height; | ||
| 81 | |||
| 82 | input_subsystem->GetTouchScreen()->TouchPressed(fx, fy, id); | ||
| 92 | } | 83 | } |
| 93 | 84 | ||
| 94 | void EmuWindow_SDL2::OnFingerMotion(float x, float y) { | 85 | void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) { |
| 86 | int width, height; | ||
| 87 | SDL_GetWindowSize(render_window, &width, &height); | ||
| 95 | const auto [px, py] = TouchToPixelPos(x, y); | 88 | const auto [px, py] = TouchToPixelPos(x, y); |
| 96 | TouchMoved(px, py, 0); | 89 | const float fx = px * 1.0f / width; |
| 90 | const float fy = py * 1.0f / height; | ||
| 91 | |||
| 92 | input_subsystem->GetTouchScreen()->TouchMoved(fx, fy, id); | ||
| 97 | } | 93 | } |
| 98 | 94 | ||
| 99 | void EmuWindow_SDL2::OnFingerUp() { | 95 | void EmuWindow_SDL2::OnFingerUp() { |
| 100 | TouchReleased(0); | 96 | input_subsystem->GetTouchScreen()->TouchReleased(0); |
| 101 | } | 97 | } |
| 102 | 98 | ||
| 103 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { | 99 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { |
| 104 | if (state == SDL_PRESSED) { | 100 | if (state == SDL_PRESSED) { |
| 105 | input_subsystem->GetKeyboard()->PressKey(key); | 101 | input_subsystem->GetKeyboard()->PressKey(static_cast<std::size_t>(key)); |
| 106 | } else if (state == SDL_RELEASED) { | 102 | } else if (state == SDL_RELEASED) { |
| 107 | input_subsystem->GetKeyboard()->ReleaseKey(key); | 103 | input_subsystem->GetKeyboard()->ReleaseKey(static_cast<std::size_t>(key)); |
| 108 | } | 104 | } |
| 109 | } | 105 | } |
| 110 | 106 | ||
| @@ -205,10 +201,12 @@ void EmuWindow_SDL2::WaitEvent() { | |||
| 205 | } | 201 | } |
| 206 | break; | 202 | break; |
| 207 | case SDL_FINGERDOWN: | 203 | case SDL_FINGERDOWN: |
| 208 | OnFingerDown(event.tfinger.x, event.tfinger.y); | 204 | OnFingerDown(event.tfinger.x, event.tfinger.y, |
| 205 | static_cast<std::size_t>(event.tfinger.touchId)); | ||
| 209 | break; | 206 | break; |
| 210 | case SDL_FINGERMOTION: | 207 | case SDL_FINGERMOTION: |
| 211 | OnFingerMotion(event.tfinger.x, event.tfinger.y); | 208 | OnFingerMotion(event.tfinger.x, event.tfinger.y, |
| 209 | static_cast<std::size_t>(event.tfinger.touchId)); | ||
| 212 | break; | 210 | break; |
| 213 | case SDL_FINGERUP: | 211 | case SDL_FINGERUP: |
| 214 | OnFingerUp(); | 212 | 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; | |||
| 16 | 16 | ||
| 17 | namespace InputCommon { | 17 | namespace InputCommon { |
| 18 | class InputSubsystem; | 18 | class InputSubsystem; |
| 19 | } | ||
| 20 | |||
| 21 | namespace MouseInput { | ||
| 22 | enum class MouseButton; | 19 | enum class MouseButton; |
| 23 | } | 20 | } // namespace InputCommon |
| 24 | 21 | ||
| 25 | class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { | 22 | class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { |
| 26 | public: | 23 | public: |
| @@ -47,7 +44,7 @@ protected: | |||
| 47 | void OnMouseMotion(s32 x, s32 y); | 44 | void OnMouseMotion(s32 x, s32 y); |
| 48 | 45 | ||
| 49 | /// Converts a SDL mouse button into MouseInput mouse button | 46 | /// Converts a SDL mouse button into MouseInput mouse button |
| 50 | MouseInput::MouseButton SDLButtonToMouseButton(u32 button) const; | 47 | InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const; |
| 51 | 48 | ||
| 52 | /// Called by WaitEvent when a mouse button is pressed or released | 49 | /// Called by WaitEvent when a mouse button is pressed or released |
| 53 | void OnMouseButton(u32 button, u8 state, s32 x, s32 y); | 50 | void OnMouseButton(u32 button, u8 state, s32 x, s32 y); |
| @@ -56,10 +53,10 @@ protected: | |||
| 56 | std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const; | 53 | std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const; |
| 57 | 54 | ||
| 58 | /// Called by WaitEvent when a finger starts touching the touchscreen | 55 | /// Called by WaitEvent when a finger starts touching the touchscreen |
| 59 | void OnFingerDown(float x, float y); | 56 | void OnFingerDown(float x, float y, std::size_t id); |
| 60 | 57 | ||
| 61 | /// Called by WaitEvent when a finger moves while touching the touchscreen | 58 | /// Called by WaitEvent when a finger moves while touching the touchscreen |
| 62 | void OnFingerMotion(float x, float y); | 59 | void OnFingerMotion(float x, float y, std::size_t id); |
| 63 | 60 | ||
| 64 | /// Called by WaitEvent when a finger stops touching the touchscreen | 61 | /// Called by WaitEvent when a finger stops touching the touchscreen |
| 65 | void OnFingerUp(); | 62 | 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 @@ | |||
| 17 | #include "common/settings.h" | 17 | #include "common/settings.h" |
| 18 | #include "common/string_util.h" | 18 | #include "common/string_util.h" |
| 19 | #include "core/core.h" | 19 | #include "core/core.h" |
| 20 | #include "input_common/keyboard.h" | ||
| 21 | #include "input_common/main.h" | 20 | #include "input_common/main.h" |
| 22 | #include "video_core/renderer_base.h" | 21 | #include "video_core/renderer_base.h" |
| 23 | #include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h" | 22 | #include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h" |