1 # Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 
14 import("//build/config/components/multimodalinput/cursor_config.gni")
15 import("//build/ohos.gni")
16 
17 mmi_part_name = "input"
18 mmi_subsystem_name = "multimodalinput"
19 mmi_path = "//foundation/multimodalinput/input"
20 graphics_path = "//foundation/graphic/graphic_2d/rosen/modules"
21 preferences_path = "//foundation/distributeddatamgr/preferences"
22 ability_runtime_path = "//foundation/ability/ability_runtime"
23 security_component_path = "//base/security"
24 c_utils_root = "//commonlibrary/c_utils"
25 hilog_root = "//base/hiviewdfx/hilog"
26 
27 declare_args() {
28   call_manager_service_enabled = false
29   resource_schedule_service_enabled = false
30   screenlock_manager_enabled = false
31   input_feature_product = "default"
32   input_feature_enable_pgo = false
33   input_feature_pgo_path = ""
34   input_feature_combination_key = true
35   input_feature_pointer_drawing = true
36   input_feature_interceptor = true
37   input_feature_monitor = true
38   input_feature_keyboard = true
39   input_feature_switch = true
40   input_feature_mouse = true
41   input_feature_joystick = true
42   input_feature_touchscreen = true
43   input_feature_input_device = true
44   input_feature_coverage = false
45   input_feature_short_key = true
46   input_ext_feature_anco = false
47   input_ext_feature_fingersense = true
48   input_ext_feature_gesturesense = true
49   input_feature_fingerprint = false
50   input_feature_crown = true
51   input_new_knuckle_dynamic_enabled = true
52 
53   if (defined(global_parts_info) &&
54       defined(global_parts_info.telephony_call_manager)) {
55     call_manager_service_enabled = true
56   }
57 
58   if (defined(global_parts_info) &&
59       defined(global_parts_info.resourceschedule_resource_schedule_service)) {
60     resource_schedule_service_enabled = true
61   }
62 
63   if (defined(global_parts_info) &&
64       defined(global_parts_info.theme_screenlock_mgr)) {
65     screenlock_manager_enabled = true
66   }
67 
68   if (is_emulator) {
69     input_feature_pointer_drawing = false
70   }
71 
72   uinput_inject_sources = [
73     "uinput/hdf_device_event_dispatch.cpp",
74     "uinput/hdf_device_event_manager.cpp",
75     "uinput/inject_thread.cpp",
76     "uinput/keyboard_inject.cpp",
77     "uinput/virtual_device.cpp",
78     "uinput/virtual_keyboard.cpp",
79     "uinput/virtual_touch_screen.cpp",
80   ]
81 
82   libmmi_common_sources = [
83     "events/src/axis_event.cpp",
84     "events/src/input_device.cpp",
85     "events/src/input_event.cpp",
86     "events/src/key_event.cpp",
87     "events/src/key_option.cpp",
88     "events/src/pointer_event.cpp",
89   ]
90 
91   libmmi_client_sources = [
92     "event_handler/src/anr_handler.cpp",
93     "event_handler/src/bytrace_adapter.cpp",
94     "event_handler/src/client_msg_handler.cpp",
95     "event_handler/src/input_device_impl.cpp",
96     "event_handler/src/input_handler_manager.cpp",
97     "event_handler/src/input_manager_impl.cpp",
98     "event_handler/src/multimodal_event_handler.cpp",
99     "event_handler/src/scene_board_judgement.cpp",
100     "events/src/input_manager.cpp",
101     "module_loader/src/mmi_client.cpp",
102     "module_loader/src/mmi_fd_listener.cpp",
103   ]
104 
105   libmmi_service_sources = [
106     "$mmi_path/frameworks/proxy/event_handler/src/bytrace_adapter.cpp",
107     "$mmi_path/frameworks/proxy/event_handler/src/scene_board_judgement.cpp",
108     "app_state_manager/src/app_state_observer.cpp",
109     "delegate_task/src/delegate_interface.cpp",
110     "delegate_task/src/delegate_tasks.cpp",
111     "device_config/src/device_config_file_parser.cpp",
112     "device_manager/src/input_device_manager.cpp",
113     "device_state_manager/src/device_event_monitor.cpp",
114     "dfx/src/dfx_hisysevent.cpp",
115     "event_dispatch/src/event_dispatch_handler.cpp",
116     "event_dump/src/event_dump.cpp",
117     "event_handler/src/anr_manager.cpp",
118     "event_handler/src/event_normalize_handler.cpp",
119     "event_handler/src/input_event_handler.cpp",
120     "event_handler/src/key_auto_repeat.cpp",
121     "event_handler/src/key_event_value_transformation.cpp",
122     "event_handler/src/key_map_manager.cpp",
123     "fingersense_wrapper/src/fingersense_wrapper.cpp",
124     "gesturesense_wrapper/src/gesturesense_wrapper.cpp",
125     "hardware_cursor_pointer_manager/src/hardware_cursor_pointer_manager.cpp",
126     "key_command/src/setting_datashare.cpp",
127     "key_command/src/setting_observer.cpp",
128     "libinput_adapter/src/hotplug_detector.cpp",
129     "libinput_adapter/src/libinput_adapter.cpp",
130     "message_handle/src/authorization_dialog.cpp",
131     "message_handle/src/authorize_helper.cpp",
132     "message_handle/src/client_death_handler.cpp",
133     "message_handle/src/inject_notice_manager.cpp",
134     "message_handle/src/server_msg_handler.cpp",
135     "module_loader/src/app_debug_listener.cpp",
136     "module_loader/src/mmi_service.cpp",
137     "module_loader/src/multimodal_input_preferences_manager.cpp",
138     "module_loader/src/uds_server.cpp",
139     "module_loader/src/watchdog_task.cpp",
140     "nap_process/src/nap_process.cpp",
141     "permission_helper/src/permission_helper.cpp",
142     "timer_manager/src/timer_manager.cpp",
143     "window_manager/src/input_display_bind_helper.cpp",
144     "window_manager/src/input_windows_manager.cpp",
145   ]
146 
147   infraredemitter_sources = [ "src/js_register_module.cpp" ]
148 
149   inputdevice_sources = [
150     "src/js_event_target.cpp",
151     "src/js_input_device_context.cpp",
152     "src/js_input_device_manager.cpp",
153     "src/js_util.cpp",
154     "src/native_register_module.cpp",
155   ]
156 
157   inputmonitor_sources = [
158     "src/js_input_monitor.cpp",
159     "src/js_input_monitor_manager.cpp",
160     "src/js_input_monitor_module.cpp",
161   ]
162 
163   patch_gen_libinput_third_mmi_sources = [
164     root_out_dir + "/diff_libinput_mmi/src/evdev-debounce.c",
165     root_out_dir + "/diff_libinput_mmi/src/evdev-fallback.c",
166     root_out_dir + "/diff_libinput_mmi/src/evdev-joystick.c",
167     root_out_dir + "/diff_libinput_mmi/src/evdev-privacy-switch.c",
168     root_out_dir + "/diff_libinput_mmi/src/evdev-middle-button.c",
169     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad-buttons.c",
170     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad-edge-scroll.c",
171     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad-gestures.c",
172     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad-tap.c",
173     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad-thumb.c",
174     root_out_dir + "/diff_libinput_mmi/src/evdev-mt-touchpad.c",
175     root_out_dir + "/diff_libinput_mmi/src/evdev-tablet-pad-leds.c",
176     root_out_dir + "/diff_libinput_mmi/src/evdev-tablet-pad.c",
177     root_out_dir + "/diff_libinput_mmi/src/evdev-tablet.c",
178     root_out_dir + "/diff_libinput_mmi/src/evdev-totem.c",
179     root_out_dir + "/diff_libinput_mmi/src/evdev-wheel.c",
180     root_out_dir + "/diff_libinput_mmi/src/evdev.c",
181     root_out_dir + "/diff_libinput_mmi/src/filter-custom.c",
182     root_out_dir + "/diff_libinput_mmi/src/filter-flat.c",
183     root_out_dir + "/diff_libinput_mmi/src/filter-low-dpi.c",
184     root_out_dir + "/diff_libinput_mmi/src/filter-mouse.c",
185     root_out_dir + "/diff_libinput_mmi/src/filter-tablet.c",
186     root_out_dir + "/diff_libinput_mmi/src/filter-touchpad-flat.c",
187     root_out_dir + "/diff_libinput_mmi/src/filter-touchpad-x230.c",
188     root_out_dir + "/diff_libinput_mmi/src/filter-touchpad.c",
189     root_out_dir + "/diff_libinput_mmi/src/filter-trackpoint-flat.c",
190     root_out_dir + "/diff_libinput_mmi/src/filter-trackpoint.c",
191     root_out_dir + "/diff_libinput_mmi/src/filter.c",
192     root_out_dir + "/diff_libinput_mmi/src/libinput-util.c",
193     root_out_dir + "/diff_libinput_mmi/src/libinput.c",
194     root_out_dir + "/diff_libinput_mmi/src/path-seat.c",
195     root_out_dir + "/diff_libinput_mmi/src/quirks.c",
196     root_out_dir + "/diff_libinput_mmi/src/timer.c",
197     root_out_dir + "/diff_libinput_mmi/src/util-list.c",
198     root_out_dir + "/diff_libinput_mmi/src/util-prop-parsers.c",
199     root_out_dir + "/diff_libinput_mmi/src/util-ratelimit.c",
200     root_out_dir + "/diff_libinput_mmi/src/util-strings.c",
201   ]
202 
203   patch_gen_libmtdev_third_mmi_sources = [
204     root_out_dir + "/diff_libmtdev_mmi/src/caps.c",
205     root_out_dir + "/diff_libmtdev_mmi/src/core.c",
206     root_out_dir + "/diff_libmtdev_mmi/src/iobuf.c",
207     root_out_dir + "/diff_libmtdev_mmi/src/match.c",
208     root_out_dir + "/diff_libmtdev_mmi/src/match_four.c",
209   ]
210 
211   event_injection_sources = [
212     "src/device_base.cpp",
213     "src/get_device_node.cpp",
214     "src/get_device_object.cpp",
215     "src/injection_event_dispatch.cpp",
216     "src/injection_tools_help_func.cpp",
217     "src/input_parse.cpp",
218     "src/manage_inject_device.cpp",
219     "src/processing_finger_device.cpp",
220     "src/processing_game_pad_device.cpp",
221     "src/processing_joystick_device.cpp",
222     "src/processing_keyboard_device.cpp",
223     "src/processing_mouse_device.cpp",
224     "src/processing_pad_device.cpp",
225     "src/processing_pen_device.cpp",
226     "src/processing_touch_screen_device.cpp",
227   ]
228 
229   libmmi_virtual_device_sources = [
230     "src/virtual_crown.cpp",
231     "src/virtual_device.cpp",
232     "src/virtual_finger.cpp",
233     "src/virtual_gamepad.cpp",
234     "src/virtual_joystick.cpp",
235     "src/virtual_keyboard.cpp",
236     "src/virtual_keyboard_consumer_ctrl.cpp",
237     "src/virtual_keyboard_ext.cpp",
238     "src/virtual_keyboard_sys_ctrl.cpp",
239     "src/virtual_knob.cpp",
240     "src/virtual_knob_consumer_ctrl.cpp",
241     "src/virtual_knob_mouse.cpp",
242     "src/virtual_knob_sys_ctrl.cpp",
243     "src/virtual_mouse.cpp",
244     "src/virtual_pc_switch.cpp",
245     "src/virtual_pc_touchpad.cpp",
246     "src/virtual_pen.cpp",
247     "src/virtual_pen_keyboard.cpp",
248     "src/virtual_pen_mouse.cpp",
249     "src/virtual_remote_control.cpp",
250     "src/virtual_single_finger.cpp",
251     "src/virtual_single_touchscreen.cpp",
252     "src/virtual_stylus.cpp",
253     "src/virtual_touchpad.cpp",
254     "src/virtual_touchscreen.cpp",
255     "src/virtual_trackball.cpp",
256     "src/virtual_trackpad.cpp",
257     "src/virtual_trackpad_mouse.cpp",
258     "src/virtual_trackpad_sys_ctrl.cpp",
259   ]
260 
261   libmmi_util_sources = [
262     "common/src/input_event_data_transformation.cpp",
263     "common/src/klog.cpp",
264     "common/src/util.cpp",
265     "network/src/circle_stream_buffer.cpp",
266     "network/src/net_packet.cpp",
267     "network/src/stream_buffer.cpp",
268     "socket/src/uds_client.cpp",
269     "socket/src/uds_session.cpp",
270     "socket/src/uds_socket.cpp",
271   ]
272 }
273 
274 if (input_feature_joystick) {
275   input_feature_mouse = true
276 }
277 
278 print("input_feature_combination_key = ${input_feature_combination_key}")
279 print("input_feature_pointer_drawing = ${input_feature_pointer_drawing}")
280 print("input_feature_monitor = ${input_feature_monitor}")
281 print("input_feature_interceptor = ${input_feature_interceptor}")
282 print("input_feature_keyboard = ${input_feature_keyboard}")
283 print("input_feature_switch = ${input_feature_switch}")
284 print("input_feature_mouse = ${input_feature_mouse}")
285 print("input_feature_joystick = ${input_feature_joystick}")
286 print("input_feature_touchscreen = ${input_feature_touchscreen}")
287 print("input_feature_input_device = ${input_feature_input_device}")
288 print("input_feature_short_key = ${input_feature_short_key}")
289 
290 input_default_defines = []
291 
292 if (input_new_knuckle_dynamic_enabled) {
293   input_default_defines += [ "OHOS_BUILD_ENABLE_NEW_KNUCKLE_DYNAMIC" ]
294 }
295 
296 if (input_feature_pointer_drawing) {
297   input_default_defines += [ "OHOS_BUILD_ENABLE_POINTER_DRAWING" ]
298 }
299 
300 if (input_feature_interceptor) {
301   input_default_defines += [ "OHOS_BUILD_ENABLE_INTERCEPTOR" ]
302 }
303 
304 if (input_feature_keyboard) {
305   input_default_defines += [ "OHOS_BUILD_ENABLE_KEYBOARD" ]
306 }
307 
308 if (input_feature_switch) {
309   input_default_defines += [ "OHOS_BUILD_ENABLE_SWITCH" ]
310 }
311 
312 if (input_feature_monitor) {
313   input_default_defines += [ "OHOS_BUILD_ENABLE_MONITOR" ]
314 }
315 
316 if (input_feature_touchscreen) {
317   input_default_defines += [ "OHOS_BUILD_ENABLE_TOUCH" ]
318 }
319 
320 if (input_feature_mouse) {
321   input_default_defines += [ "OHOS_BUILD_ENABLE_POINTER" ]
322 }
323 
324 if (input_feature_joystick) {
325   input_default_defines += [ "OHOS_BUILD_ENABLE_JOYSTICK" ]
326 }
327 
328 if (input_feature_short_key) {
329   input_default_defines += [ "OHOS_BUILD_ENABLE_SHORT_KEY" ]
330 }
331 
332 if (input_feature_fingerprint) {
333   input_default_defines += [ "OHOS_BUILD_ENABLE_FINGERPRINT" ]
334 }
335 
336 if (input_feature_crown) {
337   input_default_defines += [ "OHOS_BUILD_ENABLE_CROWN" ]
338 }
339 
340 if (!defined(global_parts_info) ||
341     defined(global_parts_info.security_security_component_manager)) {
342   security_component_enable = true
343 } else {
344   security_component_enable = false
345 }
346 
347 if (security_component_enable) {
348   input_default_defines += [ "OHOS_BUILD_ENABLE_SECURITY_COMPONENT" ]
349 }
350 
351 if (input_ext_feature_fingersense) {
352   input_default_defines += [ "OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER" ]
353 }
354 
355 if (input_ext_feature_gesturesense) {
356   input_default_defines += [ "OHOS_BUILD_ENABLE_GESTURESENSE_WRAPPER" ]
357 }
358 
359 if (input_ext_feature_anco) {
360   mmi_ext_path = "//vendor/huawei/foundation/multimodalinput/input_ext"
361   input_default_defines += [ "OHOS_BUILD_ENABLE_ANCO" ]
362   libmmi_client_sources +=
363       [ "${mmi_ext_path}/anco_uds_manager/src/input_manager_ext.cpp" ]
364 
365   libmmi_service_sources += [
366     "${mmi_ext_path}/anco_uds_manager/src/anco_uds_manager.cpp",
367     "${mmi_ext_path}/anco_uds_manager/src/input_windows_manager_ext.cpp",
368     "${mmi_ext_path}/anco_uds_manager/src/mmi_service_ext.cpp",
369   ]
370 
371   if (input_feature_product == "__other") {
372     libmmi_service_sources += [ "${mmi_path}/service/infrared_emitter/src/infrared_emitter_controller.cpp" ]
373   }
374 }
375 
376 if (input_feature_product == "pc") {
377   input_default_defines += [ "OHOS_BUILD_ENABLE_HARDWARE_CURSOR" ]
378 }
379 
380 if (input_ext_feature_magiccursor) {
381   mmi_ext_path = "//vendor/huawei/foundation/multimodalinput/input_ext"
382   g2d_ext_path = "//foundation/graphic/graphic_2d_ext"
383   g2d_path = "//foundation/graphic/graphic_2d"
384   surface_path = "//foundation/graphic/graphic_surface"
385   input_default_defines += [ "OHOS_BUILD_ENABLE_MAGICCURSOR" ]
386   libmmi_service_sources += [
387     "${mmi_ext_path}/magic_cursor/src/dfx_hisysevent_ext.cpp",
388     "${mmi_ext_path}/magic_cursor/src/lru_cache.cpp",
389     "${mmi_ext_path}/magic_cursor/src/magic_pointer_drawing_manager.cpp",
390     "${mmi_ext_path}/magic_cursor/src/magic_pointer_drawing_manager_ext.cpp",
391     "${mmi_ext_path}/magic_cursor/src/magic_pointer_velocity_tracker.cpp",
392     "${mmi_ext_path}/magic_cursor/src/render_context_gl.cpp",
393   ]
394 }
395 
396 if (defined(global_parts_info.multimedia_player_framework)) {
397   enable_player_framework = true
398   input_default_defines += [ "PLAYER_FRAMEWORK_EXISTS" ]
399 } else {
400   enable_player_framework = false
401 }
402 
403 if (enable_player_framework) {
404   libmmi_service_sources +=
405       [ "module_loader/src/input_screen_capture_monitor_listener.cpp" ]
406 }
407