From 37610617b8dc6dffd2b6a00c68465c200603aa86 Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Wed, 13 Sep 2023 17:57:13 +0900 Subject: [PATCH] e_input: add E_API e_input_device_mouse_accel_enable_set(device_name, enable) use this API to enable/disable acceleration state on each devices Change-Id: I055244d868ec946e6998435179917c2b4048d23c --- src/bin/e_info_client.c | 2 ++ src/bin/e_info_server_input.c | 26 +++----------------------- src/bin/e_input.h | 3 ++- src/bin/e_input_device.c | 38 ++++++++++++++++++++++++++++++++++++++ src/bin/e_input_evdev.c | 9 --------- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/bin/e_info_client.c b/src/bin/e_info_client.c index 25b06fa..eec593b 100644 --- a/src/bin/e_info_client.c +++ b/src/bin/e_info_client.c @@ -6265,6 +6265,8 @@ _e_info_client_cb_mouse_accel(const Eldbus_Message *msg) if (strncmp(result, E_INFO_INPUT_RESULT_NONE, sizeof(E_INFO_INPUT_RESULT_NONE))) printf("Mouse_accel Failed: %s\n", result); + else + printf("Mouse_accel Success\n"); return; diff --git a/src/bin/e_info_server_input.c b/src/bin/e_info_server_input.c index a0d7ec6..08aef5f 100644 --- a/src/bin/e_info_server_input.c +++ b/src/bin/e_info_server_input.c @@ -574,32 +574,12 @@ e_info_server_input_mousegen(int button, int x, int y, int state) char * e_info_server_input_mouse_accel_set(int state) { - const Eina_List *l, *ll, *lll; - E_Input_Device *dev; - E_Input_Seat *seat; - E_Input_Evdev *edev; - if (_e_info_input.gen.fd < 0) return "Initialize device first"; - EINA_LIST_FOREACH(e_input_devices_get(), l, dev) - { - EINA_LIST_FOREACH(dev->seats, ll, seat) - { - EINA_LIST_FOREACH(seat->devices, lll, edev) - { - if (!e_util_strcmp(_e_info_input.gen.name, libinput_device_get_name(edev->device))) - { - if (state == 1) - e_input_evdev_mouse_accel_enable(edev, EINA_TRUE); - else - e_input_evdev_mouse_accel_enable(edev, EINA_FALSE); - break; - } - } - } - } + if (e_input_device_mouse_accel_enable_set(_e_info_input.gen.name, state)) + return E_INFO_INPUT_RESULT_NONE; - return E_INFO_INPUT_RESULT_NONE; + return "Failed to set mouse_accel"; } char * diff --git a/src/bin/e_input.h b/src/bin/e_input.h index 8249884..e1210a5 100644 --- a/src/bin/e_input.h +++ b/src/bin/e_input.h @@ -123,7 +123,6 @@ EINTERN Eina_Bool e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool EINTERN Eina_Bool e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num); EINTERN Eina_Bool e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6]); EINTERN Eina_Bool e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed); -EINTERN Eina_Bool e_input_evdev_mouse_accel_enable(E_Input_Evdev *edev, Eina_Bool enable); EINTERN unsigned int e_input_evdev_touch_pressed_get(E_Input_Evdev *edev); E_API const Eina_List *e_input_devices_get(void); @@ -164,5 +163,7 @@ EINTERN e_input_keyboard_grab_key_cb e_input_keyboard_grab_key_handler_get(void) EINTERN Eina_Bool e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *subtype); +E_API Eina_Bool e_input_device_mouse_accel_enable_set(const char *device_name, Eina_Bool enable); + #endif #endif diff --git a/src/bin/e_input_device.c b/src/bin/e_input_device.c index 88781c4..334fd33 100644 --- a/src/bin/e_input_device.c +++ b/src/bin/e_input_device.c @@ -1570,3 +1570,41 @@ e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *s return EINA_TRUE; } + +E_API Eina_Bool +e_input_device_mouse_accel_enable_set(const char *device_name, Eina_Bool enable) +{ + const Eina_List *l, *ll, *lll; + E_Input_Device *dev; + E_Input_Seat *seat; + E_Input_Evdev *edev; + Eina_Bool found = EINA_FALSE; + + EINA_SAFETY_ON_NULL_RETURN_VAL(device_name, EINA_FALSE); + + EINA_LIST_FOREACH(e_input_devices_get(), l, dev) + { + EINA_LIST_FOREACH(dev->seats, ll, seat) + { + EINA_LIST_FOREACH(seat->devices, lll, edev) + { + if ((edev->caps & E_INPUT_SEAT_POINTER) && + (!e_util_strcmp(device_name, libinput_device_get_name(edev->device)))) + { + found = EINA_TRUE; + edev->disable_acceleration = !enable; + } + } + } + } + + if (!found) + { + ERR("Failed to find input device. device(%s)", device_name); + return EINA_FALSE; + } + + INF("device(%s) mouse_accel is %s", device_name, enable ? "ON" : "OFF"); + + return EINA_TRUE; +} diff --git a/src/bin/e_input_evdev.c b/src/bin/e_input_evdev.c index 402a239..6e64f99 100644 --- a/src/bin/e_input_evdev.c +++ b/src/bin/e_input_evdev.c @@ -2597,12 +2597,3 @@ e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname) return res; } - -EINTERN Eina_Bool -e_input_evdev_mouse_accel_enable(E_Input_Evdev *edev, Eina_Bool enable) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE); - edev->disable_acceleration = !enable; - - return EINA_TRUE; -} -- 2.7.4