2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /// Enumeration of device type generated events.
24 /// <since_tizen> preview </since_tizen>
25 public enum InputDeviceType
28 /// Touch Screen device.
30 TouchScreen = (1 << 0),
47 /// Enumeration of pointer event types.
49 /// <since_tizen> preview </since_tizen>
50 public enum InputPointerType
53 /// Mouse button press.
58 /// Mouse button release.
69 /// Enumeration of touch event types.
71 /// <since_tizen> preview </since_tizen>
72 public enum InputTouchType
75 /// Finger press. It is same a behavior put your finger on touch screen.
80 /// Finger move. It is same a behavior move your finger on touch screen.
85 /// Finger release. It is same a behavior release your finger on touch screen.
91 /// InputGenerator provides functions to initialize/deinitialize input devices and to generation touch / key events.
94 /// http://tizen.org/privilege/inputgenerator
97 /// This is not for use by third-party applications.
99 /// <since_tizen> preview </since_tizen>
100 public class InputGenerator : IDisposable
102 IntPtr _handle = IntPtr.Zero;
103 bool _isDisposed = false;
106 /// Creates and initializes a new instance of the InputGenerator class.
108 /// <param name="deviceType">The device type want to generate events</param>
109 /// <since_tizen> preview </since_tizen>
110 public InputGenerator(InputDeviceType deviceType)
112 _handle = Interop.Eutil.efl_util_input_initialize_generator((int)deviceType);
116 /// Creates and initializes a new instance of the InputGenerator class with given name.
118 /// <param name="deviceType">The device type want to generate events</param>
119 /// <param name="name">The device name (maximum 31 characters)</param>
120 /// <since_tizen> preview </since_tizen>
121 public InputGenerator(InputDeviceType deviceType, string name)
123 _handle = Interop.Eutil.efl_util_input_initialize_generator_with_name((int)deviceType, name);
127 /// Destroys the InputGenerator object.
135 /// Destroys the current object.
137 /// <since_tizen> preview </since_tizen>
138 public void Dispose()
141 GC.SuppressFinalize(this);
145 /// Releases all the resources currently used by this instance.
147 /// <param name="disposing">
148 /// true if the managed resources should be disposed,
151 /// <since_tizen> preview </since_tizen>
152 protected virtual void Dispose(bool disposing)
159 Interop.Eutil.efl_util_input_deinitialize_generator(_handle);
166 /// Generates all of key events using a opened device.
168 /// <param name="key">The key name want to generate.</param>
169 /// <param name="pressed">The value that select key press or release. (0: release, 1: press)</param>
170 /// <since_tizen> preview </since_tizen>
171 public void GenerateKeyEvent(string key, int pressed)
173 Interop.Eutil.efl_util_input_generate_key(_handle, key, pressed);
177 /// Generate a pointer event using a opened device
179 /// <param name="buttons">The number of button.</param>
180 /// <param name="type">The pointer type.</param>
181 /// <param name="x">x coordination to move.</param>
182 /// <param name="y">y coordination to move.</param>
183 /// <since_tizen> preview </since_tizen>
184 public void GenerateMouseEvent(int buttons, InputPointerType type, int x, int y)
186 Interop.Eutil.efl_util_input_generate_pointer(_handle, buttons, (int)type, x, y);
190 /// Generate a touch event using a opened device
192 /// <param name="index">The index of touched finger.</param>
193 /// <param name="type">The touch type.</param>
194 /// <param name="x">The x axis of touch point.</param>
195 /// <param name="y">The y axis of touch point.</param>
196 /// <since_tizen> preview </since_tizen>
197 public void GenerateTouchEvent(int index, InputTouchType type, int x, int y)
199 Interop.Eutil.efl_util_input_generate_touch(_handle, index, (int)type, x, y);