mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-05 13:40:16 +01:00
lid: disable all types but EV_SYN and EV_SW
The lid dispatch interface is a one-trick pony and can only handle SW_LID. It
ignores other switches but crashes on any event type other than EV_SW and
EV_SYN. Disable those types so we just ignore the event instead of asserting.
https://bugs.freedesktop.org/show_bug.cgi?id=101853
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
(cherry picked from commit 6bb05c594a)
This commit is contained in:
parent
582ce30d27
commit
a57d0d458f
6 changed files with 107 additions and 0 deletions
|
|
@ -512,6 +512,7 @@ if get_option('tests')
|
|||
'test/litest-device-cyborg-rat-5.c',
|
||||
'test/litest-device-elantech-touchpad.c',
|
||||
'test/litest-device-generic-singletouch.c',
|
||||
'test/litest-device-gpio-keys.c',
|
||||
'test/litest-device-huion-pentablet.c',
|
||||
'test/litest-device-keyboard.c',
|
||||
'test/litest-device-keyboard-all-codes.c',
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ struct evdev_dispatch *
|
|||
evdev_lid_switch_dispatch_create(struct evdev_device *lid_device)
|
||||
{
|
||||
struct lid_switch_dispatch *dispatch = zalloc(sizeof *dispatch);
|
||||
int type;
|
||||
|
||||
if (dispatch == NULL)
|
||||
return NULL;
|
||||
|
|
@ -311,5 +312,12 @@ evdev_lid_switch_dispatch_create(struct evdev_device *lid_device)
|
|||
|
||||
dispatch->lid_is_closed = false;
|
||||
|
||||
for (type = EV_KEY; type < EV_CNT; type++) {
|
||||
if (type == EV_SW)
|
||||
continue;
|
||||
|
||||
libevdev_disable_event_type(lid_device->evdev, type);
|
||||
}
|
||||
|
||||
return &dispatch->base;
|
||||
}
|
||||
|
|
|
|||
75
test/litest-device-gpio-keys.c
Normal file
75
test/litest-device-gpio-keys.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright © 2017 Red Hat, Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "litest.h"
|
||||
#include "litest-int.h"
|
||||
|
||||
static void
|
||||
litest_gpio_keys_setup(void)
|
||||
{
|
||||
struct litest_device *d = litest_create_device(LITEST_GPIO_KEYS);
|
||||
litest_set_current_device(d);
|
||||
}
|
||||
|
||||
static struct input_id input_id = {
|
||||
.bustype = 0x19,
|
||||
.vendor = 0x1,
|
||||
.product = 0x1,
|
||||
};
|
||||
|
||||
static int events[] = {
|
||||
EV_SW, SW_LID,
|
||||
EV_SW, SW_TABLET_MODE,
|
||||
EV_KEY, KEY_POWER,
|
||||
EV_KEY, KEY_VOLUMEUP,
|
||||
EV_KEY, KEY_VOLUMEDOWN,
|
||||
EV_KEY, KEY_POWER,
|
||||
-1, -1,
|
||||
};
|
||||
|
||||
static const char udev_rule[] =
|
||||
"ACTION==\"remove\", GOTO=\"switch_end\"\n"
|
||||
"KERNEL!=\"event*\", GOTO=\"switch_end\"\n"
|
||||
"\n"
|
||||
"ATTRS{name}==\"litest gpio-keys*\",\\\n"
|
||||
" ENV{ID_INPUT_SWITCH}=\"1\",\\\n"
|
||||
" ENV{LIBINPUT_ATTR_gpio_keys_RELIABILITY}=\"reliable\"\n"
|
||||
"\n"
|
||||
"LABEL=\"switch_end\"";
|
||||
|
||||
struct litest_test_device litest_gpio_keys_device = {
|
||||
.type = LITEST_GPIO_KEYS,
|
||||
.features = LITEST_SWITCH,
|
||||
.shortname = "gpio keys",
|
||||
.setup = litest_gpio_keys_setup,
|
||||
.interface = NULL,
|
||||
|
||||
.name = "gpio-keys",
|
||||
.id = &input_id,
|
||||
.events = events,
|
||||
.absinfo = NULL,
|
||||
|
||||
.udev_rule = udev_rule,
|
||||
};
|
||||
|
|
@ -416,6 +416,7 @@ extern struct litest_test_device litest_mouse_wheel_tilt_device;
|
|||
extern struct litest_test_device litest_lid_switch_device;
|
||||
extern struct litest_test_device litest_lid_switch_surface3_device;
|
||||
extern struct litest_test_device litest_appletouch_device;
|
||||
extern struct litest_test_device litest_gpio_keys_device;
|
||||
|
||||
struct litest_test_device* devices[] = {
|
||||
&litest_synaptics_clickpad_device,
|
||||
|
|
@ -481,6 +482,7 @@ struct litest_test_device* devices[] = {
|
|||
&litest_lid_switch_device,
|
||||
&litest_lid_switch_surface3_device,
|
||||
&litest_appletouch_device,
|
||||
&litest_gpio_keys_device,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ enum litest_device_type {
|
|||
LITEST_LID_SWITCH,
|
||||
LITEST_LID_SWITCH_SURFACE3,
|
||||
LITEST_APPLETOUCH,
|
||||
LITEST_GPIO_KEYS,
|
||||
};
|
||||
|
||||
enum litest_device_feature {
|
||||
|
|
|
|||
|
|
@ -555,6 +555,24 @@ START_TEST(lid_update_hw_on_key_closed_on_init)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(lid_key_press)
|
||||
{
|
||||
struct litest_device *sw = litest_current_device();
|
||||
struct libinput *li = sw->libinput;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_keyboard_key(sw, KEY_POWER, true);
|
||||
litest_keyboard_key(sw, KEY_POWER, false);
|
||||
libinput_dispatch(li);
|
||||
|
||||
/* We should route the key events correctly, but for now we just
|
||||
* ignore them. This test will fail once the key events are handled
|
||||
* correctly. */
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void
|
||||
litest_setup_tests_lid(void)
|
||||
{
|
||||
|
|
@ -576,4 +594,6 @@ litest_setup_tests_lid(void)
|
|||
|
||||
litest_add_for_device("lid:buggy", lid_update_hw_on_key, LITEST_LID_SWITCH_SURFACE3);
|
||||
litest_add_for_device("lid:buggy", lid_update_hw_on_key_closed_on_init, LITEST_LID_SWITCH_SURFACE3);
|
||||
|
||||
litest_add_for_device("lid:keypress", lid_key_press, LITEST_GPIO_KEYS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue