e_info: add -input_subtype_set option in winfo (enlightenment_info) accepted/tizen/unified/20230823.173942
authorduna.oh <duna.oh@samsung.com>
Tue, 22 Aug 2023 07:50:25 +0000 (16:50 +0900)
committerJunseok Kim <juns.kim@samsung.com>
Wed, 23 Aug 2023 04:31:01 +0000 (13:31 +0900)
Change-Id: I317425d70321bcc16e42f4246c98c64319ded770
Param: [input(ex./dev/input/eventX) subtype(ex.Remocon/None)]

src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_input.h
src/bin/e_input_device.c

index 6056648e08fc045292119369f0302fc42ac07355..6a03b3d025a4a5bacc0e13c45949b268646524d6 100644 (file)
@@ -6708,6 +6708,47 @@ _e_info_client_property_set(int argc, char **argv)
      }
 }
 
+static void
+_e_info_client_cb_input_subtype_set(const Eldbus_Message *msg)
+{
+   const char *errname = NULL, *errtext = NULL;
+   char *result = NULL;
+
+   EINA_SAFETY_ON_TRUE_GOTO(eldbus_message_error_get(msg, &errname, &errtext), err);
+
+   EINA_SAFETY_ON_FALSE_GOTO(eldbus_message_arguments_get(msg, "s", &result), err);
+
+   if (strncmp(result, E_INFO_INPUT_RESULT_NONE, sizeof(E_INFO_INPUT_RESULT_NONE)))
+     printf("Input_Subtype_Set Failed: %s\n", result);
+   else
+     printf("Input_Subtype_Set Success\n");
+
+   return;
+
+err:
+   if(errname || errtext)
+     printf("errname : %s, errmsg : %s\n", errname, errtext);
+   else
+     printf("Error occurred in _e_info_client_cb_input_subtype_set\n");
+}
+
+static void
+_e_info_client_proc_input_subtype_set(int argc, char **argv)
+{
+   if (argc < 4)
+     {
+        printf("Error Check Args: -input_subtype_set [input(ex./dev/input/eventX)] [subtype(ex.None/Remocon)]\n");
+        return;
+     }
+
+   if (!_e_info_client_eldbus_message_with_args("input_subtype_set", _e_info_client_cb_input_subtype_set, "ss",
+                                                argv[2], argv[3]))
+     {
+        printf("_e_info_client_eldbus_message_with_args error");
+        return;
+     }
+}
+
 typedef struct _ProcInfo
 {
    const char *option;
@@ -7170,6 +7211,12 @@ ProcInfo procs_to_input[] =
       "Set use_cursor_timer enable/disable", /* Description */
       _e_info_client_proc_use_cursor_timer /* func */
    },
+   {
+      "input_subtype_set",
+      "[input(ex./dev/input/eventX) subtype(ex.None/Remocon)]",
+      "Set input device's subtype(subclas)",
+      _e_info_client_proc_input_subtype_set
+   },
 };
 
 static Eina_List *list_tracelogs = NULL;
index 98c67186883b2f4e8cdfc4d28b0308c470e0c5ab..f8c052736918aed75d938ff82734402af5ce02d8 100644 (file)
@@ -7598,6 +7598,36 @@ _e_info_server_cb_prop_set(const Eldbus_Service_Interface *iface EINA_UNUSED, co
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_input_subtype_set(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *input_name = NULL, *subtype_name = NULL;
+   char *result = NULL;
+   Eina_Bool res = EINA_FALSE;
+
+   if (!eldbus_message_arguments_get(msg, "ss", &input_name, &subtype_name))
+     {
+        return eldbus_message_error_new(msg, "Input_subtype_setFailed",
+                                        "input_subtype_set: an attempt to set device's subtype from method call message failed");;
+     }
+
+   res = e_input_device_subtype_set(NULL, input_name, subtype_name);
+   if (res)
+     {
+        INF("Succeeded to set input device(%s)'s subtype(%s)", input_name, subtype_name);
+        result = E_INFO_INPUT_RESULT_NONE;
+     }
+   else
+     {
+        ERR("Failed to set input device(%s)'s subtype(%s)", input_name, subtype_name);
+        result = "Failed to set subtype";
+     }
+   eldbus_message_arguments_append(reply, "s", result);
+
+   return reply;
+}
+
 //{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
@@ -7703,6 +7733,7 @@ static const Eldbus_Method methods[] = {
    { "input_seat_set", ELDBUS_ARGS({"ss", "set input device's seat"}), NULL, _e_info_server_cb_input_seat_set, 0 },
    { "resize_ppu_set", ELDBUS_ARGS({"si", "set resize ppu"}), NULL, e_info_server_cb_resize_ppu_set, 0},
    { "prop_set", ELDBUS_ARGS({"s","window id" }, {"s", "property"}, {"i", "set value"}), NULL, _e_info_server_cb_prop_set, 0},
+   { "input_subtype_set", ELDBUS_ARGS({"ss", "set input device's subtype(subclas)"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_input_subtype_set, 0 },
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index c6717359fd81973e2db9c2f249c4aaae1b6eb577..beffdcb823a30e9dfed4acea98f2c5daae13ddfb 100644 (file)
@@ -157,5 +157,7 @@ EINTERN void e_input_create_event_source(E_Input_Backend *input);
 EINTERN Eina_Bool e_input_relative_motion_handler_set(e_input_relative_motion_cb handler);
 EINTERN e_input_relative_motion_cb e_input_relative_motion_handler_get(void);
 
+EINTERN Eina_Bool e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *subtype);
+
 #endif
 #endif
index 3e813e2b128d922d3151a0627d1410fb803e5cd0..88296a45f10ca13fcc417d56abe10b6882301bc5 100644 (file)
@@ -1488,3 +1488,85 @@ e_input_device_seat_name_set(E_Input_Device *dev, const char *input, const char
 
    return EINA_FALSE;
 }
+
+EINTERN Eina_Bool
+e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *subtype_name)
+{
+   Ecore_Device *ecore_dev = NULL;
+   E_Device *e_dev = NULL;
+   Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
+
+   if (!dev)
+     dev = _e_input_device_default_get();
+
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(!dev, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(!input, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(!subtype_name, EINA_FALSE);
+
+   //TODO : find device other than keyboard type.
+   //right now, subclas is only used with keyboard type.
+   if (!e_input_thread_mode_get())
+     {
+        ecore_dev = e_input_evdev_get_ecore_device(input, ECORE_DEVICE_CLASS_KEYBOARD);
+        if (!ecore_dev)
+          {
+             ERR("Failed to find input device: %s", input);
+             return EINA_FALSE;
+          }
+
+        device_subclas = ecore_device_subclass_get(ecore_dev);
+
+        if (!e_util_strcmp(subtype_name, "Remocon") &&
+            device_subclas != ECORE_DEVICE_SUBCLASS_REMOCON)
+          {
+             ecore_device_subclass_set(ecore_dev, ECORE_DEVICE_SUBCLASS_REMOCON);
+             INF("device(%s) subtype is changed to Remocon(%d->%d)", input,
+                 device_subclas, ECORE_DEVICE_SUBCLASS_REMOCON);
+          }
+        else if (!e_util_strcmp(subtype_name, "None") &&
+                 device_subclas != ECORE_DEVICE_SUBCLASS_NONE)
+          {
+             ecore_device_subclass_set(ecore_dev, ECORE_DEVICE_SUBCLASS_NONE);
+             INF("device(%s) subtype is changed to None(%d->%d)", input,
+                 device_subclas, ECORE_DEVICE_SUBCLASS_NONE);
+          }
+        else
+          {
+             ERR("Failed to set new subtype: %s (current:%d)", subtype_name, device_subclas);
+             return EINA_FALSE;
+          }
+     }
+   else
+     {
+        e_dev = e_input_evdev_get_e_device(input, ECORE_DEVICE_CLASS_KEYBOARD);
+        if (!e_dev)
+          {
+             ERR("Failed to find input device: %s", input);
+             return EINA_FALSE;
+          }
+
+        device_subclas = e_device_subclass_get(e_dev);
+
+        if (!e_util_strcmp(subtype_name, "Remocon") &&
+            device_subclas != ECORE_DEVICE_SUBCLASS_REMOCON)
+          {
+             e_device_subclass_set(e_dev, ECORE_DEVICE_SUBCLASS_REMOCON);
+             INF("device(%s) subtype is changed to Remocon(%d->%d)", input,
+                 device_subclas, ECORE_DEVICE_SUBCLASS_REMOCON);
+          }
+        else if (!e_util_strcmp(subtype_name, "None") &&
+                 device_subclas != ECORE_DEVICE_SUBCLASS_NONE)
+          {
+             e_device_subclass_set(e_dev, ECORE_DEVICE_SUBCLASS_NONE);
+             INF("device(%s) subtype is changed to None(%d->%d)", input,
+                 device_subclas, ECORE_DEVICE_SUBCLASS_NONE);
+          }
+        else
+          {
+             ERR("Failed to set new subtype: %s (current:%d)", subtype_name, device_subclas);
+             return EINA_FALSE;
+          }
+     }
+
+   return EINA_TRUE;
+}