diff --git a/src/bin/client.rs b/src/bin/client.rs index 7ce3fe6..2dfeeee 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -114,9 +114,10 @@ fn udp_loop(connection: &protocol::Connection, pointer: &Vp, keyboard: &Vk, q: E loop { if let Some(event) = connection.receive_event() { match event { - protocol::Event::Mouse { t, x, y } => { pointer.motion(t, x, y); pointer.frame(); } - protocol::Event::Button { t, b, s } => { pointer.button(t, b, s); pointer.frame(); } - protocol::Event::Axis { t, a, v } => { pointer.axis(t, a, v); pointer.frame(); } + protocol::Event::Mouse { t, x, y } => { pointer.motion(t, x, y); } + protocol::Event::Button { t, b, s } => { pointer.button(t, b, s); } + protocol::Event::Axis { t, a, v } => { pointer.axis(t, a, v); } + protocol::Event::Frame { } => { pointer.frame(); }, protocol::Event::Key { t, k, s } => { keyboard.key(t, k, u32::from(s)); pointer.frame(); }, protocol::Event::KeyModifier { mods_depressed, mods_latched, mods_locked, group } => { keyboard.modifiers(mods_depressed, mods_latched, mods_locked, group); diff --git a/src/bin/server.rs b/src/bin/server.rs index 5deefb4..3c12904 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -364,6 +364,9 @@ impl Dispatch for App { let e = protocol::Event::Axis { t: time, a: (axis.into_result().unwrap()), v: value }; app.connection.send_event(&e); } + wl_pointer::Event::Frame {} => { + app.connection.send_event(&protocol::Event::Frame{}); + } _ => (), } } diff --git a/src/protocol.rs b/src/protocol.rs index aabbdc3..a340f40 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -45,6 +45,7 @@ pub enum Event { Mouse{t: u32, x: f64, y: f64}, Button{t: u32, b: u32, s: ButtonState}, Axis{t: u32, a: Axis, v: f64}, + Frame{}, Key{t: u32, k: u32, s: KeyState}, KeyModifier{mods_depressed: u32, mods_latched: u32, mods_locked: u32, group: u32}, } @@ -67,12 +68,13 @@ impl From> for Event { a: (Axis::try_from(buf[5] as u32).unwrap()), v: (f64::from_ne_bytes(buf[6..14].try_into().unwrap())), }, - 3 => Self::Key { + 3 => Self::Frame {}, + 4 => Self::Key { t: u32::from_ne_bytes(buf[1..5].try_into().unwrap()), k: u32::from_ne_bytes(buf[5..9].try_into().unwrap()), s: KeyState::try_from(buf[9] as u32).unwrap(), }, - 4 => Self::KeyModifier { + 5 => Self::KeyModifier { mods_depressed: u32::from_ne_bytes(buf[1..5].try_into().unwrap()), mods_latched: u32::from_ne_bytes(buf[5..9].try_into().unwrap()), mods_locked: u32::from_ne_bytes(buf[9..13].try_into().unwrap()), @@ -105,14 +107,17 @@ impl From<&Event> for Vec { buf.push(u32::from(*a) as u8); buf.extend_from_slice(v.to_ne_bytes().as_ref()); } - Event::Key{t, k, s } => { + Event::Frame{} => { buf.push(3u8); + } + Event::Key{t, k, s } => { + buf.push(4u8); buf.extend_from_slice(t.to_ne_bytes().as_ref()); buf.extend_from_slice(k.to_ne_bytes().as_ref()); buf.push(u32::from(*s) as u8); } Event::KeyModifier{ mods_depressed, mods_latched, mods_locked, group } => { - buf.push(4u8); + buf.push(5u8); buf.extend_from_slice(mods_depressed.to_ne_bytes().as_ref()); buf.extend_from_slice(mods_latched.to_ne_bytes().as_ref()); buf.extend_from_slice(mods_locked.to_ne_bytes().as_ref());