1
0
Fork 0
forked from wry/wry

seat: implement per-device keymaps

This commit is contained in:
Julian Orth 2024-04-12 17:06:16 +02:00
parent 225995eb2f
commit 826f40adca
21 changed files with 293 additions and 71 deletions

View file

@ -818,6 +818,10 @@ impl Client {
self.send(&ClientMessage::SetSeat { device, seat })
}
pub fn set_device_keymap(&self, device: InputDevice, keymap: Keymap) {
self.send(&ClientMessage::DeviceSetKeymap { device, keymap })
}
pub fn set_left_handed(&self, device: InputDevice, left_handed: bool) {
self.send(&ClientMessage::SetLeftHanded {
device,

View file

@ -432,6 +432,10 @@ pub enum ClientMessage<'a> {
enabled: bool,
},
GetSocketPath,
DeviceSetKeymap {
device: InputDevice,
keymap: Keymap,
},
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -25,6 +25,16 @@ impl InputDevice {
get!().set_seat(self, seat)
}
/// Sets the keymap of the device.
///
/// This overrides the keymap set for the seat. The keymap becomes active when a key
/// on the device is pressed.
///
/// Setting the invalid keymap reverts to the seat keymap.
pub fn set_keymap(self, keymap: Keymap) {
get!().set_device_keymap(self, keymap)
}
/// Returns whether the device has the specified capability.
pub fn has_capability(self, cap: Capability) -> bool {
get!(false).has_capability(self, cap)