1.. _switches: 2 3============================================================================== 4Switches 5============================================================================== 6 7libinput supports the lid and tablet-mode switches. Unlike button events 8that come in press and release pairs, switches are usually toggled once and 9left at the setting for an extended period of time. 10 11Only some switches are handled by libinput, see **libinput_switch** for a 12list of supported switches. Switch events are exposed to the caller, but 13libinput may handle some switch events internally and enable or disable 14specific features based on a switch state. 15 16The order of switch events is guaranteed to be correct, i.e., a switch will 17never send consecutive switch on, or switch off, events. 18 19.. _switches_lid: 20 21------------------------------------------------------------------------------ 22Lid switch handling 23------------------------------------------------------------------------------ 24 25Where available, libinput listens to devices providing a lid switch. 26The evdev event code ``EV_SW`` ``SW_LID`` is provided as 27**LIBINPUT_SWITCH_LID**. If devices with a lid switch have a touchpad device, 28the device is disabled while the lid is logically closed. This is to avoid 29ghost touches that can be caused by interference with touchpads and the 30closed lid. The touchpad is automatically re-enabled whenever the lid is 31opened. 32 33This handling of lid switches is transparent to the user, no notifications 34are sent and the device appears as enabled at all times. 35 36On some devices, the device's lid state does not always reflect the physical 37state and the lid state may report as closed even when the lid is physically 38open. libinput employs some heuristics to detect user input (specifically 39typing) to re-enable the touchpad on those devices. Where input is detected, 40libinput updates the lid status of the kernel device so other consumers of 41the kernel events also get the accurate state. 42 43.. _switches_tablet_mode: 44 45------------------------------------------------------------------------------ 46Tablet mode switch handling 47------------------------------------------------------------------------------ 48 49Where available, libinput listens to devices providing a tablet mode switch. 50This switch is usually triggered on devices that can switch between a normal 51laptop layout and a tablet-like layout. One example for such a device is the 52Lenovo Yoga. 53 54The event sent by the kernel is ``EV_SW`` ``SW_TABLET_MODE`` and is provided as 55**LIBINPUT_SWITCH_TABLET_MODE**. When the device switches to tablet mode, 56the touchpad and internal keyboard are disabled. If a trackpoint exists, 57it is disabled too. The input devices are automatically re-enabled whenever 58tablet mode is disengaged. 59 60This handling of tablet mode switches is transparent to the user, no 61notifications are sent and the device appears as enabled at all times. 62