ecore_wl2_input: add setting horizontal/vertical repeat rate and delay. 15/296415/5
authorHosang Kim <hosang12.kim@samsung.com>
Thu, 27 Jul 2023 06:55:17 +0000 (15:55 +0900)
committerkim hosang <hosang12.kim@samsung.com>
Thu, 27 Jul 2023 10:02:07 +0000 (10:02 +0000)
Change-Id: I1e24bc34e8faf07ebea654e070d87c1a5679648f

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h

index 039615f..cacd475 100644 (file)
@@ -2160,6 +2160,64 @@ EAPI Eina_Bool ecore_wl2_input_keyboard_repeat_set(Ecore_Wl2_Input *input, doubl
 /**
  * @internal
  *
+ * Get the keyboard repeat rate and delay of horizontal way
+ *
+ * @param input The input
+ * @param rate Pointer to store the repeat rate (in seconds)
+ * @param rate Pointer to store the repeat delay (in seconds)
+ *
+ * @return True if repeat is enabled
+ *
+ * @ingroup Ecore_Wl2_Input_Group
+ */
+EAPI Eina_Bool ecore_wl2_input_keyboard_horizontal_way_repeat_get(const Ecore_Wl2_Input *input, double *rate, double *delay);
+
+/**
+ * @internal
+ *
+ * Set the keyboard repeat rate and delay of horizontal way
+ * @param input The input
+ * @param rate Pointer to store the repeat rate (in seconds)
+ * @param rate Pointer to store the repeat delay (in seconds)
+ *
+ * @return True if repeat is enabled
+ *
+ * @ingroup Ecore_Wl2_Input_Group
+ */
+EAPI Eina_Bool ecore_wl2_input_keyboard_horizontal_way_repeat_set(Ecore_Wl2_Input *input, double rate, double delay);
+
+/**
+ * @internal
+ *
+ * Get the keyboard repeat rate and delay of vertical way
+ *
+ * @param input The input
+ * @param rate Pointer to store the repeat rate (in seconds)
+ * @param rate Pointer to store the repeat delay (in seconds)
+ *
+ * @return True if repeat is enabled
+ *
+ * @ingroup Ecore_Wl2_Input_Group
+ */
+EAPI Eina_Bool ecore_wl2_input_keyboard_vertical_way_repeat_get(const Ecore_Wl2_Input *input, double *rate, double *delay);
+
+/**
+ * @internal
+ *
+ * Set the keyboard repeat rate and delay of vertical way
+ * @param input The input
+ * @param rate Pointer to store the repeat rate (in seconds)
+ * @param rate Pointer to store the repeat delay (in seconds)
+ *
+ * @return True if repeat is enabled
+ *
+ * @ingroup Ecore_Wl2_Input_Group
+ */
+EAPI Eina_Bool ecore_wl2_input_keyboard_vertical_way_repeat_set(Ecore_Wl2_Input *input, double rate, double delay);
+
+/**
+ * @internal
+ *
  * Set a given wl_surface to use as the pointer on a seat
  *
  * @param input The seat to set this surface as the pointer on
index bd4b700..b0e875a 100644 (file)
@@ -1420,11 +1420,22 @@ _keyboard_cb_repeat(void *data)
              return ECORE_CALLBACK_RENEW;
           }
 
-        ecore_timer_interval_set(input->repeat.timer, input->repeat.rate);
+        if (input->repeat.key == 105 || input->repeat.key == 106 ) // Left:105 Right:106
+          ecore_timer_interval_set(input->repeat.timer, input->repeat.horizontal.rate);
+        else if (input->repeat.key == 103 || input->repeat.key == 108) { // UP:103 Down:108
+          ecore_timer_interval_set(input->repeat.timer, input->repeat.vertical.rate);
+        else
+          ecore_timer_interval_set(input->repeat.timer, input->repeat.rate);
+
         input->repeat.repeating = EINA_TRUE;
      }
 
-   input->repeat.time += (int)(input->repeat.rate * 1000.0);
+   if (input->repeat.key == 105 || input->repeat.key == 106 )
+     input->repeat.time += (int)(input->repeat.horizontal.rate * 1000.0);
+   else if (input->repeat.key == 103 || input->repeat.key == 108) {
+    input->repeat.time += (int)(input->repeat.vertical.rate * 1000.0);
+   else
+    input->repeat.time += (int)(input->repeat.rate * 1000.0);
 
    _ecore_wl2_input_key_send(input, input->repeat_win,
                              input->repeat.sym, input->repeat.sym_name,
@@ -1583,8 +1594,21 @@ _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned
              if (!input->repeat.timer)
                {
                   input->repeat.repeating = EINA_FALSE;
-                  input->repeat.timer = ecore_timer_add(input->repeat.delay, _keyboard_cb_repeat, input);
-                  input->repeat.intime = (ecore_time_get() + input->repeat.delay + 0.0166);
+                  if (keycode == 105 || keycode == 106 )
+                    {
+                       input->repeat.timer = ecore_timer_add(input->repeat.horizontal.delay, _keyboard_cb_repeat, input);
+                       input->repeat.intime = (ecore_time_get() + input->repeat.horizontal.delay + 0.0166);
+                    }
+                  else if (keycode == 103 || keycode == 108)
+                    {
+                       input->repeat.timer = ecore_timer_add(input->repeat.vertical.delay, _keyboard_cb_repeat, input);
+                       input->repeat.intime = (ecore_time_get() + input->repeat.vertical.delay + 0.0166);
+                    }
+                  else
+                    {
+                       input->repeat.timer = ecore_timer_add(input->repeat.delay, _keyboard_cb_repeat, input);
+                       input->repeat.intime = (ecore_time_get() + input->repeat.delay + 0.0166);
+                    }
                }
           }
      }
@@ -1660,8 +1684,8 @@ _keyboard_cb_repeat_setup(void *data, struct wl_keyboard *keyboard EINA_UNUSED,
         //TIZEN_ONLY(20200128): Tizen calculates rate differently.
         //input->repeat.rate = (1.0 / rate);
         //
-        input->repeat.rate = (rate / 1000.0);
-        input->repeat.delay = (delay / 1000.0);
+        input->repeat.rate = input->repeat.horizontal.rate = input->repeat.vertical.rate = (rate / 1000.0);
+        input->repeat.delay = input->repeat.horizontal.delay = input->repeat.vertical.delay = (delay / 1000.0);
      }
    ev = malloc(sizeof(Ecore_Wl2_Event_Seat_Keymap_Changed));
    if (ev)
@@ -2408,8 +2432,8 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int v
    input->id = id;
    input->display = display;
    input->seat_version = version;
-   input->repeat.rate = 0.025;
-   input->repeat.delay = 0.4;
+   input->repeat.rate = input->repeat.horizontal.rate = input->repeat.vertical.rate = 0.025;
+   input->repeat.delay = input->repeat.horizontal.delay = input->repeat.vertical.delay = 0.4;
    input->repeat.enabled = EINA_TRUE;
    input->repeat.changed = EINA_FALSE;
 
@@ -3773,8 +3797,8 @@ ecore_wl2_input_keyboard_repeat_set(Ecore_Wl2_Input *input, double rate, double
    EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(input->wl.keyboard, EINA_FALSE);
-   input->repeat.rate = rate;
-   input->repeat.delay = delay;
+   input->repeat.rate = input->repeat.horizontal.rate = input->repeat.vertical.rate = rate;
+   input->repeat.delay = input->repeat.horizontal.delay = input->repeat.vertical.delay = delay;
    input->repeat.changed = EINA_TRUE;
    return input->repeat.enabled;
 }
@@ -3790,6 +3814,53 @@ ecore_wl2_input_keyboard_repeat_get(const Ecore_Wl2_Input *input, double *rate,
    return input->repeat.enabled;
 }
 
+EAPI Eina_Bool
+ecore_wl2_input_keyboard_horizontal_way_repeat_set(Ecore_Wl2_Input *input, double rate, double delay)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(input->wl.keyboard, EINA_FALSE);
+   input->repeat.horizontal.rate = rate;
+   input->repeat.horizontal.delay = delay;
+   input->repeat.changed = EINA_TRUE;
+   return input->repeat.enabled;
+}
+
+EAPI Eina_Bool
+ecore_wl2_input_keyboard_horizontal_way_repeat_get(const Ecore_Wl2_Input *input, double *rate, double *delay)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(input->wl.keyboard, EINA_FALSE);
+   if (rate) *rate = input->repeat.horizontal.rate;
+   if (delay) *delay = input->repeat.horizontal.delay;
+   return input->repeat.enabled;
+}
+
+
+EAPI Eina_Bool
+ecore_wl2_input_keyboard_vertical_way_repeat_set(Ecore_Wl2_Input *input, double rate, double delay)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(input->wl.keyboard, EINA_FALSE);
+   input->repeat.vertical.rate = rate;
+   input->repeat.vertical.delay = delay;
+   input->repeat.changed = EINA_TRUE;
+   return input->repeat.enabled;
+}
+
+EAPI Eina_Bool
+ecore_wl2_input_keyboard_vertical_way_repeat_get(const Ecore_Wl2_Input *input, double *rate, double *delay)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(input->wl.keyboard, EINA_FALSE);
+   if (rate) *rate = input->repeat.vertical.rate;
+   if (delay) *delay = input->repeat.vertical.delay;
+   return input->repeat.enabled;
+}
+
 // TIZEN_ONLY(20171207): add functions to set client's custom cursors
 static void
 _pointer_update_stop(Ecore_Wl2_Input *input)
index 7947e58..1407090 100644 (file)
@@ -762,6 +762,14 @@ struct _Ecore_Wl2_Input
         unsigned int sym, sym_name, key, time;
         double rate, delay;
         double intime; //next repeat is expected in the time. (+ 0.0166 for 1 frame variable capacity)
+        struct
+        {
+           double rate, delay;
+        } horizontal;
+        struct
+        {
+           double rate, delay;
+        } vertical;
         Eina_Bool enabled : 1;
         Eina_Bool repeating : 1;
         Eina_Bool changed : 1;