Tablet mode switch is not disabling keyboard/trackpad as expected.
Summary
I made a small service that creates a virtual device to switch my laptop into tablet mode, because the default tablet mode signal from ACPI switches my laptop into tablet mode at inappropriate times. Namely, whenever the laptop was turned on its side (regardless of how it's folded), the screen would rotate and the keyboard and touchpad would turn off.
I found that removing the intel-hid
module prevented this behavior from happening, but I wanted a way to manually switch back and forth into tablet mode.
The virtual switch behaves as expected in GNOME, i.e. it enables tablet mode, and the screen automatically rotates when I rotate my device.
However, the virtual switch device does not disable the trackpad and keyboard, which limits its utility as an actual tablet mode override switch.
As far as I can tell, this behavior is mediated by libinput, but I haven't been able to figure out why my virtual device is being treated differently than the real tablet mode switch.
Steps to reproduce
I made a small test program that adds a virtual device and emits the tablet switch events, you can build and run it with the steps below,
git clone https://gitlab.com/jmole/tablet-mode-hotkey.git
cd tablet-mode-hotkey
git checkout test
make test
sudo ./tablet-mode-test & sudo libinput debug-events
Required information
- libinput version: 1.25.0
Real device (from intel-hid
module):
Device: Intel HID switches
Kernel: /dev/input/event256
Group: 13
Seat: seat0, default
Capabilities: switch
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: n/a
Nat.scrolling: n/a
Middle emulation: n/a
Calibration: n/a
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles: n/a
Rotation: 0.0
Fake device (created by program)
Device: Fake Intel HID switches
Kernel: /dev/input/event25
Group: 16
Seat: seat0, default
Capabilities: switch
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: n/a
Nat.scrolling: n/a
Middle emulation: n/a
Calibration: n/a
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles: n/a
Rotation: 0.0
Recording from intel-hid
switches (which turns off keyboard/touchpad):
/dev/input/event259: Intel HID switches
Select the device event number: 259
Recording to 'stdout'.
# libinput record
version: 1
ndevices: 1
libinput:
version: "1.25.0"
git: "unknown"
system:
kernel: "6.9.0-rc3-next-20240410-1-next-git-05042-g6ebf211bb11d-dirty"
dmi: "dmi:bvnAMI:bvrF.08:bd01/25/2024:br15.8:efr86.37:svnHP:pnHPSpectrex3602-in-1Laptop16t-aa000:pvr:rvnHP:rn8C17:rvr86.37:cvnHP:ct31:cvrChassisVersion:sku7M3K7AV:"
devices:
- node: /dev/input/event259
evdev:
# Name: Intel HID switches
# ID: bus 0x0019 vendor 0x0000 product 0x0000 version 0x0000
# Supported Events:
# Event type 0 (EV_SYN)
# Event type 5 (EV_SW)
# Event code 1 (SW_TABLET_MODE)
# State 0
# Properties:
name: "Intel HID switches"
id: [25, 0, 0, 0]
codes:
0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # EV_SYN
5: [1] # EV_SW
properties: []
udev:
properties:
- ID_INPUT=1
- ID_INPUT_SWITCH=1
quirks:
events:
# Current time is 14:23:54
# Current time is 14:23:57
- evdev:
- [ 0, 0, 5, 1, 1] # EV_SW / SW_TABLET_MODE 1
- [ 0, 0, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +0ms
# Current time is 14:24:00
- evdev:
- [ 2, 333023, 5, 1, 0] # EV_SW / SW_TABLET_MODE 0
- [ 2, 333023, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +2333ms
Recording from fake HID switches (which doesn't turn off keyboard/touchpad):
/dev/input/event25: Fake Intel HID switches
Select the device event number: 25
Recording to 'stdout'.
# libinput record
version: 1
ndevices: 1
libinput:
version: "1.25.0"
git: "unknown"
system:
kernel: "6.9.0-rc3-next-20240410-1-next-git-05042-g6ebf211bb11d-dirty"
dmi: "dmi:bvnAMI:bvrF.08:bd01/25/2024:br15.8:efr86.37:svnHP:pnHPSpectrex3602-in-1Laptop16t-aa000:pvr:rvnHP:rn8C17:rvr86.37:cvnHP:ct31:cvrChassisVersion:sku7M3K7AV:"
devices:
- node: /dev/input/event25
evdev:
# Name: Fake Intel HID switches
# ID: bus 0x0019 vendor 0x1234 product 0x1234 version 0x1234
# Supported Events:
# Event type 0 (EV_SYN)
# Event type 5 (EV_SW)
# Event code 1 (SW_TABLET_MODE)
# State 0
# Properties:
name: "Fake Intel HID switches"
id: [25, 4660, 4660, 4660]
codes:
0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # EV_SYN
5: [1] # EV_SW
properties: []
udev:
properties:
- ID_INPUT=1
- ID_INPUT_SWITCH=1
quirks:
events:
# Current time is 14:25:17
- evdev:
- [ 0, 0, 5, 1, 1] # EV_SW / SW_TABLET_MODE 1
- [ 0, 0, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +0ms
# Current time is 14:25:20
- evdev:
- [ 1, 503021, 5, 1, 0] # EV_SW / SW_TABLET_MODE 0
- [ 1, 503021, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +1503ms