Compare commits

..

7 commits

Author SHA1 Message Date
Giulio P
be44b6e6a8 doc: fix typo
Remove a repetition of words in the comments on
libevdev_set_event_value()

Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/131>
2025-12-07 02:31:20 +00:00
Peter Hutterer
139b58e135 libevdev 1.13.6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-12-01 15:12:22 +10:00
Peter Hutterer
c6bf238c4e include: sync event codes with kernel 6.18
Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/129>
2025-12-01 14:49:50 +10:00
Peter Hutterer
f3a9c2038d libevdev 1.13.5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-10-20 14:49:38 +10:00
Marcos Alano
9289c9826c Sync headers with kernel 6.17
Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/126>
2025-09-28 20:34:21 -03:00
Peter Hutterer
a30a461e82 util: change the bit to shift to ULL
libevdev/libevdev-util.h:45:45: runtime error: left shift of 1 by 63 places cannot be represented in type 'long long'

Fixes: #32
Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/127>
2025-08-13 21:23:10 +10:00
Peter Hutterer
d093b4752a include: sync event codes with kernel 6.16
Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/125>
2025-07-29 09:07:13 +10:00
9 changed files with 86 additions and 18 deletions

View file

@ -7,7 +7,7 @@ AC_PREREQ([2.62])
# change meson version too # change meson version too
AC_INIT([libevdev], AC_INIT([libevdev],
[1.13.4], [1.13.6],
[https://gitlab.freedesktop.org/libevdev/libevdev/issues/], [https://gitlab.freedesktop.org/libevdev/libevdev/issues/],
[libevdev], [libevdev],
[http://freedesktop.org/wiki/Software/libevdev/]) [http://freedesktop.org/wiki/Software/libevdev/])

View file

@ -27,6 +27,7 @@
#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */
#define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */
#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */
#define INPUT_PROP_PRESSUREPAD 0x07 /* pressure triggers clicks */
#define INPUT_PROP_MAX 0x1f #define INPUT_PROP_MAX 0x1f
#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
@ -519,6 +520,7 @@
#define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */ #define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */
#define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */ #define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */
#define KEY_HANGUP_PHONE 0x1be /* Decline 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_EOL 0x1c0
#define KEY_DEL_EOS 0x1c1 #define KEY_DEL_EOS 0x1c1
@ -600,6 +602,11 @@
#define BTN_DPAD_LEFT 0x222 #define BTN_DPAD_LEFT 0x222
#define BTN_DPAD_RIGHT 0x223 #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_ALS_TOGGLE 0x230 /* Ambient light sensor */
#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ #define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */
#define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */ #define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */
@ -624,6 +631,18 @@
#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
/*
* Keycodes for hotkeys toggling the electronic privacy screen found on some
* laptops on/off. Note when the embedded-controller turns on/off the eprivacy
* screen itself then the state should be reported through drm connecter props:
* https://www.kernel.org/doc/html/latest/gpu/drm-kms.html#standard-connector-properties
* Except when implementing the drm connecter properties API is not possible
* because e.g. the firmware does not allow querying the presence and/or status
* of the eprivacy screen at boot.
*/
#define KEY_EPRIVACY_SCREEN_ON 0x252
#define KEY_EPRIVACY_SCREEN_OFF 0x253
#define KEY_KBDINPUTASSIST_PREV 0x260 #define KEY_KBDINPUTASSIST_PREV 0x260
#define KEY_KBDINPUTASSIST_NEXT 0x261 #define KEY_KBDINPUTASSIST_NEXT 0x261
#define KEY_KBDINPUTASSIST_PREVGROUP 0x262 #define KEY_KBDINPUTASSIST_PREVGROUP 0x262
@ -764,6 +783,9 @@
#define KEY_KBD_LCD_MENU4 0x2bb #define KEY_KBD_LCD_MENU4 0x2bb
#define KEY_KBD_LCD_MENU5 0x2bc #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_HAPPY 0x2c0
#define BTN_TRIGGER_HAPPY1 0x2c0 #define BTN_TRIGGER_HAPPY1 0x2c0
#define BTN_TRIGGER_HAPPY2 0x2c1 #define BTN_TRIGGER_HAPPY2 0x2c1
@ -924,7 +946,8 @@
#define SW_MUTE_DEVICE 0x0e /* set = device disabled */ #define SW_MUTE_DEVICE 0x0e /* set = device disabled */
#define SW_PEN_INSERTED 0x0f /* set = pen inserted */ #define SW_PEN_INSERTED 0x0f /* set = pen inserted */
#define SW_MACHINE_COVER 0x10 /* set = cover closed */ #define SW_MACHINE_COVER 0x10 /* set = cover closed */
#define SW_MAX 0x10 #define SW_USB_INSERT 0x11 /* set = USB audio device connected */
#define SW_MAX 0x11
#define SW_CNT (SW_MAX+1) #define SW_CNT (SW_MAX+1)
/* /*

View file

@ -27,6 +27,7 @@
#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */
#define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */
#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */
#define INPUT_PROP_PRESSUREPAD 0x07 /* pressure triggers clicks */
#define INPUT_PROP_MAX 0x1f #define INPUT_PROP_MAX 0x1f
#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
@ -519,6 +520,7 @@
#define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */ #define KEY_NOTIFICATION_CENTER 0x1bc /* Show/hide the notification center */
#define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */ #define KEY_PICKUP_PHONE 0x1bd /* Answer incoming call */
#define KEY_HANGUP_PHONE 0x1be /* Decline 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_EOL 0x1c0
#define KEY_DEL_EOS 0x1c1 #define KEY_DEL_EOS 0x1c1
@ -600,6 +602,11 @@
#define BTN_DPAD_LEFT 0x222 #define BTN_DPAD_LEFT 0x222
#define BTN_DPAD_RIGHT 0x223 #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_ALS_TOGGLE 0x230 /* Ambient light sensor */
#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ #define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */
#define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */ #define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */
@ -624,6 +631,18 @@
#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
/*
* Keycodes for hotkeys toggling the electronic privacy screen found on some
* laptops on/off. Note when the embedded-controller turns on/off the eprivacy
* screen itself then the state should be reported through drm connecter props:
* https://www.kernel.org/doc/html/latest/gpu/drm-kms.html#standard-connector-properties
* Except when implementing the drm connecter properties API is not possible
* because e.g. the firmware does not allow querying the presence and/or status
* of the eprivacy screen at boot.
*/
#define KEY_EPRIVACY_SCREEN_ON 0x252
#define KEY_EPRIVACY_SCREEN_OFF 0x253
#define KEY_KBDINPUTASSIST_PREV 0x260 #define KEY_KBDINPUTASSIST_PREV 0x260
#define KEY_KBDINPUTASSIST_NEXT 0x261 #define KEY_KBDINPUTASSIST_NEXT 0x261
#define KEY_KBDINPUTASSIST_PREVGROUP 0x262 #define KEY_KBDINPUTASSIST_PREVGROUP 0x262
@ -764,6 +783,9 @@
#define KEY_KBD_LCD_MENU4 0x2bb #define KEY_KBD_LCD_MENU4 0x2bb
#define KEY_KBD_LCD_MENU5 0x2bc #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_HAPPY 0x2c0
#define BTN_TRIGGER_HAPPY1 0x2c0 #define BTN_TRIGGER_HAPPY1 0x2c0
#define BTN_TRIGGER_HAPPY2 0x2c1 #define BTN_TRIGGER_HAPPY2 0x2c1
@ -924,7 +946,8 @@
#define SW_MUTE_DEVICE 0x0e /* set = device disabled */ #define SW_MUTE_DEVICE 0x0e /* set = device disabled */
#define SW_PEN_INSERTED 0x0f /* set = pen inserted */ #define SW_PEN_INSERTED 0x0f /* set = pen inserted */
#define SW_MACHINE_COVER 0x10 /* set = cover closed */ #define SW_MACHINE_COVER 0x10 /* set = cover closed */
#define SW_MAX 0x10 #define SW_USB_INSERT 0x11 /* set = USB audio device connected */
#define SW_MAX 0x11
#define SW_CNT (SW_MAX+1) #define SW_CNT (SW_MAX+1)
/* /*

View file

@ -6,14 +6,16 @@
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation. * the Free Software Foundation.
*/ */
#ifndef _INPUT_H #ifndef _UAPI_INPUT_H
#define _INPUT_H #define _UAPI_INPUT_H
#ifndef __KERNEL__
#include <sys/time.h> #include <sys/time.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/types.h> #include <linux/types.h>
#endif
#include "input-event-codes.h" #include "input-event-codes.h"
@ -273,6 +275,7 @@ struct input_mask {
#define BUS_CEC 0x1E #define BUS_CEC 0x1E
#define BUS_INTEL_ISHTP 0x1F #define BUS_INTEL_ISHTP 0x1F
#define BUS_AMD_SFH 0x20 #define BUS_AMD_SFH 0x20
#define BUS_SDW 0x21
/* /*
* MT_TOOL types * MT_TOOL types
@ -426,6 +429,24 @@ struct ff_rumble_effect {
__u16 weak_magnitude; __u16 weak_magnitude;
}; };
/**
* struct ff_haptic_effect
* @hid_usage: hid_usage according to Haptics page (WAVEFORM_CLICK, etc.)
* @vendor_id: the waveform vendor ID if hid_usage is in the vendor-defined range
* @vendor_waveform_page: the vendor waveform page if hid_usage is in the vendor-defined range
* @intensity: strength of the effect as percentage
* @repeat_count: number of times to retrigger effect
* @retrigger_period: time before effect is retriggered (in ms)
*/
struct ff_haptic_effect {
__u16 hid_usage;
__u16 vendor_id;
__u8 vendor_waveform_page;
__u16 intensity;
__u16 repeat_count;
__u16 retrigger_period;
};
/** /**
* struct ff_effect - defines force feedback effect * struct ff_effect - defines force feedback effect
* @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
@ -462,6 +483,7 @@ struct ff_effect {
struct ff_periodic_effect periodic; struct ff_periodic_effect periodic;
struct ff_condition_effect condition[2]; /* One for each axis */ struct ff_condition_effect condition[2]; /* One for each axis */
struct ff_rumble_effect rumble; struct ff_rumble_effect rumble;
struct ff_haptic_effect haptic;
} u; } u;
}; };
@ -469,6 +491,7 @@ struct ff_effect {
* Force feedback effect types * Force feedback effect types
*/ */
#define FF_HAPTIC 0x4f
#define FF_RUMBLE 0x50 #define FF_RUMBLE 0x50
#define FF_PERIODIC 0x51 #define FF_PERIODIC 0x51
#define FF_CONSTANT 0x52 #define FF_CONSTANT 0x52
@ -478,7 +501,7 @@ struct ff_effect {
#define FF_INERTIA 0x56 #define FF_INERTIA 0x56
#define FF_RAMP 0x57 #define FF_RAMP 0x57
#define FF_EFFECT_MIN FF_RUMBLE #define FF_EFFECT_MIN FF_HAPTIC
#define FF_EFFECT_MAX FF_RAMP #define FF_EFFECT_MAX FF_RAMP
/* /*
@ -513,4 +536,4 @@ struct ff_effect {
#define FF_MAX 0x7f #define FF_MAX 0x7f
#define FF_CNT (FF_MAX+1) #define FF_CNT (FF_MAX+1)
#endif /* _INPUT_H */ #endif /* _UAPI_INPUT_H */

View file

@ -42,19 +42,19 @@ startswith(const char *str, size_t len, const char *prefix, size_t plen)
static inline int static inline int
bit_is_set(const unsigned long *array, int bit) 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 static inline void
set_bit(unsigned long *array, int bit) 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 static inline void
clear_bit(unsigned long *array, int bit) 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 static inline void

View file

@ -1563,8 +1563,7 @@ int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsi
* *
* @return 0 on success, or -1 on failure. * @return 0 on success, or -1 on failure.
* @retval -1 * @retval -1
* - the device does not have the event type or * - the device does not have the event type or code enabled, or
* - code enabled, or the code is outside the, or
* - the code is outside the allowed limits for the given type, or * - the code is outside the allowed limits for the given type, or
* - the type cannot be set, or * - the type cannot be set, or
* - the value is not permitted for the given code. * - the value is not permitted for the given code.

View file

@ -1,5 +1,5 @@
project('libevdev', 'c', project('libevdev', 'c',
version: '1.13.4', # change autotools version too version: '1.13.6', # change autotools version too
license: 'MIT/Expat', license: 'MIT/Expat',
default_options: [ 'c_std=gnu99', 'warning_level=2' ], default_options: [ 'c_std=gnu99', 'warning_level=2' ],
meson_version: '>= 0.56.0') meson_version: '>= 0.56.0')

View file

@ -158,7 +158,7 @@ START_TEST(test_code_sw_name)
ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_RFKILL_ALL), "SW_RFKILL_ALL"); ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_RFKILL_ALL), "SW_RFKILL_ALL");
ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_LINEIN_INSERT), "SW_LINEIN_INSERT"); ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_LINEIN_INSERT), "SW_LINEIN_INSERT");
ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_PEN_INSERTED), "SW_PEN_INSERTED"); ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_PEN_INSERTED), "SW_PEN_INSERTED");
ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_MAX), "SW_MACHINE_COVER"); ck_assert_str_eq(libevdev_event_code_get_name(EV_SW, SW_MAX), "SW_USB_INSERT");
} }
END_TEST END_TEST

View file

@ -617,12 +617,12 @@ START_TEST(test_syn_delta_sw)
EV_SYN, SYN_DROPPED, EV_SYN, SYN_DROPPED,
EV_SW, SW_HEADPHONE_INSERT, EV_SW, SW_HEADPHONE_INSERT,
EV_SW, SW_MICROPHONE_INSERT, EV_SW, SW_MICROPHONE_INSERT,
EV_SW, SW_MAX, EV_SW, SW_MACHINE_COVER, /* Replace with SW_MAX once runners are on 6.16 */
-1); -1);
uinput_device_event(uidev, EV_SW, SW_HEADPHONE_INSERT, 1); uinput_device_event(uidev, EV_SW, SW_HEADPHONE_INSERT, 1);
uinput_device_event(uidev, EV_SW, SW_MICROPHONE_INSERT, 1); uinput_device_event(uidev, EV_SW, SW_MICROPHONE_INSERT, 1);
uinput_device_event(uidev, EV_SW, SW_MAX, 1); uinput_device_event(uidev, EV_SW, SW_MACHINE_COVER, 1);
uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0); uinput_device_event(uidev, EV_SYN, SYN_REPORT, 0);
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev); rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC); ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
@ -635,7 +635,7 @@ START_TEST(test_syn_delta_sw)
assert_event(&ev, EV_SW, SW_MICROPHONE_INSERT, 1); assert_event(&ev, EV_SW, SW_MICROPHONE_INSERT, 1);
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev); rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC); ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
assert_event(&ev, EV_SW, SW_MAX, 1); assert_event(&ev, EV_SW, SW_MACHINE_COVER, 1);
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev); rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev);
ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC); ck_assert_int_eq(rc, LIBEVDEV_READ_STATUS_SYNC);
assert_event(&ev, EV_SYN, SYN_REPORT, 0); assert_event(&ev, EV_SYN, SYN_REPORT, 0);
@ -644,7 +644,7 @@ START_TEST(test_syn_delta_sw)
ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_HEADPHONE_INSERT), 1); ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_HEADPHONE_INSERT), 1);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_MICROPHONE_INSERT), 1); ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_MICROPHONE_INSERT), 1);
ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_MAX), 1); ck_assert_int_eq(libevdev_get_event_value(dev, EV_SW, SW_MACHINE_COVER), 1);
uinput_device_free(uidev); uinput_device_free(uidev);
libevdev_free(dev); libevdev_free(dev);