InputCommon: add Keyboard
This commit is contained in:
parent
70420272ca
commit
38e800f70d
17 changed files with 254 additions and 85 deletions
|
@ -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<Motion::MotionEmu>(*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<unsigned, unsigned>& minimal_size) {
|
||||
|
||||
|
|
|
@ -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::MotionEmu> motion_emu;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue