Skip to content

Commit

Permalink
V7 trackstick works?
Browse files Browse the repository at this point in the history
  • Loading branch information
1Revenger1 committed Feb 29, 2020
1 parent a4dd28e commit f421855
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions VoodooPS2Trackpad/VoodooPS2TouchPadBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class EXPORT VoodooPS2TouchPadBase : public IOHIPointing
// normal state
int lastx, lasty, last_fingers, b4last;
UInt32 lastbuttons;
UInt32 lastTrackStickButtons, lastTouchpadButtons;
int ignoredeltas;
int ignoresingle;
int xrest, yrest, scrollrest;
Expand Down
33 changes: 21 additions & 12 deletions VoodooPS2Trackpad/alps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,17 +1072,23 @@ void ALPS::alps_process_trackstick_packet_v7(UInt8 *packet)
int x, y, z, left, right, middle;
int buttons = 0;

uint64_t now_abs;
clock_get_uptime(&now_abs);

/* It should be a DualPoint when received trackstick packet */
if (!(priv.flags & ALPS_DUALPOINT)) {
IOLog("ALPS: Rejected trackstick packet from non DualPoint device");
return;
}

x = ((packet[2] & 0xbf)) | ((packet[3] & 0x10) << 2);
y = (packet[3] & 0x07) | (packet[4] & 0xb8) |
((packet[3] & 0x20) << 1);
x = (SInt8) ((packet[2] & 0xbf) | ((packet[3] & 0x10) << 2));
y = (SInt8) ((packet[3] & 0x07) | (packet[4] & 0xb8) |
((packet[3] & 0x20) << 1));
z = (packet[5] & 0x3f) | ((packet[3] & 0x80) >> 1);

// X is inverted
x = -x;

left = (packet[1] & 0x01);
right = (packet[1] & 0x02) >> 1;
middle = (packet[1] & 0x04) >> 2;
Expand All @@ -1091,8 +1097,15 @@ void ALPS::alps_process_trackstick_packet_v7(UInt8 *packet)
buttons |= right ? 0x02 : 0;
buttons |= middle ? 0x04 : 0;

//TODO: V7 Trackstick: Someone with the hardware needs to debug this.
//dispatchRelativePointerEventX(x, y, 0, now_abs);
lastTrackStickButtons = buttons;
buttons |= lastTouchpadButtons;

/* If middle button is pressed, switch to scroll mode. Else, move pointer normally */
if (0 == (buttons & 0x04)) {
dispatchRelativePointerEventX(x, y, buttons, now_abs);
} else {
dispatchScrollWheelEventX(-y, -x, 0, now_abs);
}
}

void ALPS::alps_process_touchpad_packet_v7(UInt8 *packet){
Expand All @@ -1109,12 +1122,8 @@ void ALPS::alps_process_touchpad_packet_v7(UInt8 *packet){
buttons |= f.right ? 0x02 : 0;
buttons |= f.middle ? 0x04 : 0;

if ((priv.flags & ALPS_DUALPOINT) &&
!(priv.quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
buttons |= f.ts_left ? 0x01 : 0;
buttons |= f.ts_right ? 0x02 : 0;
buttons |= f.ts_middle ? 0x04 : 0;
}
lastTouchpadButtons = buttons;
buttons |= lastTrackStickButtons;

fingers = f.fingers;

Expand Down Expand Up @@ -2572,7 +2581,7 @@ void ALPS::set_protocol() {
if (alps_probe_trackstick_v3_v7(ALPS_REG_BASE_V7)){
priv.flags &= ~ALPS_DUALPOINT;
} else {
IOLog("ALPS: TrackStick detected... (WARNING: V7 TrackStick disabled)\n");
IOLog("ALPS: TrackStick detected...\n");
}

break;
Expand Down

0 comments on commit f421855

Please sign in to comment.