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