From 38e800f70d122051e12ac9f22e23d84b97fec424 Mon Sep 17 00:00:00 2001 From: wwylele Date: Sat, 21 Jan 2017 11:53:03 +0200 Subject: InputCommon: add Keyboard --- src/citra/emu_window/emu_window_sdl2.cpp | 21 ++++++--------------- src/citra/emu_window/emu_window_sdl2.h | 6 ------ 2 files changed, 6 insertions(+), 21 deletions(-) (limited to 'src/citra/emu_window') 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 @@ #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(*this); SDL_SetMainReady(); @@ -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& 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_emu; }; -- cgit v1.2.3