Support legacy way to create InputMethodContext
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / keyboard.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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 #include "common.h"
19
20 #include <dali/dali.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/devel-api/adaptor-framework/keyboard.h>
25
26 #include <stdexcept>
27 #include <exception>
28
29
30 #ifdef TIZEN_BUILD
31 #ifdef ECORE_WL2
32 #include <Ecore_Wl2.h>
33 #else
34 #include <Ecore_Wayland.h>
35 #endif
36 #endif
37
38 #undef LOG
39 //#define LOG DALI_LOG_ERROR
40 #define LOG(a...)
41
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Keyboard_SetRepeatInfo(float rate, float delay)
48 {
49   bool ret;
50
51   LOG("CSharp_Dali_Keyboard_SetRepeatInfo() [DP1] rate=%f, delay=%f", rate, delay);
52
53   {
54     try {
55       ret = Dali::Keyboard::SetRepeatInfo(rate, delay);
56     } catch (std::out_of_range& e) {
57     {
58       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
59     };
60     } catch (std::exception& e) {
61     {
62       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
63     };
64     } catch (Dali::DaliException e) {
65       {
66         SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
67       };
68     } catch (...) {
69       {
70         SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
71       };
72     }
73   }
74
75
76   LOG("CSharp_Dali_Keyboard_SetRepeatInfo() [DP2] ret=%d", ret);
77
78   return ret;
79 }
80
81 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Keyboard_GetRepeatInfo(float& rate, float& delay)
82 {
83   bool ret;
84
85   LOG("CSharp_Dali_Keyboard_GetRepeatInfo() [DP1] rate=%f, delay=%f", rate, delay);
86
87   {
88     try {
89       ret = Dali::Keyboard::GetRepeatInfo(rate, delay);
90     } catch (std::out_of_range& e) {
91     {
92       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
93     };
94     } catch (std::exception& e) {
95     {
96       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
97     };
98     } catch (Dali::DaliException e) {
99       {
100         SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
101       };
102     } catch (...) {
103       {
104         SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
105       };
106     }
107   }
108
109
110   LOG("CSharp_Dali_Keyboard_GetRepeatInfo() [DP2] ret=%d", ret);
111
112   return ret;
113 }
114
115
116 #ifdef __cplusplus
117 }
118 #endif
119