Browse Source

* mousebutton 4 and 5 support (gpm only?) Mantis #13469

git-svn-id: trunk@24164 -
marco 12 years ago
parent
commit
07e23b8401
2 changed files with 16 additions and 1 deletions
  1. 2 0
      rtl/inc/mouseh.inc
  2. 14 1
      rtl/unix/keyboard.pp

+ 2 - 0
rtl/inc/mouseh.inc

@@ -33,6 +33,8 @@ const
   MouseLeftButton   = $01;                         { Left mouse button }
   MouseRightButton  = $02;                         { Right mouse button }
   MouseMiddleButton = $04;                         { Middle mouse button }
+  MouseButton4      = $08;
+  MouseButton5      = $10;
 
   MouseEventBufSize = 16;                { Size of event queue }
 

+ 14 - 1
rtl/unix/keyboard.pp

@@ -491,6 +491,13 @@ const
     Action : 0;
   );
 
+  procedure GenFakeReleaseEvent(MouseEvent : TMouseEvent);
+  begin
+    MouseEvent.action := MouseActionUp;
+    MouseEvent.buttons := 0;
+    PutMouseEvent(MouseEvent);
+  end;
+  
   procedure GenMouseEvent;
   var MouseEvent: TMouseEvent;
       ch : char;
@@ -510,7 +517,7 @@ const
      bit  5   : mouse movement while button down.
      bit  6   : interpret button 1 as button 4
                 interpret button 2 as button 5}
-    case buttonval and 3 of
+    case buttonval and 67 of
       0 : {left button press}
         MouseEvent.buttons:=1;
       1 : {middle button pressed }
@@ -519,6 +526,10 @@ const
         MouseEvent.buttons:=4;
       3 : { no button pressed }
         MouseEvent.buttons:=0;
+      64: { button 4 pressed }
+          MouseEvent.buttons:=8;
+      65: { button 5 pressed }
+          MouseEvent.buttons:=16;
     end;
      if inhead=intail then
        fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
@@ -552,6 +563,8 @@ const
        end;
 *)
      PutMouseEvent(MouseEvent);
+     if (MouseEvent.buttons and (8+16)) <> 0 then // 'M' escape sequence cannot map button 4&5 release, so fake one.
+       GenFakeReleaseEvent(MouseEvent);
 {$ifdef DebugMouse}
      if MouseEvent.Action=MouseActionDown then
        Write(system.stderr,'Button down : ')