Add new interface to receive information about the clicked key 33/262133/1
authorInHong Han <inhong1.han@samsung.com>
Mon, 24 May 2021 11:01:38 +0000 (20:01 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 3 Aug 2021 05:14:32 +0000 (14:14 +0900)
Change-Id: Ief14b78089226c7337745aeff6008056e6fb8182

ISEDefaultNUI/Interop/Interop.SclNui.cs
ISEDefaultNUI/SCLNUI.cs

index f10e9a7..036fca5 100644 (file)
@@ -34,8 +34,8 @@ namespace NUITemplate1.Interop
 
 using System;
 using System.Runtime.InteropServices;
-//using Samsung.Tizen.AI.Nmt;
 using Tizen;
+using Tizen.Internals;
 
 internal static partial class Interop
 {
@@ -58,6 +58,103 @@ internal static partial class Interop
 
         internal static string LogTag = "SclNuiCSharp";
 
+        internal enum SclNuiKeyType
+        {
+            None = 0,      /**< none */
+            Char,          /**< key that can be displayed independently */
+            Control,       /**< key to use as control */
+            Modechange,    /**< key to change mode*/
+            String,        /**< key to be displayed as string */
+            User,          /**< key to be processed by user custom function */
+            Max            /* maximum number of Key type */
+        }
+
+        internal enum SclNuiEventType
+        {
+            None = 0,      /**< none */
+            Press,         /**< button press event */
+            Move,          /**< button move event */
+            Release,      /**< button release event */
+            Longpress,    /**< button longpress event */
+            Repeat,        /**< button repeat event */
+            Max            /* maximum number of Event type */
+        }
+
+        internal enum SclNuiKeyModifier
+        {
+            None = 0,                   /**< none */
+            LongKey,                    /**< longkey event */
+            MultitapStart,              /**< multitap started */
+            MultitapRepeat,             /**< multitap repeated */
+            MultitapRelease,            /**< multitap released */
+
+            DirectionLeft,              /**< drag left */
+            DirectionRight,             /**< drag right */
+            DirectionUp,                /**< drag up */
+            DirectionDown,              /**< drag down */
+            DirectionUpLeft,            /**< drag up left */
+            DirectionUpRight,           /**< drag up right */
+            DirectionDownLeft,          /**< drag down left */
+            DirectionDownRight,         /**< drag down right */
+
+            DirectionLeftLong,          /**< drag left */
+            DirectionRightLong,         /**< drag right */
+            DirectionUpLong,            /**< drag up */
+            DirectionDownLong,          /**< drag down */
+            DirectionUpLeftLong,        /**< drag up left */
+            DirectionUpRightLong,       /**< drag up right */
+            DirectionDownLeftLong,      /**< drag down left */
+            DirectionDownRightLong,     /**< drag down right */
+
+            DirectionLeftReturn,        /**< drag left */
+            DirectionRightReturn,       /**< drag right */
+            DirectionUpReturn,          /**< drag up */
+            DirectionDownReturn,        /**< drag down */
+            DirectionUpLeftReturn,      /**< drag up left */
+            DirectionUpRightReturn,     /**< drag up right */
+            DirectionDownLeftReturn,    /**< drag down left */
+            DirectionDownRightReturn,   /**< drag down right */
+
+            DirectionCurveUpLeft,       /**< drag up left */
+            DirectionCurveUpRight,      /**< drag up right */
+            DirectionCurveDownLeft,     /**< drag down left */
+            DirectionCurveDownRight,    /**< drag down right */
+            DirectionCurveLeftUp,       /**< drag left up */
+            DirectionCurveLeftDown,     /**< drag left down */
+            DirectionCurveRightUp,      /**< drag right up */
+            DirectionCurveRightDown,    /**< drag right down */
+
+            Toggled,                    /**< toggled state */
+            Max                         /**< maximum number of Key type */
+        }
+
+        internal enum SclNuiEventReturnType
+        {
+            PassOn = 0,    /* This event needs further handling of default SCL event handler */
+            Done           /* We're done with this event, do not call any other default SCL event handlers */
+        }
+
+        internal struct Point
+        {
+            internal int x;
+            internal int y;
+        }
+
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+        internal struct SclNuiEventDesc
+        {
+            internal string keyValue;
+            internal ulong keyEvent;
+            internal SclNuiKeyType keyType;
+            internal SclNuiKeyModifier keyModifier;
+            internal int touchID;
+            internal int touchEventOrder;
+            internal Point MousePressedPoint;
+            internal Point MouseCurrentPoint;
+            internal Point MouseFarhestPoint;
+            internal SclNuiEventType eventType;
+        }
+
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         //internal delegate void DrawTextCallback(IntPtr str, int x, int y, int w, int h, int fontsize, IntPtr userData);
         //internal delegate void DrawTextCallback(SclFontInfo fontinfo, SclColor color, IntPtr str, int x, int y, int w, int h, int label_alignment, int padding_x, int padding_y, int inner_width, int inner_height, IntPtr userData);
@@ -76,6 +173,9 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void UpdateWindowCallback(int x, int y, int width, int height, IntPtr user_data);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate int KeyClickEventCallback(IntPtr eventDesc);
+
         [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_init")]
         internal static extern int SclNuiInit(string entry_filepath);
 
@@ -114,5 +214,8 @@ internal static partial class Interop
 
         [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_update_window_cb")]
         internal static extern int SclNuiUpdateWindowCb(UpdateWindowCallback callbackFunction, IntPtr userData);
+
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_key_click_event_cb")]
+        internal static extern int SclNuiKeyClickEventCb(KeyClickEventCallback callbackFunction);
     }
 }
index fd9fd43..c3c7a2d 100644 (file)
@@ -18,6 +18,7 @@ namespace ISEDefaultNUI
         private DrawImageCallback _draw_image_cb = null;
         private DrawRectangleCallback _draw_rectangle_cb = null;
         private UpdateWindowCallback _update_window_cb = null;
+        private KeyClickEventCallback _onKeyClickEvent = null;
 
         private List<ImageView> image_list;
         private List<TextLabel> label_list;
@@ -115,6 +116,25 @@ namespace ISEDefaultNUI
             };
             SclNuiUpdateWindowCb(_update_window_cb, (IntPtr)null);
 
+            _onKeyClickEvent = (IntPtr eventDesc) =>
+            {
+                IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(eventDesc));
+                Marshal.StructureToPtr(eventDesc, pnt, false);
+                SclNuiEventDesc eventInfo;
+                eventInfo = (SclNuiEventDesc)Marshal.PtrToStructure(pnt, typeof(SclNuiEventDesc));
+
+                if (eventInfo.keyValue.Equals("OPTION"))
+                {
+                    navigator.Pop();
+                    KeyboardSettingPage keyboardSettingPage = new KeyboardSettingPage(navigator);
+                    navigator.Push(keyboardSettingPage);
+                }
+
+                Marshal.FreeHGlobal(pnt);
+                return (int)SclNuiEventReturnType.PassOn;
+            };
+            SclNuiKeyClickEventCb(_onKeyClickEvent);
+
             Window.Instance.TouchEvent += OnWindowTouched;
 
             BackKeyPressed += (object source, EventArgs args) =>
@@ -338,12 +358,6 @@ namespace ISEDefaultNUI
                         Log.Info("NUIIME", "[MOUSE UP] x=" + e.Touch.GetScreenPosition(0).X + ", y=" + e.Touch.GetScreenPosition(0).Y);
                         SclControllerMouseRelease((int)e.Touch.GetScreenPosition(0).X, (int)e.Touch.GetScreenPosition(0).Y);
                         //mTouched = false;
-
-
-                        navigator.Pop();
-                        KeyboardSettingPage keyboardSettingPage = new KeyboardSettingPage(navigator);
-                        navigator.Push(keyboardSettingPage);
-
                         break;
                     }
             }