diff --git a/BUILD.gn b/BUILD.gn index 7c04741..9920e4b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,12 +1,14 @@ import("//build/ohos.gni") +gen_dst_dir = root_out_dir + "/diff_libevdev_mmi" + ## Build libevdev.so {{{ config("libevdev_config") { visibility = [ ":*" ] include_dirs = [ - "libevdev", - "include", + "$gen_dst_dir/libevdev", + "$gen_dst_dir/include", ] cflags = [ @@ -17,25 +19,44 @@ config("libevdev_config") { config("libevdev_public_config") { include_dirs = [ - "export_include", - "libevdev", + "$gen_dst_dir/export_include", + "$gen_dst_dir/libevdev", ] cflags = [] } -ohos_shared_library("libevdev") { +ohos_source_set("patch_gen_libevdev-third-mmi") { + part_name = "libevdev" + subsystem_name = "thirdparty" + sources = [ - "libevdev/libevdev-names.c", - "libevdev/libevdev-uinput.c", - "libevdev/libevdev.c", + root_out_dir + "/diff_libevdev_mmi/libevdev/libevdev-names.c", + root_out_dir + "/diff_libevdev_mmi/libevdev/libevdev-uinput.c", + root_out_dir + "/diff_libevdev_mmi/libevdev/libevdev.c", ] + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + configs = [ ":libevdev_config" ] + public_configs = [ ":libevdev_public_config" ] + + deps = [ "patch:apply_patch" ] +} + +ohos_shared_library("libevdev") { + sources = [] + configs = [ ":libevdev_config" ] public_configs = [ ":libevdev_public_config" ] - deps = [] + deps = [":patch_gen_libevdev-third-mmi"] public_deps = [] diff --git a/patch/apply_patch.sh b/patch/apply_patch.sh old mode 100644 new mode 100755 diff --git a/patch/diff_libevdev_mmi/libevdev/libevdev_0000.diff b/patch/diff_libevdev_mmi/libevdev/libevdev_0000.diff index 18ada4c..25f7bd3 100644 --- a/patch/diff_libevdev_mmi/libevdev/libevdev_0000.diff +++ b/patch/diff_libevdev_mmi/libevdev/libevdev_0000.diff @@ -1,4 +1,4 @@ -Copyright (C) 2024 Huawei Device Co., Ltd. +Copyright (C) 2025 Huawei Device Co., Ltd. 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\n @@ -10,54 +10,200 @@ 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. +--- a/include/linux/freebsd/input-event-codes.h ++++ b/include/linux/freebsd/input-event-codes.h +@@ -519,6 +519,7 @@ + #define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */ + #define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */ + #define KEY_HANGUP_PHONE 0x1be /* Decline incoming call */ ++#define KEY_LINK_PHONE 0x1bf /* AL Phone Syncing */ + + #define KEY_DEL_EOL 0x1c0 + #define KEY_DEL_EOS 0x1c1 +@@ -600,8 +601,14 @@ + #define BTN_DPAD_LEFT 0x222 + #define BTN_DPAD_RIGHT 0x223 + ++#define BTN_GRIPL 0x224 ++#define BTN_GRIPR 0x225 ++#define BTN_GRIPL2 0x226 ++#define BTN_GRIPR2 0x227 ++ + #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ + #define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ ++#define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */ + + #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ + #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ +@@ -617,6 +624,8 @@ + #define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */ + #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */ + #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */ ++#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */ ++#define KEY_DO_NOT_DISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/ + + #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ + #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ +@@ -761,6 +770,9 @@ + #define KEY_KBD_LCD_MENU4 0x2bb + #define KEY_KBD_LCD_MENU5 0x2bc + ++/* Performance Boost key (Alienware)/G-Mode key (Dell) */ ++#define KEY_PERFORMANCE 0x2bd ++ + #define BTN_TRIGGER_HAPPY 0x2c0 + #define BTN_TRIGGER_HAPPY1 0x2c0 + #define BTN_TRIGGER_HAPPY2 0x2c1 -diff -Naur old/include/event-names.h new/include/event-names.h ---- old/include/event-names.h 2024-01-01 00:00:00.000000000 +0000 -+++ new/include/event-names.h 2024-01-01 00:00:00.000000000 +0000 -@@ -63,6 +63,7 @@ - [ABS_TOOL_WIDTH] = "ABS_TOOL_WIDTH", - [ABS_VOLUME] = "ABS_VOLUME", - [ABS_MISC] = "ABS_MISC", -+ [ABS_MT_MOVEFLAG] = "ABS_MT_MOVEFLAG", - [ABS_RESERVED] = "ABS_RESERVED", - [ABS_MT_SLOT] = "ABS_MT_SLOT", - [ABS_MT_TOUCH_MAJOR] = "ABS_MT_TOUCH_MAJOR", -@@ -731,6 +732,7 @@ - [SW_MUTE_DEVICE] = "SW_MUTE_DEVICE", - [SW_PEN_INSERTED] = "SW_PEN_INSERTED", - [SW_MACHINE_COVER] = "SW_MACHINE_COVER", -+ [SW_SUPER_PRIVACY] = "SW_SUPER_PRIVACY", - }; +--- a/include/linux/linux/input-event-codes.h ++++ b/include/linux/linux/input-event-codes.h +@@ -519,6 +519,7 @@ + #define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */ + #define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */ + #define KEY_HANGUP_PHONE 0x1be /* Decline incoming call */ ++#define KEY_LINK_PHONE 0x1bf /* AL Phone Syncing */ - static const char * const ff_map[FF_MAX + 1] = { -@@ -877,6 +879,7 @@ - }; + #define KEY_DEL_EOL 0x1c0 + #define KEY_DEL_EOS 0x1c1 +@@ -600,8 +601,14 @@ + #define BTN_DPAD_LEFT 0x222 + #define BTN_DPAD_RIGHT 0x223 - static const struct name_entry code_names[] = { -+ { .name = "ABS_MT_MOVEFLAG", .value = ABS_MT_MOVEFLAG }, - { .name = "ABS_BRAKE", .value = ABS_BRAKE }, - { .name = "ABS_DISTANCE", .value = ABS_DISTANCE }, - { .name = "ABS_GAS", .value = ABS_GAS }, -diff -Naur old/include/linux/linux/input-event-codes.h new/include/linux/linux/input-event-codes.h ---- old/include/linux/linux/input-event-codes.h 2024-01-01 00:00:00.000000000 +0000 -+++ new/include/linux/linux/input-event-codes.h 2024-01-01 00:00:00.000000000 +0000 -@@ -843,6 +843,7 @@ - #define ABS_VOLUME 0x20 ++#define BTN_GRIPL 0x224 ++#define BTN_GRIPR 0x225 ++#define BTN_GRIPL2 0x226 ++#define BTN_GRIPR2 0x227 ++ + #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ + #define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ ++#define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */ - #define ABS_MISC 0x28 -+#define ABS_MT_MOVEFLAG 0x29 + #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ + #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ +@@ -617,6 +624,8 @@ + #define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */ + #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */ + #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */ ++#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */ ++#define KEY_DO_NOT_DISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/ + + #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ + #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ +@@ -761,6 +770,9 @@ + #define KEY_KBD_LCD_MENU4 0x2bb + #define KEY_KBD_LCD_MENU5 0x2bc + ++/* Performance Boost key (Alienware)/G-Mode key (Dell) */ ++#define KEY_PERFORMANCE 0x2bd ++ + #define BTN_TRIGGER_HAPPY 0x2c0 + #define BTN_TRIGGER_HAPPY1 0x2c0 + #define BTN_TRIGGER_HAPPY2 0x2c1 + +--- a/include/linux/linux/input.h ++++ b/include/linux/linux/input.h +@@ -6,14 +6,16 @@ + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ +-#ifndef _INPUT_H +-#define _INPUT_H ++#ifndef _UAPI_INPUT_H ++#define _UAPI_INPUT_H + + ++#ifndef __KERNEL__ + #include + #include + #include + #include ++#endif + + #include "input-event-codes.h" + +@@ -273,6 +275,7 @@ struct input_mask { + #define BUS_CEC 0x1E + #define BUS_INTEL_ISHTP 0x1F + #define BUS_AMD_SFH 0x20 ++#define BUS_SDW 0x21 /* - * 0x2e is reserved and should not be used in input drivers. -@@ -896,8 +897,9 @@ - #define SW_MUTE_DEVICE 0x0e /* set = device disabled */ - #define SW_PEN_INSERTED 0x0f /* set = pen inserted */ - #define SW_MACHINE_COVER 0x10 /* set = cover closed */ --#define SW_MAX 0x10 --#define SW_CNT (SW_MAX+1) -+#define SW_SUPER_PRIVACY 0x11 /* set = super privacy open */ -+#define SW_MAX 0x11 -+#define SW_CNT (SW_MAX+1) + * MT_TOOL types +@@ -513,4 +516,4 @@ struct ff_effect { + #define FF_MAX 0x7f + #define FF_CNT (FF_MAX+1) + +-#endif /* _INPUT_H */ ++#endif /* _UAPI_INPUT_H */ + +--- a/libevdev/libevdev-util.h ++++ b/libevdev/libevdev-util.h +@@ -42,19 +42,19 @@ startswith(const char *str, size_t len, const char *prefix, size_t plen) + static inline int + bit_is_set(const unsigned long *array, int bit) + { +- return !!(array[bit / LONG_BITS] & (1LL << (bit % LONG_BITS))); ++ return !!(array[bit / LONG_BITS] & (1ULL << (bit % LONG_BITS))); + } + + static inline void + set_bit(unsigned long *array, int bit) + { +- array[bit / LONG_BITS] |= (1LL << (bit % LONG_BITS)); ++ array[bit / LONG_BITS] |= (1ULL << (bit % LONG_BITS)); + } + + static inline void + clear_bit(unsigned long *array, int bit) + { +- array[bit / LONG_BITS] &= ~(1LL << (bit % LONG_BITS)); ++ array[bit / LONG_BITS] &= ~(1ULL << (bit % LONG_BITS)); + } + + static inline void + +--- a/libevdev/libevdev.c ++++ b/libevdev/libevdev.c +@@ -805,23 +805,34 @@ push_mt_sync_events(struct libevdev *dev, + int rc; + + for (int slot = 0; slot < dev->num_slots; slot++) { +- /* stopped touches were already terminated in +- * terminate_slots */ +- if (changes[slot].state == TOUCH_STOPPED || +- !bit_is_set(changes[slot].axes, ABS_MT_SLOT)) +- continue; ++ bool have_slot_event = false; + +- queue_push_event(dev, EV_ABS, ABS_MT_SLOT, slot); +- last_reported_slot = slot; ++ if (!bit_is_set(changes[slot].axes, ABS_MT_SLOT)) ++ continue; + + for (int axis = ABS_MT_MIN; axis <= ABS_MT_MAX; axis++) { + if (axis == ABS_MT_SLOT || + !libevdev_has_event_code(dev, EV_ABS, axis)) + continue; + +- if (bit_is_set(changes[slot].axes, axis)) ++ if (bit_is_set(changes[slot].axes, axis)) { ++ /* We already sent the tracking id -1 in ++ * terminate_slots so don't do that again. There ++ * may be other axes like ABS_MT_TOOL_TYPE that ++ * need to be synced despite no touch being active */ ++ if (axis == ABS_MT_TRACKING_ID && ++ *slot_value(dev, slot, axis) == -1) ++ continue; ++ ++ if (!have_slot_event) { ++ queue_push_event(dev, EV_ABS, ABS_MT_SLOT, slot); ++ last_reported_slot = slot; ++ have_slot_event = true; ++ } ++ + queue_push_event(dev, EV_ABS, axis, + *slot_value(dev, slot, axis)); ++ } + } + } - /* - * Misc events