Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Add mouse protocol encoding for buttons 6-7 (wheel left/right) and 8-11
Browse files Browse the repository at this point in the history
Ref. #102
  • Loading branch information
tomscii committed Jan 14, 2023
1 parent 8db89ee commit 310d913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 1 addition & 3 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ but some will possibly be implemented in the future.
exception of highlight tracking mode that is not implemented. Mouse
highlight tracking is a mode that requires cooperation from the
client application; it is not clear if any software actively used in
2020 needs this feature. Also, all events for mouse buttons above
the conventional five (three buttons plus scroll wheel up/down) are
discarded.
2020 needs this feature.

- Blinking in general (blinking text driven by the SGR attribute 5,
and blinking cursor mode turned on/off by DEC-private set/reset
Expand Down
22 changes: 15 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,20 @@ mouseProtoSend (MouseTrackingEnc enc, int eventType, unsigned int modstate,
}
else // normal button encoding
{
if (button == 4)
cb = 64; // Mouse wheel up
else if (button == 5)
cb = 65; // Mouse wheel down
else
cb = button - 1; // Mouse button 1..3
switch (button)
{
case 1: cb = 0; break;
case 2: cb = 1; break;
case 3: cb = 2; break;
case 4: cb = 64; break; // wheel up
case 5: cb = 65; break; // wheel down
case 6: cb = 66; break; // wheel left
case 7: cb = 67; break; // wheel right
case 8: cb = 128; break;
case 9: cb = 129; break;
case 10: cb = 130; break;
case 11: cb = 131; break;
}
}

if (modstate & ShiftMask) cb += 4;
Expand Down Expand Up @@ -766,7 +774,7 @@ onButtonPressMouseProto (XButtonEvent& xbevt,
{
uint16_t cx, cy;

if (xbevt.button > 5)
if (xbevt.button > 11)
return;

switch (mouseTrk.mode)
Expand Down

0 comments on commit 310d913

Please sign in to comment.