diff options
| author | 2017-03-17 14:59:39 -0400 | |
|---|---|---|
| committer | 2017-03-17 14:59:39 -0400 | |
| commit | 423ab5e2bcf5a522e5f412447c05f648df57a14c (patch) | |
| tree | 1e60eaeffa59229254a47f885d2fe2cbbdc1a5c0 /src/citra/emu_window/emu_window_sdl2.cpp | |
| parent | Merge pull request #2618 from wwylele/log-less-filename (diff) | |
| parent | qt/config_input: don't connect for null button (diff) | |
| download | yuzu-423ab5e2bcf5a522e5f412447c05f648df57a14c.tar.gz yuzu-423ab5e2bcf5a522e5f412447c05f648df57a14c.tar.xz yuzu-423ab5e2bcf5a522e5f412447c05f648df57a14c.zip | |
Merge pull request #2497 from wwylele/input-2
Refactor input emulation & add SDL gamepad support
Diffstat (limited to 'src/citra/emu_window/emu_window_sdl2.cpp')
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index 00d00905a..6bc0b0d00 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp | |||
| @@ -12,9 +12,9 @@ | |||
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/scm_rev.h" | 13 | #include "common/scm_rev.h" |
| 14 | #include "common/string_util.h" | 14 | #include "common/string_util.h" |
| 15 | #include "core/frontend/key_map.h" | ||
| 16 | #include "core/hle/service/hid/hid.h" | ||
| 17 | #include "core/settings.h" | 15 | #include "core/settings.h" |
| 16 | #include "input_common/keyboard.h" | ||
| 17 | #include "input_common/main.h" | ||
| 18 | #include "video_core/video_core.h" | 18 | #include "video_core/video_core.h" |
| 19 | 19 | ||
| 20 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | 20 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { |
| @@ -40,9 +40,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | |||
| 40 | 40 | ||
| 41 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { | 41 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { |
| 42 | if (state == SDL_PRESSED) { | 42 | if (state == SDL_PRESSED) { |
| 43 | KeyMap::PressKey(*this, {key, keyboard_id}); | 43 | InputCommon::GetKeyboard()->PressKey(key); |
| 44 | } else if (state == SDL_RELEASED) { | 44 | } else if (state == SDL_RELEASED) { |
| 45 | KeyMap::ReleaseKey(*this, {key, keyboard_id}); | 45 | InputCommon::GetKeyboard()->ReleaseKey(key); |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | 48 | ||
| @@ -57,9 +57,8 @@ void EmuWindow_SDL2::OnResize() { | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | EmuWindow_SDL2::EmuWindow_SDL2() { | 59 | EmuWindow_SDL2::EmuWindow_SDL2() { |
| 60 | keyboard_id = KeyMap::NewDeviceId(); | 60 | InputCommon::Init(); |
| 61 | 61 | ||
| 62 | ReloadSetKeymaps(); | ||
| 63 | motion_emu = std::make_unique<Motion::MotionEmu>(*this); | 62 | motion_emu = std::make_unique<Motion::MotionEmu>(*this); |
| 64 | 63 | ||
| 65 | SDL_SetMainReady(); | 64 | SDL_SetMainReady(); |
| @@ -117,6 +116,7 @@ EmuWindow_SDL2::~EmuWindow_SDL2() { | |||
| 117 | SDL_GL_DeleteContext(gl_context); | 116 | SDL_GL_DeleteContext(gl_context); |
| 118 | SDL_Quit(); | 117 | SDL_Quit(); |
| 119 | motion_emu = nullptr; | 118 | motion_emu = nullptr; |
| 119 | InputCommon::Shutdown(); | ||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void EmuWindow_SDL2::SwapBuffers() { | 122 | void EmuWindow_SDL2::SwapBuffers() { |
| @@ -169,15 +169,6 @@ void EmuWindow_SDL2::DoneCurrent() { | |||
| 169 | SDL_GL_MakeCurrent(render_window, nullptr); | 169 | SDL_GL_MakeCurrent(render_window, nullptr); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | void EmuWindow_SDL2::ReloadSetKeymaps() { | ||
| 173 | KeyMap::ClearKeyMapping(keyboard_id); | ||
| 174 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | ||
| 175 | KeyMap::SetKeyMapping( | ||
| 176 | {Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id}, | ||
| 177 | KeyMap::mapping_targets[i]); | ||
| 178 | } | ||
| 179 | } | ||
| 180 | |||
| 181 | void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest( | 172 | void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest( |
| 182 | const std::pair<unsigned, unsigned>& minimal_size) { | 173 | const std::pair<unsigned, unsigned>& minimal_size) { |
| 183 | 174 | ||