|
9 | 9 | #include <ace/xcomponent/native_interface_xcomponent.h>
|
10 | 10 | #include "../../video/ohos/SDL_ohosvideo.h"
|
11 | 11 | #include "SDL3/SDL_mutex.h"
|
| 12 | +#include "../../video/ohos/SDL_ohoskeyboard.h" |
12 | 13 |
|
13 | 14 | OHNativeWindow *nativeWindow;
|
14 | 15 | SDL_Mutex *g_ohosPageMutex = NULL;
|
@@ -99,7 +100,32 @@ static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window)
|
99 | 100 | }
|
100 | 101 | #endif
|
101 | 102 | }
|
102 |
| -static void onKeyEvent(OH_NativeXComponent *component, void *window) {} |
| 103 | +static void onKeyEvent(OH_NativeXComponent *component, void *window) |
| 104 | +{ |
| 105 | + OH_NativeXComponent_KeyEvent *keyEvent = NULL; |
| 106 | + if (OH_NativeXComponent_GetKeyEvent(component, &keyEvent) >= 0) |
| 107 | + { |
| 108 | + OH_NativeXComponent_KeyAction action; |
| 109 | + OH_NativeXComponent_KeyCode code; |
| 110 | + OH_NativeXComponent_EventSourceType sourceType; |
| 111 | + |
| 112 | + OH_NativeXComponent_GetKeyEventAction(keyEvent, &action); |
| 113 | + OH_NativeXComponent_GetKeyEventCode(keyEvent, &code); |
| 114 | + OH_NativeXComponent_GetKeyEventSourceType(keyEvent, &sourceType); |
| 115 | + |
| 116 | + if (sourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD) |
| 117 | + { |
| 118 | + if (OH_NATIVEXCOMPONENT_KEY_ACTION_DOWN == action) |
| 119 | + { |
| 120 | + OHOS_OnKeyDown(code); |
| 121 | + } |
| 122 | + else if (OH_NATIVEXCOMPONENT_KEY_ACTION_UP == action) |
| 123 | + { |
| 124 | + OHOS_OnKeyUp(code); |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | +} |
103 | 129 | static void onNativeTouch(OH_NativeXComponent *component, void *window) {}
|
104 | 130 | static void onNativeMouse(OH_NativeXComponent *component, void *window) {}
|
105 | 131 | static void OnDispatchTouchEventCB(OH_NativeXComponent *component, void *window) {}
|
|
0 commit comments