Send SYN_REPORT with shift modifying keys to make libinput happy

This commit is contained in:
Travis Burtrum 2017-12-06 00:06:44 -05:00
parent d0fdea6ff6
commit 0e58664f67
3 changed files with 51 additions and 7 deletions

40
notes.txt Normal file
View File

@ -0,0 +1,40 @@
After all these years of this technique working perfectly, libinput goes and breaks it (along with apparantly many other things):
https://bugs.freedesktop.org/show_bug.cgi?id=104030
A normal USB keyboard pressing shift+3:
E: 0.000001 0004 0004 458977 # EV_MSC / MSC_SCAN 458977
E: 0.000001 0001 002a 0001 # EV_KEY / KEY_LEFTSHIFT 1
E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.151990 0004 0004 458784 # EV_MSC / MSC_SCAN 458784
E: 0.151990 0001 0004 0001 # EV_KEY / KEY_3 1
E: 0.151990 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +151ms
#E: 0.327930 0004 0004 458784 # EV_MSC / MSC_SCAN 458784
E: 0.327930 0001 0004 0000 # EV_KEY / KEY_3 0
E: 0.327930 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +176ms
E: 0.400020 0004 0004 458977 # EV_MSC / MSC_SCAN 458977
E: 0.400020 0001 002a 0000 # EV_KEY / KEY_LEFTSHIFT 0
E: 0.400020 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +73ms
rusty-keys pre SYN_REPORT fix:
E: 0.000001 0001 002a 0001 # EV_KEY / KEY_LEFTSHIFT 1
E: 0.000001 0001 001a 0001 # EV_KEY / KEY_LEFTBRACE 1
E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
{E: 0.031945 0001 001a 0000 # EV_KEY / KEY_LEFTBRACE 0
E: 0.031945 0001 002a 0000 # EV_KEY / KEY_LEFTSHIFT 0
E: 0.031945 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +31ms
rusty-keys post SYN_REPORT fix:
E: 0.000001 0001 002a 0001 # EV_KEY / KEY_LEFTSHIFT 1
E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.000032 0001 001a 0001 # EV_KEY / KEY_LEFTBRACE 1
E: 0.000032 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
{E: 0.096031 0001 001a 0000 # EV_KEY / KEY_LEFTBRACE 0
E: 0.096031 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +96ms
E: 0.096091 0001 002a 0000 # EV_KEY / KEY_LEFTSHIFT 0
E: 0.096091 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
Seems to be good enough for now...

View File

@ -18,7 +18,7 @@ impl Device {
}
#[doc(hidden)]
pub fn write(&mut self, kind: c_int, code: c_int, value: c_int) -> Res<()> {
pub fn write(&self, kind: c_int, code: c_int, value: c_int) -> Res<()> {
let mut event = input_event {
time: timeval { tv_sec: 0, tv_usec: 0 },
type_: kind as u16,
@ -44,27 +44,27 @@ impl Device {
}
/// Synchronize the device.
pub fn synchronize(&mut self) -> Res<()> {
pub fn synchronize(&self) -> Res<()> {
self.write(EV_SYN, SYN_REPORT, 0)
}
/// Send an event.
pub fn send(&mut self, kind: c_int, code: c_int, value: i32) -> Res<()> {
pub fn send(&self, kind: c_int, code: c_int, value: i32) -> Res<()> {
self.write(kind, code, value)
}
/// Send a press event.
pub fn press(&mut self, kind: c_int, code: c_int) -> Res<()> {
pub fn press(&self, kind: c_int, code: c_int) -> Res<()> {
self.write(kind, code, 1)
}
/// Send a release event.
pub fn release(&mut self, kind: c_int, code: c_int) -> Res<()> {
pub fn release(&self, kind: c_int, code: c_int) -> Res<()> {
self.write(kind, code, 0)
}
/// Send a press and release event.
pub fn click(&mut self, kind: c_int, code: c_int) -> Res<()> {
pub fn click(&self, kind: c_int, code: c_int) -> Res<()> {
try!(self.press(kind, code));
try!(self.release(kind, code));
@ -72,7 +72,7 @@ impl Device {
}
/// Send a relative or absolute positioning event.
pub fn position(&mut self, kind: c_int, code: c_int, value: i32) -> Res<()> {
pub fn position(&self, kind: c_int, code: c_int, value: i32) -> Res<()> {
self.write(kind, code, value)
}
}

View File

@ -321,6 +321,8 @@ impl HalfInvertedKey {
}
//event.code.send_event(key_state, event, device);
device.write_event(event)?;
// SYN_REPORT after, then key, then key's SYN_REPORT
device.synchronize()?;
event.code = code; // not needed since u16 does it
event.value = value;
}
@ -342,6 +344,8 @@ impl HalfInvertedKey {
event.value = UP;
}
//event.code.send_event(key_state, event, device);
// SYN_REPORT first after key, then shift, then key's SYN_REPORT which will be used for shift's
device.synchronize()?;
device.write_event(event)?;
// neither of these are needed now...
event.code = code; // not needed since u16 does it