summaryrefslogtreecommitdiff
path: root/src/citra/emu_window/emu_window_glfw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra/emu_window/emu_window_glfw.cpp')
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index b911e60c5..661521eb7 100644
--- a/src/citra/emu_window/emu_window_glfw.cpp
+++ b/src/citra/emu_window/emu_window_glfw.cpp
@@ -6,26 +6,9 @@
6 6
7#include "video_core/video_core.h" 7#include "video_core/video_core.h"
8 8
9#include "citra/emu_window/emu_window_glfw.h" 9#include "core/settings.h"
10 10
11static const std::pair<int, HID_User::PadState> default_key_map[] = { 11#include "citra/emu_window/emu_window_glfw.h"
12 { GLFW_KEY_A, HID_User::PAD_A },
13 { GLFW_KEY_B, HID_User::PAD_B },
14 { GLFW_KEY_BACKSLASH, HID_User::PAD_SELECT },
15 { GLFW_KEY_ENTER, HID_User::PAD_START },
16 { GLFW_KEY_RIGHT, HID_User::PAD_RIGHT },
17 { GLFW_KEY_LEFT, HID_User::PAD_LEFT },
18 { GLFW_KEY_UP, HID_User::PAD_UP },
19 { GLFW_KEY_DOWN, HID_User::PAD_DOWN },
20 { GLFW_KEY_R, HID_User::PAD_R },
21 { GLFW_KEY_L, HID_User::PAD_L },
22 { GLFW_KEY_X, HID_User::PAD_X },
23 { GLFW_KEY_Y, HID_User::PAD_Y },
24 { GLFW_KEY_H, HID_User::PAD_CIRCLE_RIGHT },
25 { GLFW_KEY_F, HID_User::PAD_CIRCLE_LEFT },
26 { GLFW_KEY_T, HID_User::PAD_CIRCLE_UP },
27 { GLFW_KEY_G, HID_User::PAD_CIRCLE_DOWN },
28};
29 12
30/// Called by GLFW when a key event occurs 13/// Called by GLFW when a key event occurs
31void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) { 14void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
@@ -48,14 +31,9 @@ void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int acti
48 31
49/// EmuWindow_GLFW constructor 32/// EmuWindow_GLFW constructor
50EmuWindow_GLFW::EmuWindow_GLFW() { 33EmuWindow_GLFW::EmuWindow_GLFW() {
51
52 // Register a new ID for the default keyboard
53 keyboard_id = KeyMap::NewDeviceId(); 34 keyboard_id = KeyMap::NewDeviceId();
54 35
55 // Set default key mappings for keyboard 36 ReloadSetKeymaps();
56 for (auto mapping : default_key_map) {
57 KeyMap::SetKeyMapping({mapping.first, keyboard_id}, mapping.second);
58 }
59 37
60 // Initialize the window 38 // Initialize the window
61 if(glfwInit() != GL_TRUE) { 39 if(glfwInit() != GL_TRUE) {
@@ -111,3 +89,22 @@ void EmuWindow_GLFW::MakeCurrent() {
111void EmuWindow_GLFW::DoneCurrent() { 89void EmuWindow_GLFW::DoneCurrent() {
112 glfwMakeContextCurrent(NULL); 90 glfwMakeContextCurrent(NULL);
113} 91}
92
93void EmuWindow_GLFW::ReloadSetKeymaps() {
94 KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, HID_User::PAD_A);
95 KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, HID_User::PAD_B);
96 KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, HID_User::PAD_SELECT);
97 KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, HID_User::PAD_START);
98 KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, HID_User::PAD_RIGHT);
99 KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, HID_User::PAD_LEFT);
100 KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, HID_User::PAD_UP);
101 KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, HID_User::PAD_DOWN);
102 KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, HID_User::PAD_R);
103 KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, HID_User::PAD_L);
104 KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, HID_User::PAD_X);
105 KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, HID_User::PAD_Y);
106 KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, HID_User::PAD_CIRCLE_RIGHT);
107 KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, HID_User::PAD_CIRCLE_LEFT);
108 KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, HID_User::PAD_CIRCLE_UP);
109 KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN);
110}