Skip to content

Commit f572534

Browse files
committed
Add keycode response for the Win/Command key.
1 parent d619d11 commit f572534

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

native/cocos/engine/EngineEvents.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ enum class KeyCode {
265265
DPAD_LEFT = 1000,
266266
DPAD_DOWN = 1004,
267267
DPAD_RIGHT = 1001,
268-
DPAD_CENTER = 1005
268+
DPAD_CENTER = 1005,
269+
// WIN/Command按钮
270+
LGUI = 20300,
271+
RGUI = 20301,
269272
};
270273

271274
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::LGUI},
39+
{SDLK_RGUI, cc::KeyCode::RGUI},
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ int ohKeyCodeToCocosKeyCode(OH_NativeXComponent_KeyCode ohKeyCode) {
224224
{KEY_NUMPAD_9, cc::KeyCode::NUMPAD_9},
225225

226226
{KEY_MENU, cc::KeyCode::CONTEXT_MENU},
227+
{KEY_SYSRQ, cc::KeyCode::PRINT_SCREEN},
228+
{KEY_META_LEFT, cc::KeyCode::LGUI},
229+
{KEY_META_RIGHT, cc::KeyCode::RGUI},
227230
};
228231
if (keyCodeMap.find(ohKeyCode) != keyCodeMap.end()) {
229232
return int(keyCodeMap[ohKeyCode]);

0 commit comments

Comments
 (0)