Skip to content

Commit b8d80cb

Browse files
authored
Add response for the keyboard "Menu" button. (#19096)
* Add response for the keyboard "Menu" button. * Add keycode response for the Win/Command key. * Add keycode response for the Win/Command key.
1 parent 1b7bbb6 commit b8d80cb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

native/cocos/engine/EngineEvents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ enum class KeyCode {
265265
DPAD_LEFT = 1000,
266266
DPAD_DOWN = 1004,
267267
DPAD_RIGHT = 1001,
268-
DPAD_CENTER = 1005
268+
DPAD_CENTER = 1005,
269269
};
270270

271271
class KeyboardEvent {

native/cocos/platform/SDLHelper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
namespace {
3737
std::unordered_map<int, cc::KeyCode> gKeyMap = {
38+
{SDLK_LGUI, cc::KeyCode::META_LEFT},
39+
{SDLK_RGUI, cc::KeyCode::META_RIGHT},
3840
{SDLK_APPLICATION, cc::KeyCode::CONTEXT_MENU},
3941
{SDLK_SCROLLLOCK, cc::KeyCode::SCROLLLOCK},
4042
{SDLK_PAUSE, cc::KeyCode::PAUSE},

native/cocos/platform/openharmony/OpenHarmonyPlatform.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ int ohKeyCodeToCocosKeyCode(OH_NativeXComponent_KeyCode ohKeyCode) {
222222
{KEY_NUMPAD_7, cc::KeyCode::NUMPAD_7},
223223
{KEY_NUMPAD_8, cc::KeyCode::NUMPAD_8},
224224
{KEY_NUMPAD_9, cc::KeyCode::NUMPAD_9},
225+
226+
{KEY_MENU, cc::KeyCode::CONTEXT_MENU},
227+
{KEY_SYSRQ, cc::KeyCode::PRINT_SCREEN},
228+
{KEY_META_LEFT, cc::KeyCode::META_LEFT},
229+
{KEY_META_RIGHT, cc::KeyCode::META_RIGHT},
225230
};
226231
if (keyCodeMap.find(ohKeyCode) != keyCodeMap.end()) {
227232
return int(keyCodeMap[ohKeyCode]);

0 commit comments

Comments
 (0)