From 788f00119cd3bd292738e7d7676c05746840cf0c Mon Sep 17 00:00:00 2001 From: Anon Date: Sat, 30 Jul 2016 11:39:21 -0500 Subject: [PATCH] Fix SDL input. fix travis build error. --- src/citra/config.cpp | 4 ++-- src/citra/emu_window/emu_window_sdl2.cpp | 14 ++++++++++---- src/citra/emu_window/emu_window_sdl2.h | 3 ++- src/core/hle/service/hid/hid.cpp | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index e15063953..1d610c48b 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -58,8 +58,8 @@ static const std::array defaults = { void Config::ReadValues() { // Controls for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { - //Settings::values.input_mappings[Settings::NativeInput::All[i]] = - // sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); + Settings::values.input_mappings[Settings::NativeInput::All[i]] = + sdl2_config->Get("Controls", Settings::NativeInput::Mapping[i], std::to_string(defaults[i])); } Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index ffc7f9cbf..1bf901e92 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp @@ -18,6 +18,9 @@ #include "core/settings.h" #include "core/hle/service/hid/hid.h" +#include "input_core/input_core.h" +#include "input_core/devices/Keyboard.h" + #include "citra/emu_window/emu_window_sdl2.h" #include "video_core/video_core.h" @@ -38,12 +41,15 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { } } -void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { +void EmuWindow_SDL2::OnKeyEvent(SDL_Keysym key, u8 state) { + auto& keyboard = InputCore::main_keyboard; + KeyboardKey param = KeyboardKey(key.sym, key.scancode, SDL_GetKeyName(key.scancode)); + if (state == SDL_PRESSED) { - //KeyMap::PressKey(*this, key); + keyboard->KeyPressed(param); } else if (state == SDL_RELEASED) { - //KeyMap::ReleaseKey(*this, key); + keyboard->KeyReleased(param); } } @@ -144,7 +150,7 @@ void EmuWindow_SDL2::PollEvents() { break; case SDL_KEYDOWN: case SDL_KEYUP: - OnKeyEvent(static_cast(event.key.keysym.scancode), event.key.state); + OnKeyEvent(event.key.keysym, event.key.state); break; case SDL_MOUSEMOTION: OnMouseMotion(event.motion.x, event.motion.y); diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h index 77279f022..10815821a 100644 --- a/src/citra/emu_window/emu_window_sdl2.h +++ b/src/citra/emu_window/emu_window_sdl2.h @@ -9,6 +9,7 @@ #include "common/emu_window.h" struct SDL_Window; +struct SDL_Keysym; class EmuWindow_SDL2 : public EmuWindow { public: @@ -35,7 +36,7 @@ public: private: /// Called by PollEvents when a key is pressed or released. - void OnKeyEvent(int key, u8 state); + void OnKeyEvent(SDL_Keysym key, u8 state); /// Called by PollEvents when the mouse moves. void OnMouseMotion(s32 x, s32 y); diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 61b704150..d0b940b38 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -12,7 +12,7 @@ #include "core/hle/service/hid/hid_spvr.h" #include "core/hle/service/hid/hid_user.h" -#include "input_core\input_core.h" +#include "input_core/input_core.h" #include "core/core_timing.h" #include "core/hle/kernel/event.h"