From 7b610b2d4bbfb72f31cc631c16be07973fbe8a16 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 31 Jul 2004 03:01:37 +0200 Subject: [PATCH] Fixed some problems with ALPS guest devices. From Alastair M. Robinson: * The guest mouse doesn't report button releases. * The stick pointer has buttons of its own, and they don't work. Attached is another patch, this one far less invasive than the last, which fixes these two problems. (The button presses that come from the stick pointer's buttons arrive in events with pressure set to 127, just like stick movement - but this doesn't seem to be terribly reliable - I think the button release gets reported with true pressure when the touchpad is being used too. For this reason, I've set these up to report as ->left / ->right, not as ->guest_left / ->guest_right.) * One issue that remains - the middle button emulation for two button mice doesn't seem to work for the guest mouse. Fixed by me. --- alpscomm.c | 11 ++++++----- synaptics.c | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/alpscomm.c b/alpscomm.c index 01db0d7..992f4c5 100644 --- a/alpscomm.c +++ b/alpscomm.c @@ -160,10 +160,8 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw) y = y - 256; hw->guest_dx = x; hw->guest_dy = -y; - if (packet[0] & 0x01) - hw->guest_left = 1; - if (packet[0] & 0x02) - hw->guest_right = 1; + hw->guest_left = (packet[0] & 0x01) ? TRUE : FALSE; + hw->quest_right = (packet[0] & 0x02) ? TRUE : FALSE; return; } @@ -178,7 +176,10 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw) y = y - 512; hw->guest_dx = x; hw->guest_dy = -y; - z = 0; + hw->left = packet[2] & 1; + hw->left |= packet[3] & 1; + hw->right = (packet[2] >> 1) & 1; + hw->right |= (packet[3] >> 1) & 1; return; } diff --git a/synaptics.c b/synaptics.c index 8e26c23..7e72453 100644 --- a/synaptics.c +++ b/synaptics.c @@ -1323,6 +1323,12 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) hw->up |= hw->multi[0]; hw->down |= hw->multi[1]; + if (!para->guestmouse_off) { + hw->left |= hw->guest_left; + hw->middle |= hw->guest_mid; + hw->right |= hw->guest_right; + } + /* 3rd button emulation */ hw->middle |= HandleMidButtonEmulation(priv, hw, &delay); @@ -1369,11 +1375,6 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) timeleft = ComputeDeltas(priv, hw, edge, &dx, &dy); delay = MIN(delay, timeleft); - if (!para->guestmouse_off) { - hw->left |= hw->guest_left; - hw->middle |= hw->guest_mid; - hw->right |= hw->guest_right; - } buttons = ((hw->left ? 0x01 : 0) | (hw->middle ? 0x02 : 0) | (hw->right ? 0x04 : 0) |