diff options
Diffstat (limited to '')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 337 |
1 files changed, 120 insertions, 217 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 6acfb7b06..d88efacd7 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -401,224 +401,127 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { } int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) { - switch (qt_key) { - case Qt::Key_A: - return Settings::NativeKeyboard::A; - case Qt::Key_B: - return Settings::NativeKeyboard::B; - case Qt::Key_C: - return Settings::NativeKeyboard::C; - case Qt::Key_D: - return Settings::NativeKeyboard::D; - case Qt::Key_E: - return Settings::NativeKeyboard::E; - case Qt::Key_F: - return Settings::NativeKeyboard::F; - case Qt::Key_G: - return Settings::NativeKeyboard::G; - case Qt::Key_H: - return Settings::NativeKeyboard::H; - case Qt::Key_I: - return Settings::NativeKeyboard::I; - case Qt::Key_J: - return Settings::NativeKeyboard::J; - case Qt::Key_K: - return Settings::NativeKeyboard::K; - case Qt::Key_L: - return Settings::NativeKeyboard::L; - case Qt::Key_M: - return Settings::NativeKeyboard::M; - case Qt::Key_N: - return Settings::NativeKeyboard::N; - case Qt::Key_O: - return Settings::NativeKeyboard::O; - case Qt::Key_P: - return Settings::NativeKeyboard::P; - case Qt::Key_Q: - return Settings::NativeKeyboard::Q; - case Qt::Key_R: - return Settings::NativeKeyboard::R; - case Qt::Key_S: - return Settings::NativeKeyboard::S; - case Qt::Key_T: - return Settings::NativeKeyboard::T; - case Qt::Key_U: - return Settings::NativeKeyboard::U; - case Qt::Key_V: - return Settings::NativeKeyboard::V; - case Qt::Key_W: - return Settings::NativeKeyboard::W; - case Qt::Key_X: - return Settings::NativeKeyboard::X; - case Qt::Key_Y: - return Settings::NativeKeyboard::Y; - case Qt::Key_Z: - return Settings::NativeKeyboard::Z; - case Qt::Key_1: - return Settings::NativeKeyboard::N1; - case Qt::Key_2: - return Settings::NativeKeyboard::N2; - case Qt::Key_3: - return Settings::NativeKeyboard::N3; - case Qt::Key_4: - return Settings::NativeKeyboard::N4; - case Qt::Key_5: - return Settings::NativeKeyboard::N5; - case Qt::Key_6: - return Settings::NativeKeyboard::N6; - case Qt::Key_7: - return Settings::NativeKeyboard::N7; - case Qt::Key_8: - return Settings::NativeKeyboard::N8; - case Qt::Key_9: - return Settings::NativeKeyboard::N9; - case Qt::Key_0: - return Settings::NativeKeyboard::N0; - case Qt::Key_Return: - return Settings::NativeKeyboard::Return; - case Qt::Key_Escape: - return Settings::NativeKeyboard::Escape; - case Qt::Key_Backspace: - return Settings::NativeKeyboard::Backspace; - case Qt::Key_Tab: - return Settings::NativeKeyboard::Tab; - case Qt::Key_Space: - return Settings::NativeKeyboard::Space; - case Qt::Key_Minus: - return Settings::NativeKeyboard::Minus; - case Qt::Key_Plus: - case Qt::Key_questiondown: - return Settings::NativeKeyboard::Plus; - case Qt::Key_BracketLeft: - case Qt::Key_BraceLeft: - return Settings::NativeKeyboard::OpenBracket; - case Qt::Key_BracketRight: - case Qt::Key_BraceRight: - return Settings::NativeKeyboard::CloseBracket; - case Qt::Key_Bar: - return Settings::NativeKeyboard::Pipe; - case Qt::Key_Dead_Tilde: - return Settings::NativeKeyboard::Tilde; - case Qt::Key_Ntilde: - case Qt::Key_Semicolon: - return Settings::NativeKeyboard::Semicolon; - case Qt::Key_Apostrophe: - return Settings::NativeKeyboard::Quote; - case Qt::Key_Dead_Grave: - return Settings::NativeKeyboard::Backquote; - case Qt::Key_Comma: - return Settings::NativeKeyboard::Comma; - case Qt::Key_Period: - return Settings::NativeKeyboard::Period; - case Qt::Key_Slash: - return Settings::NativeKeyboard::Slash; - case Qt::Key_CapsLock: - return Settings::NativeKeyboard::CapsLock; - case Qt::Key_F1: - return Settings::NativeKeyboard::F1; - case Qt::Key_F2: - return Settings::NativeKeyboard::F2; - case Qt::Key_F3: - return Settings::NativeKeyboard::F3; - case Qt::Key_F4: - return Settings::NativeKeyboard::F4; - case Qt::Key_F5: - return Settings::NativeKeyboard::F5; - case Qt::Key_F6: - return Settings::NativeKeyboard::F6; - case Qt::Key_F7: - return Settings::NativeKeyboard::F7; - case Qt::Key_F8: - return Settings::NativeKeyboard::F8; - case Qt::Key_F9: - return Settings::NativeKeyboard::F9; - case Qt::Key_F10: - return Settings::NativeKeyboard::F10; - case Qt::Key_F11: - return Settings::NativeKeyboard::F11; - case Qt::Key_F12: - return Settings::NativeKeyboard::F12; - case Qt::Key_Print: - return Settings::NativeKeyboard::PrintScreen; - case Qt::Key_ScrollLock: - return Settings::NativeKeyboard::ScrollLock; - case Qt::Key_Pause: - return Settings::NativeKeyboard::Pause; - case Qt::Key_Insert: - return Settings::NativeKeyboard::Insert; - case Qt::Key_Home: - return Settings::NativeKeyboard::Home; - case Qt::Key_PageUp: - return Settings::NativeKeyboard::PageUp; - case Qt::Key_Delete: - return Settings::NativeKeyboard::Delete; - case Qt::Key_End: - return Settings::NativeKeyboard::End; - case Qt::Key_PageDown: - return Settings::NativeKeyboard::PageDown; - case Qt::Key_Right: - return Settings::NativeKeyboard::Right; - case Qt::Key_Left: - return Settings::NativeKeyboard::Left; - case Qt::Key_Down: - return Settings::NativeKeyboard::Down; - case Qt::Key_Up: - return Settings::NativeKeyboard::Up; - case Qt::Key_NumLock: - return Settings::NativeKeyboard::NumLock; - // Numpad keys are missing here - case Qt::Key_F13: - return Settings::NativeKeyboard::F13; - case Qt::Key_F14: - return Settings::NativeKeyboard::F14; - case Qt::Key_F15: - return Settings::NativeKeyboard::F15; - case Qt::Key_F16: - return Settings::NativeKeyboard::F16; - case Qt::Key_F17: - return Settings::NativeKeyboard::F17; - case Qt::Key_F18: - return Settings::NativeKeyboard::F18; - case Qt::Key_F19: - return Settings::NativeKeyboard::F19; - case Qt::Key_F20: - return Settings::NativeKeyboard::F20; - case Qt::Key_F21: - return Settings::NativeKeyboard::F21; - case Qt::Key_F22: - return Settings::NativeKeyboard::F22; - case Qt::Key_F23: - return Settings::NativeKeyboard::F23; - case Qt::Key_F24: - return Settings::NativeKeyboard::F24; - // case Qt::: - // return Settings::NativeKeyboard::KPComma; - // case Qt::: - // return Settings::NativeKeyboard::Ro; - case Qt::Key_Hiragana_Katakana: - return Settings::NativeKeyboard::KatakanaHiragana; - case Qt::Key_yen: - return Settings::NativeKeyboard::Yen; - case Qt::Key_Henkan: - return Settings::NativeKeyboard::Henkan; - case Qt::Key_Muhenkan: - return Settings::NativeKeyboard::Muhenkan; - // case Qt::: - // return Settings::NativeKeyboard::NumPadCommaPc98; - case Qt::Key_Hangul: - return Settings::NativeKeyboard::HangulEnglish; - case Qt::Key_Hangul_Hanja: - return Settings::NativeKeyboard::Hanja; - case Qt::Key_Katakana: - return Settings::NativeKeyboard::KatakanaKey; - case Qt::Key_Hiragana: - return Settings::NativeKeyboard::HiraganaKey; - case Qt::Key_Zenkaku_Hankaku: - return Settings::NativeKeyboard::ZenkakuHankaku; - // Modifier keys are handled by the modifier property - default: - return Settings::NativeKeyboard::None; + static constexpr std::array<std::pair<Qt::Key, Settings::NativeKeyboard::Keys>, 106> key_map = { + std::pair<Qt::Key, Settings::NativeKeyboard::Keys>{Qt::Key_A, Settings::NativeKeyboard::A}, + {Qt::Key_A, Settings::NativeKeyboard::A}, + {Qt::Key_B, Settings::NativeKeyboard::B}, + {Qt::Key_C, Settings::NativeKeyboard::C}, + {Qt::Key_D, Settings::NativeKeyboard::D}, + {Qt::Key_E, Settings::NativeKeyboard::E}, + {Qt::Key_F, Settings::NativeKeyboard::F}, + {Qt::Key_G, Settings::NativeKeyboard::G}, + {Qt::Key_H, Settings::NativeKeyboard::H}, + {Qt::Key_I, Settings::NativeKeyboard::I}, + {Qt::Key_J, Settings::NativeKeyboard::J}, + {Qt::Key_K, Settings::NativeKeyboard::K}, + {Qt::Key_L, Settings::NativeKeyboard::L}, + {Qt::Key_M, Settings::NativeKeyboard::M}, + {Qt::Key_N, Settings::NativeKeyboard::N}, + {Qt::Key_O, Settings::NativeKeyboard::O}, + {Qt::Key_P, Settings::NativeKeyboard::P}, + {Qt::Key_Q, Settings::NativeKeyboard::Q}, + {Qt::Key_R, Settings::NativeKeyboard::R}, + {Qt::Key_S, Settings::NativeKeyboard::S}, + {Qt::Key_T, Settings::NativeKeyboard::T}, + {Qt::Key_U, Settings::NativeKeyboard::U}, + {Qt::Key_V, Settings::NativeKeyboard::V}, + {Qt::Key_W, Settings::NativeKeyboard::W}, + {Qt::Key_X, Settings::NativeKeyboard::X}, + {Qt::Key_Y, Settings::NativeKeyboard::Y}, + {Qt::Key_Z, Settings::NativeKeyboard::Z}, + {Qt::Key_1, Settings::NativeKeyboard::N1}, + {Qt::Key_2, Settings::NativeKeyboard::N2}, + {Qt::Key_3, Settings::NativeKeyboard::N3}, + {Qt::Key_4, Settings::NativeKeyboard::N4}, + {Qt::Key_5, Settings::NativeKeyboard::N5}, + {Qt::Key_6, Settings::NativeKeyboard::N6}, + {Qt::Key_7, Settings::NativeKeyboard::N7}, + {Qt::Key_8, Settings::NativeKeyboard::N8}, + {Qt::Key_9, Settings::NativeKeyboard::N9}, + {Qt::Key_0, Settings::NativeKeyboard::N0}, + {Qt::Key_Return, Settings::NativeKeyboard::Return}, + {Qt::Key_Escape, Settings::NativeKeyboard::Escape}, + {Qt::Key_Backspace, Settings::NativeKeyboard::Backspace}, + {Qt::Key_Tab, Settings::NativeKeyboard::Tab}, + {Qt::Key_Space, Settings::NativeKeyboard::Space}, + {Qt::Key_Minus, Settings::NativeKeyboard::Minus}, + {Qt::Key_Plus, Settings::NativeKeyboard::Plus}, + {Qt::Key_questiondown, Settings::NativeKeyboard::Plus}, + {Qt::Key_BracketLeft, Settings::NativeKeyboard::OpenBracket}, + {Qt::Key_BraceLeft, Settings::NativeKeyboard::OpenBracket}, + {Qt::Key_BracketRight, Settings::NativeKeyboard::CloseBracket}, + {Qt::Key_BraceRight, Settings::NativeKeyboard::CloseBracket}, + {Qt::Key_Bar, Settings::NativeKeyboard::Pipe}, + {Qt::Key_Dead_Tilde, Settings::NativeKeyboard::Tilde}, + {Qt::Key_Ntilde, Settings::NativeKeyboard::Semicolon}, + {Qt::Key_Semicolon, Settings::NativeKeyboard::Semicolon}, + {Qt::Key_Apostrophe, Settings::NativeKeyboard::Quote}, + {Qt::Key_Dead_Grave, Settings::NativeKeyboard::Backquote}, + {Qt::Key_Comma, Settings::NativeKeyboard::Comma}, + {Qt::Key_Period, Settings::NativeKeyboard::Period}, + {Qt::Key_Slash, Settings::NativeKeyboard::Slash}, + {Qt::Key_CapsLock, Settings::NativeKeyboard::CapsLockKey}, + {Qt::Key_F1, Settings::NativeKeyboard::F1}, + {Qt::Key_F2, Settings::NativeKeyboard::F2}, + {Qt::Key_F3, Settings::NativeKeyboard::F3}, + {Qt::Key_F4, Settings::NativeKeyboard::F4}, + {Qt::Key_F5, Settings::NativeKeyboard::F5}, + {Qt::Key_F6, Settings::NativeKeyboard::F6}, + {Qt::Key_F7, Settings::NativeKeyboard::F7}, + {Qt::Key_F8, Settings::NativeKeyboard::F8}, + {Qt::Key_F9, Settings::NativeKeyboard::F9}, + {Qt::Key_F10, Settings::NativeKeyboard::F10}, + {Qt::Key_F11, Settings::NativeKeyboard::F11}, + {Qt::Key_F12, Settings::NativeKeyboard::F12}, + {Qt::Key_Print, Settings::NativeKeyboard::PrintScreen}, + {Qt::Key_ScrollLock, Settings::NativeKeyboard::ScrollLockKey}, + {Qt::Key_Pause, Settings::NativeKeyboard::Pause}, + {Qt::Key_Insert, Settings::NativeKeyboard::Insert}, + {Qt::Key_Home, Settings::NativeKeyboard::Home}, + {Qt::Key_PageUp, Settings::NativeKeyboard::PageUp}, + {Qt::Key_Delete, Settings::NativeKeyboard::Delete}, + {Qt::Key_End, Settings::NativeKeyboard::End}, + {Qt::Key_PageDown, Settings::NativeKeyboard::PageDown}, + {Qt::Key_Right, Settings::NativeKeyboard::Right}, + {Qt::Key_Left, Settings::NativeKeyboard::Left}, + {Qt::Key_Down, Settings::NativeKeyboard::Down}, + {Qt::Key_Up, Settings::NativeKeyboard::Up}, + {Qt::Key_NumLock, Settings::NativeKeyboard::NumLockKey}, + // Numpad keys are missing here + {Qt::Key_F13, Settings::NativeKeyboard::F13}, + {Qt::Key_F14, Settings::NativeKeyboard::F14}, + {Qt::Key_F15, Settings::NativeKeyboard::F15}, + {Qt::Key_F16, Settings::NativeKeyboard::F16}, + {Qt::Key_F17, Settings::NativeKeyboard::F17}, + {Qt::Key_F18, Settings::NativeKeyboard::F18}, + {Qt::Key_F19, Settings::NativeKeyboard::F19}, + {Qt::Key_F20, Settings::NativeKeyboard::F20}, + {Qt::Key_F21, Settings::NativeKeyboard::F21}, + {Qt::Key_F22, Settings::NativeKeyboard::F22}, + {Qt::Key_F23, Settings::NativeKeyboard::F23}, + {Qt::Key_F24, Settings::NativeKeyboard::F24}, + // {Qt::..., Settings::NativeKeyboard::KPComma}, + // {Qt::..., Settings::NativeKeyboard::Ro}, + {Qt::Key_Hiragana_Katakana, Settings::NativeKeyboard::KatakanaHiragana}, + {Qt::Key_yen, Settings::NativeKeyboard::Yen}, + {Qt::Key_Henkan, Settings::NativeKeyboard::Henkan}, + {Qt::Key_Muhenkan, Settings::NativeKeyboard::Muhenkan}, + // {Qt::..., Settings::NativeKeyboard::NumPadCommaPc98}, + {Qt::Key_Hangul, Settings::NativeKeyboard::HangulEnglish}, + {Qt::Key_Hangul_Hanja, Settings::NativeKeyboard::Hanja}, + {Qt::Key_Katakana, Settings::NativeKeyboard::KatakanaKey}, + {Qt::Key_Hiragana, Settings::NativeKeyboard::HiraganaKey}, + {Qt::Key_Zenkaku_Hankaku, Settings::NativeKeyboard::ZenkakuHankaku}, + // Modifier keys are handled by the modifier property + }; + + for (const auto& [qkey, nkey] : key_map) { + if (qt_key == qkey) { + return nkey; + } } + + return Settings::NativeKeyboard::None; } int GRenderWindow::QtModifierToSwitchModifier(Qt::KeyboardModifiers qt_modifiers) { |