/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Runtime.InteropServices; namespace ElmSharp { /// /// The EvasKeyEventArgs is an EvasKey EventArgs /// public class EvasKeyEventArgs : EventArgs { IntPtr _nativeEventInfo; EvasEventFlag _eventFlags; /// /// BackButton name in Platform /// public const string PlatformBackButtonName = "XF86Back"; /// /// MenuButton name in Platform /// public const string PlatformMenuButtonName = "XF86Menu"; /// /// HomeButton name in Platform /// public const string PlatformHomeButtonName = "XF86Home"; /// /// Gets the name of Key /// public string KeyName { get; private set; } public EvasEventFlag Flags { get { IntPtr offset = Marshal.OffsetOf("event_flags"); return (EvasEventFlag)Marshal.ReadIntPtr(_nativeEventInfo, (int)offset); } set { IntPtr offset = Marshal.OffsetOf("event_flags"); Marshal.WriteIntPtr(_nativeEventInfo, (int)offset, (IntPtr)value); } } EvasKeyEventArgs(IntPtr info) { _nativeEventInfo = info; var evt = Marshal.PtrToStructure(info); KeyName = evt.keyname; } /// /// Creates and initializes a new instance of the EvasKeyEventArgs class. /// /// data info /// object /// information /// EvasKey eventArgs static public EvasKeyEventArgs Create(IntPtr data, IntPtr obj, IntPtr info) { return new EvasKeyEventArgs(info); } /// /// Event structure for Key Down event callbacks. /// [StructLayout(LayoutKind.Sequential)] struct EvasEventKeyDown { /// /// Name string of the key pressed /// public string keyname; /// /// Data to be passed to the event /// public IntPtr data; /// /// Modifier keys pressed during the event /// public IntPtr modifiers; /// /// Locks info /// public IntPtr locks; /// /// Logical key: (example, shift+1 == exclamation) /// public string key; /// /// UTF8 string if this keystroke has produced a visible string to be ADDED /// public string str; /// /// UTF8 string if this keystroke has modified a string in the middle of being composed - this string replaces the previous one /// public string compose; public uint timestamp; /// /// Event_flags /// public EvasEventFlag event_flags; /// /// /// public IntPtr dev; /// /// Keycode /// public uint keycode; }; } /// /// Flags for Events /// [Flags] public enum EvasEventFlag { /// /// No fancy flags set /// None = 0, /// ///This event is being delivered but should be put "on hold" until the on hold flag is unset. the event should be used for informational purposes and maybe some indications visually, but not actually perform anything /// OnHold = 1, } }