880d068673df27eb3dbc332345855f53f3c25e6e
[platform/core/uifw/mmi-manager.git] / src / mmimgr / output_modality / mmi_output_modality.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *               http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  */
17
18
19 #include <string>
20
21 #include "mmi-common.h"
22 #include "TouchModule.h"
23 #include "mmi-manager-dbg.h"
24 #include "mmi_output_modality.h"
25
26 static TouchModule *g_touch_module = nullptr;
27
28 EXPORT_API void output_modality_initialize()
29 {
30         LOGD("initialize output modality");
31         g_touch_module = new TouchModule();
32 }
33
34 EXPORT_API void output_modality_shutdown()
35 {
36         LOGD("shutdown output modality");
37         if (g_touch_module) {
38                 delete g_touch_module;
39                 g_touch_module = NULL;
40         }
41 }
42
43 EXPORT_API int output_modality_voice_touch(mmi_output_modality_voice_touch modality)
44 {
45         mmi_voice_touch_mode mode = (mmi_voice_touch_mode)modality.mode;
46         int ret = 0;
47
48         if (MMI_VOICE_TOUCH_MODE_TOOLTIP == mode) {
49                 LOGD("voice touch by tooltip");
50                 std::string objID = std::string(modality.object_id, strlen(modality.object_id));
51                 ret = g_touch_module->ClickByObjectId(objID);
52         } else if (MMI_VOICE_TOUCH_MODE_GRID == mode) {
53                 LOGD("voice touch by grid");
54                 ret = g_touch_module->ClickByCoordinate(modality.coord_x, modality.coord_y);
55         } else {
56                 return 0;
57         }
58         LOGD("voice touch done");
59
60         return ret;
61 }