mirror of
https://github.com/openharmony/third_party_libevdev.git
synced 2026-07-21 06:25:21 -04:00
4786e63163
Signed-off-by: zhengyaozong <zhengyaozong@h-partners.com>
217 lines
7.8 KiB
Diff
217 lines
7.8 KiB
Diff
Copyright (C) 2021-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
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
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.
|
|
|
|
diff --git a/include/linux/freebsd/input-event-codes.h b/include/linux/freebsd/input-event-codes.h
|
|
index c5713e4..c514cb0 100644
|
|
--- 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 --git a/include/linux/linux/input-event-codes.h b/include/linux/linux/input-event-codes.h
|
|
index 539acc9..acc4574 100644
|
|
--- 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 */
|
|
|
|
#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 --git a/include/linux/linux/input.h b/include/linux/linux/input.h
|
|
index 7f37e6e..fff30fa 100644
|
|
--- 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 <sys/time.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/types.h>
|
|
#include <linux/types.h>
|
|
+#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
|
|
|
|
/*
|
|
* 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 */
|
|
diff --git a/libevdev/libevdev-util.h b/libevdev/libevdev-util.h
|
|
index ed85c95..cab8067 100644
|
|
--- 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
|
|
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
|
|
index 6931177..3eefc87 100644
|
|
--- 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));
|
|
+ }
|
|
}
|
|
}
|
|
|