86bd10ffe3dd5bee6531a4c5029fa63842c12498
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / InputGenerator.cs
1 /*
2  * Copyright (c) 2016 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 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// Enumeration of device type generated events.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     [Obsolete("This has been deprecated in API12")]
26     public enum InputDeviceType
27     {
28         /// <summary>
29         /// Touch Screen device.
30         /// </summary>
31         TouchScreen = (1 << 0),
32
33         /// <summary>
34         /// Keyboard device.
35         /// </summary>
36         Keyboard = (1 << 1),
37
38         /// <summary>
39         /// Mouse Device.
40         /// </summary>
41         /// <remarks>
42         /// Since 3.0.
43         /// </remarks>
44         Pointer = (1 << 2),
45     }
46
47     /// <summary>
48     /// Enumeration of pointer event types.
49     /// </summary>
50     /// <since_tizen> preview </since_tizen>
51     [Obsolete("This has been deprecated in API12")]
52     public enum InputPointerType
53     {
54         /// <summary>
55         /// Mouse button press.
56         /// </summary>
57         MouseDown,
58
59         /// <summary>
60         /// Mouse button release.
61         /// </summary>
62         MouseUp,
63
64         /// <summary>
65         /// Mouse move
66         /// </summary>
67         Move,
68     }
69
70     /// <summary>
71     /// Enumeration of touch event types.
72     /// </summary>
73     /// <since_tizen> preview </since_tizen>
74     [Obsolete("This has been deprecated in API12")]
75     public enum InputTouchType
76     {
77         /// <summary>
78         /// Finger press. It is same a behavior put your finger on touch screen.
79         /// </summary>
80         Begin = 1,
81
82         /// <summary>
83         /// Finger move. It is same a behavior move your finger on touch screen.
84         /// </summary>
85         Update,
86
87         /// <summary>
88         /// Finger release. It is same a behavior release your finger on touch screen.
89         /// </summary>
90         End,
91     }
92
93     /// <summary>
94     /// InputGenerator provides functions to initialize/deinitialize input devices and to generation touch / key events.
95     /// </summary>
96     /// <privilege>
97     /// http://tizen.org/privilege/inputgenerator
98     /// </privilege>
99     /// <remarks>
100     /// This is not for use by third-party applications.
101     /// </remarks>
102     /// <since_tizen> preview </since_tizen>
103     [Obsolete("This has been deprecated in API12")]
104     public class InputGenerator : IDisposable
105     {
106         IntPtr _handle = IntPtr.Zero;
107         bool _isDisposed = false;
108
109         /// <summary>
110         /// Creates and initializes a new instance of the InputGenerator class.
111         /// </summary>
112         /// <param name="deviceType">The device type want to generate events</param>
113         /// <since_tizen> preview </since_tizen>
114         [Obsolete("This has been deprecated in API12")]
115         public InputGenerator(InputDeviceType deviceType)
116         {
117             _handle = Interop.Eutil.efl_util_input_initialize_generator((int)deviceType);
118         }
119
120         /// <summary>
121         /// Creates and initializes a new instance of the InputGenerator class with given name.
122         /// </summary>
123         /// <param name="deviceType">The device type want to generate events</param>
124         /// <param name="name">The device name (maximum 31 characters)</param>
125         /// <since_tizen> preview </since_tizen>
126         [Obsolete("This has been deprecated in API12")]
127         public InputGenerator(InputDeviceType deviceType, string name)
128         {
129             _handle = Interop.Eutil.efl_util_input_initialize_generator_with_name((int)deviceType, name);
130         }
131
132         /// <summary>
133         /// Destroys the InputGenerator object.
134         /// </summary>
135         ~InputGenerator()
136         {
137             Dispose(false);
138         }
139
140         /// <summary>
141         /// Destroys the current object.
142         /// </summary>
143         /// <since_tizen> preview </since_tizen>
144         [Obsolete("This has been deprecated in API12")]
145         public void Dispose()
146         {
147             Dispose(true);
148             GC.SuppressFinalize(this);
149         }
150
151         /// <summary>
152         /// Releases all the resources currently used by this instance.
153         /// </summary>
154         /// <param name="disposing">
155         /// true if the managed resources should be disposed,
156         /// otherwise false.
157         /// </param>
158         /// <since_tizen> preview </since_tizen>
159         [Obsolete("This has been deprecated in API12")]
160         protected virtual void Dispose(bool disposing)
161         {
162             if (_isDisposed)
163                 return;
164
165             if (disposing)
166             {
167                 Interop.Eutil.efl_util_input_deinitialize_generator(_handle);
168             }
169
170             _isDisposed = true;
171         }
172
173         /// <summary>
174         /// Generates all of key events using a opened device.
175         /// </summary>
176         /// <param name="key">The key name want to generate.</param>
177         /// <param name="pressed">The value that select key press or release. (0: release, 1: press)</param>
178         /// <since_tizen> preview </since_tizen>
179         [Obsolete("This has been deprecated in API12")]
180         public void GenerateKeyEvent(string key, int pressed)
181         {
182             Interop.Eutil.efl_util_input_generate_key(_handle, key, pressed);
183         }
184
185         /// <summary>
186         /// Generate a pointer event using a opened device
187         /// </summary>
188         /// <param name="buttons">The number of button.</param>
189         /// <param name="type">The pointer type.</param>
190         /// <param name="x">x coordination to move.</param>
191         /// <param name="y">y coordination to move.</param>
192         /// <since_tizen> preview </since_tizen>
193         [Obsolete("This has been deprecated in API12")]
194         public void GenerateMouseEvent(int buttons, InputPointerType type, int x, int y)
195         {
196             Interop.Eutil.efl_util_input_generate_pointer(_handle, buttons, (int)type, x, y);
197         }
198
199         /// <summary>
200         /// Generate a touch event using a opened device
201         /// </summary>
202         /// <param name="index">The index of touched finger.</param>
203         /// <param name="type">The touch type.</param>
204         /// <param name="x">The x axis of touch point.</param>
205         /// <param name="y">The y axis of touch point.</param>
206         /// <since_tizen> preview </since_tizen>
207         [Obsolete("This has been deprecated in API12")]
208         public void GenerateTouchEvent(int index, InputTouchType type, int x, int y)
209         {
210             Interop.Eutil.efl_util_input_generate_touch(_handle, index, (int)type, x, y);
211         }
212     }
213 }