Browse Source

* compiles again with -dnomouse

Jonas Maebe 25 years ago
parent
commit
47ff00a141
2 changed files with 31 additions and 14 deletions
  1. 24 10
      api/linux/keyboard.inc
  2. 7 4
      api/linux/mouse.inc

+ 24 - 10
api/linux/keyboard.inc

@@ -211,20 +211,27 @@ Begin
 End;
 End;
 
 
 
 
-Function KeyPressed:Boolean;
+{ This one doesn't care about keypresses already processed by readkey  }
+{ and waiting in the KeyBuffer, only about waiting keypresses at the   }
+{ TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
+function sysKeyPressed: boolean;
 var
 var
   fdsin : fdSet;
   fdsin : fdSet;
-Begin
-  if (KeySend<>KeyPut) or (InCnt>0) then
-   KeyPressed:=true
+begin
+  if (InCnt>0) then
+   sysKeyPressed:=true
   else
   else
    begin
    begin
      FD_Zero(fdsin);
      FD_Zero(fdsin);
      fd_Set(StdInputHandle,fdsin);
      fd_Set(StdInputHandle,fdsin);
-     Keypressed:=(Select(StdInputHandle+1,@fdsin,nil,nil,1)>0);
+     sysKeypressed:=(Select(StdInputHandle+1,@fdsin,nil,nil,0)>0);
    end;
    end;
-End;
+end;
 
 
+Function KeyPressed:Boolean;
+Begin
+  Keypressed := (KeySend<>KeyPut) or sysKeyPressed;
+End;
 
 
 Function ReadKey:char;
 Function ReadKey:char;
 Var
 Var
@@ -240,8 +247,12 @@ Begin
      exit;
      exit;
    end;
    end;
 {Wait for Key}
 {Wait for Key}
-  repeat
-  until keypressed;
+  if not sysKeyPressed then
+   begin
+     FD_Zero (fdsin);
+     FD_Set (StdInputHandle,fdsin);
+     Select (StdInputHandle+1,@fdsin,nil,nil,nil);
+   end;
   ch:=ttyRecvChar;
   ch:=ttyRecvChar;
 {Esc Found ?}
 {Esc Found ?}
   If (ch=#27) then
   If (ch=#27) then
@@ -251,7 +262,7 @@ Begin
      State:=1;
      State:=1;
      if InCnt=0 then
      if InCnt=0 then
       Select(StdInputHandle+1,@fdsin,nil,nil,10);
       Select(StdInputHandle+1,@fdsin,nil,nil,10);
-     while (State<>0) and (KeyPressed) do
+     while (State<>0) and (sysKeyPressed) do
       begin
       begin
         ch:=ttyRecvChar;
         ch:=ttyRecvChar;
         OldState:=State;
         OldState:=State;
@@ -565,7 +576,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2000-01-06 01:20:31  peter
+  Revision 1.2  2000-06-30 09:00:33  jonas
+    * compiles again with -dnomouse
+
+  Revision 1.1  2000/01/06 01:20:31  peter
     * moved out of packages/ back to topdir
     * moved out of packages/ back to topdir
 
 
   Revision 1.1  1999/11/24 23:36:38  peter
   Revision 1.1  1999/11/24 23:36:38  peter

+ 7 - 4
api/linux/mouse.inc

@@ -171,7 +171,7 @@ var
 {$endif ndef NOMOUSE}
 {$endif ndef NOMOUSE}
 begin
 begin
 {$ifdef NOMOUSE}
 {$ifdef NOMOUSE}
-  fillchar(@MouseEvent,SizeOf(TMouseEvent),#0);
+  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
 {$else ndef NOMOUSE}
 {$else ndef NOMOUSE}
   if gpm_fd<0 then
   if gpm_fd<0 then
    exit;
    exit;
@@ -210,7 +210,7 @@ var
 {$endif ndef NOMOUSE}
 {$endif ndef NOMOUSE}
 begin
 begin
 {$ifdef NOMOUSE}
 {$ifdef NOMOUSE}
-  fillchar(@MouseEvent,SizeOf(TMouseEvent),#0);
+  fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
   exit(false);
   exit(false);
 {$else ndef NOMOUSE}
 {$else ndef NOMOUSE}
   if gpm_fd<0 then
   if gpm_fd<0 then
@@ -246,7 +246,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2000-04-17 08:51:38  pierre
+  Revision 1.3  2000-06-30 09:00:33  jonas
+    * compiles again with -dnomouse
+
+  Revision 1.2  2000/04/17 08:51:38  pierre
    + set conditional NOMOUSE to get dummy mouse unit
    + set conditional NOMOUSE to get dummy mouse unit
 
 
   Revision 1.1  2000/01/06 01:20:31  peter
   Revision 1.1  2000/01/06 01:20:31  peter
@@ -278,4 +281,4 @@ end;
   Revision 1.2  1998/10/29 12:49:49  peter
   Revision 1.2  1998/10/29 12:49:49  peter
     * more fixes
     * more fixes
 
 
-}
+}